[14:17:54] [Server thread/ERROR]: Could not load 'E:\PocketMine-MP\plugins\CratePlugin_v1' in folder 'E:\PocketMine-MP\plugins\': Argument 2 passed to pocketmine\permission\Permission::loadPermission() must be of the type array, null given, called in phar://E:/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/permission/Permission.php on line 207 [14:17:54] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to pocketmine\permission\Permission::loadPermission() must be of the type array, null given, called in phar://E:/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/permission/Permission.php on line 207" (EXCEPTION) in "/src/pocketmine/permission/Permission" at line 223 any ideas of what ive done wrong?
<?php namespace CratePlugin_v1\CratePlugin_v1: use pocketmine\plugin\PluginBase: use pocketmine\command\CommandSender: use pocketmine\command\Command:\ use pocketmine\Player: use pocketmine\Server: use pocketmine\utils\TextFormat as c: class Main extends PluginBase{ } public function onEnable(){ $this->getLogger()->notice(c::BOLD.c:ARK_PURPLE."(!)". c::RESET.c:ARK_AQUA." CratePlugin Has been enabled"): } public function onCommand(CommandSender $sender , $Command $cnd, $label, $args)( if(strtolower($cnd->getName()) == "Cratekey")( $sender->isOp() { $sender->sendMessage(c::BOLD.c:ARK_PURPLE."(!)".c:ARK_AQUA." You have been given x1 common crate key!"): $sender->getInventory()->addItem(item::get(131:1,0,0)); }elseif{!$sender->hasPermission("OP")) $sender->sendMessage(c::BOLD.c:ARK_RED."(!)".c::RESET.c::RED." Invalid Permissions"): } } } public function onDisable()} $this->getLogger()->warning(c::BOLD.c:ARK_RED."(!)".c::RESET.c::RED."CratePlugin has been disabled"): } } ?> id assume its the $array at the start of my code causing the issues.
Please put your code in php blocks so we can actually read it. ([php][/php]) I've seen multiple issues in your code already, not sure about the original error.
Here, I've freed your code from the countless syntax errors and put it in a code block. PHP: <?phpnamespace CratePlugin_v1\CratePlugin_v;use pocketmine\plugin\PluginBase;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\item\Item;use pocketmine\Player;use pocketmine\Server;use pocketmine\utils\TextFormat as c;class Main extends PluginBase{ public function onEnable(){ $this->getLogger()->notice(c::BOLD . c::DARK_PURPLE . "(!)" . c::RESET.c::DARK_AQUA . "CratePlugin Has been enabled"); } public function onCommand(CommandSender $sender, Command $cnd, string $label, array $args) : bool{ if(strtolower($cnd->getName()) === "cratekey"){ if($sender->isOp()){ $sender->sendMessage(c::BOLD . c::DARK_PURPLE . "(!)" . c::AQUA . "You have been given x1 common crate key!"); $sender->getInventory()->addItem(Item::get(131:1,0,0)); }else{ $sender->sendMessage(c::BOLD . c::DARK_RED . "(!)" . c::RESET . c::RED . "InvalidPermissions"); } } return true; } public function onDisable(){ $this->getLogger()->warning(c::BOLD . c::DARK_RED . "(!)" . c::RESET . c::RED . "CratePlugin has been disabled"); }} Now please go learn how PHP works and how the syntax works. You're clearly not ready to use it yet
I've learnt php just not familiar with the API. And I suppose this is my first time structuring a plugin and for that matter a php file.
Strtolower will make you big letters to small so when you write $ cmd-> getName () with strtolower for Cratekey is logical that it will not work .
Using the API was exactly the part you did do right. I found at least 1 syntax error each line of the plugin.
Well thanks for the criticism but hey, I suppose I gotta keep going at it Thanks for the advice! Looking back at my code, I'm honestly ashamed the errors I made were so basic and I should be ashamed as I've made simple syntax errors Sorry for the frustration I've caused.
Thanks for the help, ik That I should of used the correct syntax format but that didn't solve the initial error I was having.