I have one made one and now I think because of changes of Api ant etc it won't work I've reaserched alot Spoiler PHP: <?phpnamespace Mega\Sys;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\PluginCommand;class Ver extends PluginCommand { /** @var Main $plugin */ private $plugins; public function __construct(Main $plugins){ parent::__construct("SysVer", "Display Ver", null, ["Sys"]); $this->plugins = $plugins; $this->setPermission("mega.sys.ver"); } public function execute(CommandSender $sender, $currentAlias, array $args){ // will be done by running the command foreach($this->plugin->getServer()->getOnlinePlayers() as $player){ $player->sendMessage("1.2.3 pmmp api.. \n MegaSys Ver 1.5 alpha"); } } public function getPlugins(): BaseCommand{return $this->plugins;}}
PHP: public function getPlugins(): BaseCommand{ return $this->plugins;} What even is that. Your PHPDoc says it's an instance of Main, yet you're returning BaseCommand. But did you register the command to the command map?
ParseError: "syntax error, unexpected 'class' (T_CLASS), expecting ',' or ';'" (EXCEPTION) in "PluginName/src/Mega/Sys/Ver" at line 9
PHP: <?phpnamespace Mega\Sys;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\PluginCommand;use pocketmine\command\PluginIdentifiableCommand;class Ver extends Command implements \pocketmine\command\PluginIdentifiableCommand { /** @var Main $plugin */ private $plugin; public function __construct(Main $plugin){ parent::__construct("sysver", "Display Ver", null, ["sys"]); $this->plugin = $plugin; $this->setPermission("mega.sys.ver"); } public function execute(CommandSender $sender, $currentAlias, array $args){ // will be done by running the command foreach($this->plugin->getServer()->getOnlinePlayers() as $player){ $player->sendMessage("1.2.3 pmmp api.. \n MegaSys Ver 1.5 alpha"); } } public function getPlugin(): BaseCommand{return $this->plugin;}}
PluginIdentifiableCommand::getPlugin() should return an instance of Plugin. Why are you returning it as BaseCommand when you aren't using it. I smell copy and pasted code without knowledge of how it works, so here let me give you a little insight. Make sure you are providing an instance of Main when constructing Ver. This is what your command class should look like: PHP: <?phpnamespace Mega\Sys;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\PluginCommand;use pocketmine\command\PluginIdentifiableCommand;class Ver extends Command implements PluginIdentifiableCommand { /** @var Main $plugin */ private $plugin; public function __construct(Main $plugin) { parent::__construct("sysver", "Display Ver", null, ["sys"]); $this->plugin = $plugin; $this->setPermission("mega.sys.ver"); } public function execute(CommandSender $sender, $currentAlias, array $args){ // will be done by running the command foreach($this->getPlugin()->getServer()->getOnlinePlayers() as $player){ $player->sendMessage("1.2.3 pmmp api.. \n MegaSys Ver 1.5 alpha"); } } public function getPlugin(): Plugin { return $this->plugin; }} Here's what your registration should look like if you are registering from your class that extends PluginBase(I'm 99.9% sure that it's your Main class): PHP: $this->getServer()->getCommandMap()->register("exampleFallbackPrefix", new Ver($this));