Ok, i have an plugin: MainClass: PHP: class Main extends PluginBase implementsListener{public function onEnable() {$this->getServer()->getPluginManager()->registerEvents($this, $this);new InventoryManager($this, "SW");}} MainClass works fine But on new InventoryManager($this, "SW"); PHP: <?phpnamespace robske_110\ServerCore;use pocketmine\event\entity\EntityLevelChangeEvent;use pocketmine\event\player\PlayerQuitEvent;#use pocketmine\event\inventory\InventoryEvent; //TODO::ForLaterImplementationToSaveStuffBetter#use pocketmine\event\player\PlayerExperienceChangeEvent; //TODO::ForLaterImplementationToSaveStuffBetter#use pocketmine\event\player\FOOD; //TODO::ForLaterImplementationToSaveStuffBetter#use pocketmine\event\entity\EntityDamageEvent; //TODO::ForLaterImplementationToSaveStuffBetteruse pocketmine\event\Listener;use pocketmine\Player;use pocketmine\utils\Config;use pocketmine\plugin\PluginBase;#use pocketmine\utils\TextFormat; //TODO::Messagesuse pocketmine\item\Item;class InventoryManager extends Main implements Listener{ public $WatchWorld; private $MainConfig; private $Server; private $savedInv; //TODO::Events ForLaterImplementationToSaveStuffBetter private $savedExp; //TODO::Events ForLaterImplementationToSaveStuffBetter private $savedFood; //TODO::WaitingForEvents ForLaterImplementationToSaveStuffBetter private $savedHealth; //TODO::Events ForLaterImplementationToSaveStuffBetter private $Stats; public function __construct($MAIN, $WatchWorld = NULL){ if ($WatchWorld == NULL) { #InventoryManager::__destruct(); //PHP will destruct this class by itself. } else { $this->Server = $MAIN->getServer(); $this->Server->getPluginManager()->registerEvents($this, $this); @mkdir($this->getDataFolder()); $this->MainConfig = new Config($this->getDataFolder() . "InventoryManager.yml", Config::YAML, array()); if(!$this->MainConfig->exists("Stats")){ $this->MainConfig->set("Stats", ['Saves:' => 0,"Reads:" => 0]); $this->Stats = $this->MainConfig->get("Stats"); }else{ $this->Stats = $this->MainConfig->get("Stats"); } $this->MainConfig->save(); $this->WatchWorld = $WatchWorld; } } Code: [21:54:00] [Server thread/CRITICAL]: pocketmine\utils\PluginException: "Plugin attempted to register robske_110\ServerCore\InventoryManager while not enabled" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 680 The class crashes with that
Oops, gonna fix this, but all you need to know is that main class calls new InventoryManager($this, "SW") on onEnable
I think PHP: class Main extends PluginBase implements Listener{public function onEnable() {$this->getServer()->getPluginManager()->registerEvents($this, $this);$this->getServer()->getPluginManager()->registerEvents(new InventoryManager($this, "SW"), $this);}} and remove the line PHP: $this->Server->getPluginManager()->registerEvents($this, $this); in InventoryManager
This line in the InventoryManager constructor PHP: $this->Server->getPluginManager()->registerEvents($this, $this); The plugin parameter should be $MAIN, not $this.
Thanks, this is one of the copy paste functions you never think about (Erm what is the plugin param [first or secound?]) Would work too, but i want InventoryManager to be completly independent.
Mind looking it up yourself? https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/plugin/PluginManager.php#L689 PHP: public function PluginManager::registerEvents(Listener, Plugin); Or use an IDE This is what happens in PhpStorm: Spoiler: Cropped Screenshots
I love you @PEMapModder #NoHomo (Do i even know your real gender lol) Especially for pointing out lines in the sources! And to the IDE: Is there an free one (Or can you get PHPStorm for free?)
I don't use NetBeans, but I heard that it has similar functions too. It is free. About free PhpStorm: https://www.jetbrains.com/student/