PHP: namespace AdminFun\commands; use pocketmine\plugin\PluginBase;use pocketmine\command\CommandExecutor;use AdminFun\AdminFun;abstract class BaseCommand extends PluginBase implements CommandExecutor{ public $plugin; public function __construct(AdminFun $plugin){ $this->plugin = $plugin; } public final function getPlugin(){ return $this->plugin; } Help me with this code That caused server crash
Replace PluginBase with PluginCommand but make sure to call the parent constructor, too. (On a side note, this also makes PHP: $this->plugin = $plugin; redundant, since you could just use PHP: $this->getPlugin() to access your plugin object)
Your class should look more or less like this: PHP: namespace AdminFun\commands; use pocketmine\command\CommandExecutor;use pocketmine\command\PluginCommand;abstract class BaseCommand extends PluginCommand implements CommandExecutor{} That might seem too empty, but that's totally fine. Look at this example command extending your base command: PHP: namespace AdminFun\commands;use AdminFun\AdminFun;class ExampleCommand extends BaseCommand { public function __construct(AdminFun $plugin){ parent::__construct("example", $plugin); } // Inside this class, you can now use $this->getPlugin()} Here's the origin of ExampleCommand->getPlugin()