I have this code: PHP: <?php/* * ___ __ __ * |_ _|_ ____ _| \/ | ___ _ __ _ _ * | || '_ \ \ / / |\/| |/ _ \ '_ \| | | | * | || | | \ V /| | | | __/ | | | |_| | * |___|_| |_|\_/ |_| |_|\___|_| |_|\__,_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * @author Muqsit * @link http://github.com/Muqsit **/namespace muqsit\invmenu;use muqsit\invmenu\inventories\BaseFakeInventory;use pocketmine\event\inventory\InventoryTransactionEvent;use pocketmine\event\Listener;use pocketmine\inventory\transaction\action\SlotChangeAction;use pocketmine\plugin\Plugin;use pocketmine\Player;class InvMenuHandler implements Listener{ /** @var Plugin|null */ private static $registrant; protected $player; private function __construct(Player $player){ $this->player = $player; } public function getBannedPlayer() : Player{ return $this->player; } public static function isRegistered() : bool{ return self::$registrant instanceof Plugin; } public static function getRegistrant() : Plugin{ return self::$registrant; } public static function register(Plugin $plugin) : void{ if(self::isRegistered()){ throw new \Error($plugin->getName() . "attempted to register " . self::class . " twice."); } self::$registrant = $plugin; $bannedplayer = $this->player; $plugin->getServer()->getPluginManager()->registerEvents(new InvMenuHandler($bannedplayer), $plugin); } /** * @param InventoryTransactionEvent $event * @priority NORMAL * @ignoreCancelled true */ public function onInventoryTransaction(InventoryTransactionEvent $event) : void{ $transaction = $event->getTransaction(); foreach($transaction->getActions() as $action){ if($action instanceof SlotChangeAction){ $inventory = $action->getInventory(); if($inventory instanceof BaseFakeInventory){ $menu = $inventory->getMenu(); $listener = $menu->getListener(); if(($listener !== null && !$listener($transaction->getSource(), $this->getBannedPlayer(), $action->getSourceItem(), $action->getTargetItem(), $action)) || $menu->isReadonly()){ $event->setCancelled(); return; } } } } } When i started the server, it showed this Code: 2019-01-28 [17:59:50] [Server thread/CRITICAL]: Error: "Using $this when not in object context" (EXCEPTION) in "plugins/Core [SW]/src/muqsit/invmenu/InvMenuHandler" at line 58 2019-01-28 [17:59:50] [Server thread/DEBUG]: #0 plugins/Core [SW]/src/Core/command/PunishCommand(22): muqsit\invmenu\InvMenuHandler::register(Core\Main object) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #1 plugins/Core [SW]/src/Core/Main(40): Core\command\PunishCommand->__construct(Core\Main object) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginBase(123): Core\Main->onEnable() 2019-01-28 [17:59:50] [Server thread/DEBUG]: #3 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #4 src/pocketmine/Server(2003): pocketmine\plugin\PluginManager->enablePlugin(Core\Main object) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #5 src/pocketmine/Server(1989): pocketmine\Server->enablePlugin(Core\Main object) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #6 src/pocketmine/Server(1783): pocketmine\Server->enablePlugins(integer 1) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #7 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Administrator\Desktop\Minecraft\HeroMC 1vs1\, string C:\Users\Administrator\Desktop\Minecraft\HeroMC 1vs1\plugins\) 2019-01-28 [17:59:50] [Server thread/DEBUG]: #8 (1): require(string phar://C:/Users/Administrator/Desktop/Minecraft/HeroMC 1vs1/PocketMine-MP.phar/src/pocketmine/PocketMine.php) P/S: Please Muqsit dont blame me for editing your code stupidly
You can't use "$this" in a static function change the code so you can get the player variable without using "$this" in the static function
I recommend you read the InvMenu wiki to find out how to properly use the library/virion through examples. https://github.com/Muqsit/InvMenu/wiki/Examples