I don't know how to fix this, so I came here (yes I'm a big noob lol). So this is the error: Code: 2020-03-15 [20:25:34] [Server thread/CRITICAL]: Error: "Call to a member function banPlayerCombatHacks() on null" (EXCEPTION) in "plugins/StaffMode/src/ethaniccc/StaffMode/BanMenu" at line 40 This is my code in BanMenu.php: PHP: <?phpnamespace ethaniccc\StaffMode;use muqsit\invmenu\InvMenu;use pocketmine\inventory\transaction\action\SlotChangeAction;use pocketmine\item\Item;use pocketmine\Player;use pocketmine\scheduler\ClosureTask;use pocketmine\utils\TextFormat;use pocketmine\Server;class BanMenu{ private $plugin; public function _construct(StaffMode $plugin){ $this->plugin = $plugin; } public function openBanMenu(Player $sender, Player $who) : void{ $menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST); $menu->readonly(); $menu->setName(TextFormat::RED . $who->getName() . "'s profile"); for($i = 0; $i <= 53; ++$i) { $menu->getInventory()->setItem($i, Item::get(Item::STAINED_GLASS_PANE, 0, 1)->setCustomName(TextFormat::RESET . " ")); } $menu->getInventory()->setItem(20, Item::get(276, 0, 1)->setCustomName(TextFormat::BOLD . TextFormat::RED . "Combat Hacks")); $menu->setListener(function(Player $player, Item $itemClicked, Item $itemClickedWith, SlotChangeAction $action) use ($who, $menu) : bool{ switch ($itemClicked->getId()) { case Item::DIAMOND_SWORD: $player->removeWindow($action->getInventory()); $this->plugin->banPlayerCombatHacks($who); //line of error return false; break; } }); $menu->send($sender); }} Can anyone help me?
That means that $this->plugin is null, there is probably something wrong in the part of your code where you create the BanMenu object. (new Banmenu())
I fixed it by making it so that instead of my BanMenu class into going back into the main class and using a function from there, I just used the code from the function and put it in there, now it doesn't appear.