PHP: <?phpdeclare(strict_types=1);namespace PrinceAce\ShopTest;use pocketmine\Player;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\plugin\PluginBase;use pocketmine\item\Item;use pocketmine\item\enchantment\Enchantment;class Main extends PluginBase{ public function onEnable(){ /*i will use EconomyAPI*/$this->money = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI"); $this->getLogger()->info("§eEnable"); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { /*Register Function*/ $money = $this->money->myMoney($sender->getName()); switch($command->getName()){ case "shop": if(!$sender instanceof Player){ $sender->sendMessage("§cRun commands in game!"); return true; } if(!isset($args[0])){ $sender->sendMessage("§Commands:§6/shop list"); return true; } if(!in_array($args[0],array("list, buy"))){ $sender->sendMessage("§cCommands §6/shop list"); return true; } if(strtolower($args[0]) == "list"){ $sender->sendMessage("§9SHOP ITEM\n§e64 Stone - 100$\n64 Grass - 300$\nDiamond Swords - 1000$"); return true; } if(strtolower($args[0]) == "buy") if(!isset($args[1])){ $sender->sendMessage("§e/shop buy <id>"); return true; } if(!in_array($args[1],array("Stone","Grass","Swords"))){ $sender->sendMessage("§cError!"); return true; } if(strtolower($args[1]) == "Stone"){ if($money >= 100){ /*Reduce Money*/ $this->money->reduceMoney($sender->getName(), 100); $sender->getInventory()->addItem(item::get(1,0,64)); $sender->sendMessage("§aSuccess!"); }else{ $sender->sendMessage("§cError!"); } } if(strtolower($args[1]) == "Grass"){ if($money >= 300){ $this->money->reduceMoney($sender->getName(), 300); $sender->getInventory()->addItem(item::get(2,0,64)); $sender->sendMessage("§aSuccess!"); }else{ $sender->sendMessage("§cError!"); } } if(strtolower($args[1]) == "Swords"){ if($money >= 1000){ $this->money->reduceMoney($sender->getName(), 1000); $sender->sendMessage("§aSuccess!"); $item = item::get(276,0,1); $item->addEnchantment(Enchantment::getEnchantment(9)->setLevel(2)); }else{ $sender->sendMessage("§cError!"); } } } }} when i use /shop in game no result or not working i dont have a error why not working?
i already fix that thanks but when i type /shop got this error [12:19:26] [Server thread/CRITICAL]: TypeError: "Return value of PrincessAcesia\TestShop\Main:nCommand() must be of the type bool, none returned" (EXCEPTION) in "plugins/TestShop/src/PrincessAcesia/TestShop/Main" at line 81 this is my code https://pastebin.com/XHxJAubh
PHP: <?phpdeclare(strict_types=1);namespace PrinceAce\TestShop;use pocketmine\Player;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\plugin\PluginBase;use pocketmine\item\Item;use pocketmine\item\enchantment\Enchantment;class Main extends PluginBase{ public function onEnable(){ /*i will use EconomyAPI*/$this->money = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI"); $this->getLogger()->info("§eEnable"); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { /*Register Function*/ $money = $this->money->myMoney($sender->getName()); switch($command->getName()){ case "shop": if(!$sender instanceof Player){ $sender->sendMessage("§cRun commands in game!"); return true; } if(!isset($args[0])){ $sender->sendMessage("§6Commands§f:§6/shop list"); return true; } if(!in_array($args[0],array("list","buy"))){ $sender->sendMessage("§cCommands§f:§6/shop list"); return true; } if(strtolower($args[0]) == "list"){ $sender->sendMessage("§9SHOP ITEM\n§e64 Stone - 100$\n64 Grass - 300$\nDiamond Swords - 1000$"); return true; } if(strtolower($args[0]) == "buy") if(!isset($args[1])){ $sender->sendMessage("§e/shop buy §7<id>"); return true; } if(!in_array($args[1],array("Stone","Grass","Swords"))){ $sender->sendMessage("§cError!"); return true; } if(strtolower($args[1]) == "Stone"){ if($money >= 100){ /*Reduce Money*/ $this->money->reduceMoney($sender->getName(), 100); $sender->getInventory()->addItem(item::get(1,0,64)); $sender->sendMessage("§aSuccess!"); }else{ $sender->sendMessage("§cError!"); } } if(strtolower($args[1]) == "Grass"){ if($money >= 300){ $this->money->reduceMoney($sender->getName(), 300); $sender->getInventory()->addItem(item::get(2,0,64)); $sender->sendMessage("§aSuccess!"); }else{ $sender->sendMessage("§cError!"); } } if(strtolower($args[1]) == "Swords"){ if($money >= 1000){ $this->money->reduceMoney($sender->getName(), 1000); $sender->sendMessage("§aSuccess!"); $item = item::get(276,0,1); $item->addEnchantment(Enchantment::getEnchantment(9)->setLevel(2)); }else{ $sender->sendMessage("§cError!"); } } } return true; }} [14:09:16] [Server thread/CRITICAL]: TypeError: "Return value of PrinceAce\TestShop\Main:nCommand() must be of the type bool, none returned" (EXCEPTION) in "plugins/TestShop/src/PrinceAce/TestShop/Main" at line 81 not working??