Need help from a dev

Discussion in 'Development' started by Brant, Feb 4, 2020.

  1. Brant

    Brant Slime

    Messages:
    97
    GitHub:
    tetroyt
    i recently found out that in the QuestPMMP plugin you can set commands as rewards but it doesnt say in the config or the read me file how to do it. and i dont understand code could someone help figure out how i would do it in the config? in the php file (aQuestListener) line 125 it talks about award id ‘other’ and command sender heres the code:

    if($award['id'] == 'other') {
    Server::getInstance()->dispatchCommand(new ConsoleCommandSender(), str_replace('{player}', $player->getName(), $award['command']));
    $player->sendMessage(str_replace(['{quest}', '{award}'], [$this->plugin->config['quests'][$id], $award['name'] ?? 'Привелегия'], $text));
    return true;
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    if its a yml file
    - other give {player} 1 1: [] OR
    - other:give {player} 1 1: [] OR
    other:give {player} 1 1: []

    But i dont see an explode for the : o an implode for a " " So idk
     
  3. Brant

    Brant Slime

    Messages:
    97
    GitHub:
    tetroyt
    thank you ill try it, also ive noticed in a lot of configs when it comes to listing stuff starting with - theres 2 spaces should i do that?
     
  4. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    Yes just follow the format
     
  5. Brant

    Brant Slime

    Messages:
    97
    GitHub:
    tetroyt
    i got this error idk if it will help
    [22:25:19] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\item\Item::get() must be of the type int, string given, called in phar:///home/minecraft/plugins/QuestPMMP_dev-1.phar/src/AlexBrin/aQuestListener.php on line 134" (EXCEPTION) in "src/pocketmine/item/Item" at line 104

    [22:25:19] [Server thread/DEBUG]: #0 plugins/QuestPMMP_dev-1.phar/src/AlexBrin/aQuestListener(134): pocketmine\item\Item::get(string[38] other - givekit {player} ..cStarter..r, integer 0, integer 1)

    [22:25:19] [Server thread/DEBUG]: #1 plugins/QuestPMMP_dev-1.phar/src/AlexBrin/aQuestListener(103): AlexBrin\aQuestListener->giveAward(object pocketmine\Player, array[4], integer 0)

    [22:25:19] [Server thread/DEBUG]: #2 plugins/QuestPMMP_dev-1.phar/src/AlexBrin/aQuestListener(56): AlexBrin\aQuestListener->checkQuest(object pocketmine\Player, array[2], string[10] blockbreak, integer 1)

    [22:25:19] [Server thread/DEBUG]: #3 src/pocketmine/plugin/MethodEventExecutor(42): AlexBrin\aQuestListener->onBlockBreak(object pocketmine\event\block\BlockBreakEvent)

    [22:25:19] [Server thread/DEBUG]: #4 src/pocketmine/plugin/RegisteredListener(100): pocketmine\plugin\MethodEventExecutor->execute(object AlexBrin\aQuestListener, object pocketmine\event\block\BlockBreakEvent)

    [22:25:19] [Server thread/DEBUG]: #5 src/pocketmine/event/Event(95): pocketmine\plugin\RegisteredListener->callEvent(object pocketmine\event\block\BlockBreakEvent)

    [22:25:19] [Server thread/DEBUG]: #6 src/pocketmine/level/Level(1932): pocketmine\event\Event->call()

    [22:25:19] [Server thread/DEBUG]: #7 src/pocketmine/Player(2598): pocketmine\level\Level->useBreakOn(object pocketmine\math\Vector3, object pocketmine\item\Pickaxe, object pocketmine\Player, boolean 1)

    [22:25:19] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(151): pocketmine\Player->handleInventoryTransaction(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket)

    [22:25:19] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(178): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket)

    [22:25:19] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(111): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)

    [22:25:19] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/protocol/BatchPacket(130): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket)

    [22:25:19] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(111): pocketmine\network\mcpe\protocol\BatchPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)

    [22:25:19] [Server thread/DEBUG]: #13 src/pocketmine/Player(3276): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)

    [22:25:19] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/RakLibInterface(169): pocketmine\Player->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)

    [22:25:19] [Server thread/DEBUG]: #15 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string[19] 92.22.221.176 62204, object raklib\protocol\EncapsulatedPacket, integer 0)

    [22:25:19] [Server thread/DEBUG]: #16 src/pocketmine/network/mcpe/RakLibInterface(109): raklib\server\ServerHandler->handlePacket()

    [22:25:19] [Server thread/DEBUG]: #17 src/pocketmine/network/mcpe/RakLibInterface(99): pocketmine\network\mcpe\RakLibInterface->process()

    [22:25:19] [Server thread/DEBUG]: #18 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()

    [22:25:19] [Server thread/DEBUG]: #19 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()

    [22:25:19] [Server thread/DEBUG]: #20 src/pocketmine/Server(2406): pocketmine\snooze\SleeperHandler->sleepUntil(double 1580851519.0942)

    [22:25:19] [Server thread/DEBUG]: #21 src/pocketmine/Server(2250): pocketmine\Server->tickProcessor()

    [22:25:19] [Server thread/DEBUG]: #22 src/pocketmine/Server(1811): pocketmine\Server->start()

    [22:25:19] [Server thread/DEBUG]: #23 src/pocketmine/PocketMine(274): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[16] /home/minecraft/, string[24] /home/minecraft/plugins/)

    [22:25:19] [Server thread/DEBUG]: #24 src/pocketmine/PocketMine(297): pocketmine\server()

    [22:25:19] [Server thread/DEBUG]: #25 (1): require(string[68] phar:///home/minecraft/pocketmine.phar/src/pocketmine/PocketMine.php)
     
  6. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    Show the lines in the code
     
  7. Brant

    Brant Slime

    Messages:
    97
    GitHub:
    tetroyt
    if($award['id'] == 'other') {
    Server::getInstance()->dispatchCommand(new ConsoleCommandSender(), str_replace('{player}', $player->getName(), $award['command']));
    $player->sendMessage(str_replace(['{quest}', '{award}'], [$this->plugin->config['quests'][$id], $award['name'] ?? 'Привелегия'], $text));
    return true;
    }
    if(!isset($award['damage']))
    $award['damage'] = 0;
    if(!isset($award['count']))
    $award['count'] = 1;
    $item = Item::get($award['id'], $award['damage'], $award['count']);
    $itemName = $award['name'] ?? $item->getName();
    if(isset($award['name']))
    $item->setCustomName($award['name']);
    if($award['enchant'] !== false) {
    $award['enchant'] = explode(' ', $award['enchant']);
    if(!isset($award['enchant'][1]))
    $award['enchant'][1] = 1;
    $ench = Enchantment::getEnchantment($award['enchant'][0])->setLevel($award['enchant'][1]);
    $item->addEnchantment($ench);
    }
    $player->getInventory()->addItem($item);
    $player->sendMessage(['{quest}', '{award}', '{count}'], [$this->plugin->config['quests'][$id], $itemName, $award['count']], $this->plugin->config['questEnd']);
     
  8. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    Please use the PHP Code insert
     
  9. Brant

    Brant Slime

    Messages:
    97
    GitHub:
    tetroyt
    PHP:
                if($award['id'] == 'other') {
                    
    Server::getInstance()->dispatchCommand(new ConsoleCommandSender(), str_replace('{player}'$player->getName(), $award['command']));
                    
    $player->sendMessage(str_replace(['{quest}''{award}'], [$this->plugin->config['quests'][$id], $award['name'] ?? 'Привелегия'], $text));
                    return 
    true;
                }
                if(!isset(
    $award['damage']))
                    
    $award['damage'] = 0;
                if(!isset(
    $award['count']))
                    
    $award['count'] = 1;
                
    $item Item::get($award['id'], $award['damage'], $award['count']);
                
    $itemName $award['name'] ?? $item->getName();
                if(isset(
    $award['name']))
                    
    $item->setCustomName($award['name']);
                if(
    $award['enchant'] !== false) {
                    
    $award['enchant'] = explode(' '$award['enchant']);
                    if(!isset(
    $award['enchant'][1]))
                        
    $award['enchant'][1] = 1;
                    
    $ench Enchantment::getEnchantment($award['enchant'][0])->setLevel($award['enchant'][1]);
                    
    $item->addEnchantment($ench);
                }
                
    $player->getInventory()->addItem($item);
                
    $player->sendMessage(['{quest}''{award}''{count}'], [$this->plugin->config['quests'][$id], $itemName$award['count']], $this->plugin->config['questEnd']);
            }

        }

    ?>
     
  10. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    Can i see a couple of lines in the file?
     
  11. Brant

    Brant Slime

    Messages:
    97
    GitHub:
    tetroyt
    do you want me to just send the whole plugin?
     
  12. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    No just like 2 items you put in the file
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.