PHP: <?phpnamespace com\hawari\Gg;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\Listener;use pocketmine\event\player\PlayerRespawnEvent;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\utils\TextFormat;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents(this, this); $this->getLogger()->info(TextFormat::GREEN . "plugin works by 7awari"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ switch($command->getName()){ case "about": $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)"); break; case "ver": $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)"); break; case "version": $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)"); } }}?>
you have to register the command in your plugin.yml if you're listening to commands like that also I recommend you using an IDE with autocomplete, maybe PHPStorm etc
Code: name: Private version: 0.0.5 api: [3.0.0, 3.7.0, 3.5.0, 3.2.6, 4.0 0] author: 7awariGamer(7Wdev) main: com\hawari\Gg\Main commands: about: description: Gets the version of this server including any plugins in use usage: "/about" permission: pmmpabout ver: description: Gets the version of this server including any plugins in use usage: "/ver" permission: pmmpabout version: description: Gets the version of this server including any plugins in use usage: "/version" permission: pmmpabout permissions: pmmpabout: description: "Allow /ver to display PMMP." default: true But the server still crash when i put this plugin in plugins folder
PHP: <?phpnamespace com\hawari\Gg;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\Listener;use pocketmine\event\player\PlayerRespawnEvent;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\utils\TextFormat;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents(this, this); $this->getLogger()->info(TextFormat::GREEN . "plugin works by 7awari"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args): bool{ switch($command->getName()){ case "about": case "version": case "ver": $sender->sendMessage("§6This server is running StockPE.phar for Minecraft: Bedrock Edition v1.10.x (protocol 180)"); break; }return true;}?> use this code and next time Consider posting the error with the code
Doesn't work Log: Code: [13:20:22] [Server thread/DEBUG]: #0 (): BaseClassLoader->loadClass(string com\hawari\Gg\Main) [13:20:22] [Server thread/DEBUG]: #1 (): spl_autoload_call(string com\hawari\Gg\Main) [13:20:22] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginManager(178): class_exists(string com\hawari\Gg\Main, boolean 1) [13:20:22] [Server thread/DEBUG]: #3 src/pocketmine/plugin/PluginManager(343): pocketmine\plugin\PluginManager->loadPlugin(string /storage/emulated/0/PocketMine-MP/plugins/Private, array Array()) [13:20:22] [Server thread/DEBUG]: #4 plugins/PocketMine-DevTools.phar/src/DevTools/DevTools(49): pocketmine\plugin\PluginManager->loadPlugins(string /storage/emulated/0/PocketMine-MP/plugins/, array Array()) [13:20:22] [Server thread/DEBUG]: #5 src/pocketmine/plugin/PluginBase(123): DevTools\DevTools->onEnable() [13:20:22] [Server thread/DEBUG]: #6 src/pocketmine/plugin/PluginManager(587): pocketmine\plugin\PluginBase->setEnabled(boolean 1) [13:20:22] [Server thread/DEBUG]: #7 src/pocketmine/Server(1984): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object) [13:20:22] [Server thread/DEBUG]: #8 src/pocketmine/Server(1970): pocketmine\Server->enablePlugin(DevTools\DevTools object) [13:20:22] [Server thread/DEBUG]: #9 src/pocketmine/Server(1703): pocketmine\Server->enablePlugins(integer 0) [13:20:22] [Server thread/DEBUG]: #10 src/pocketmine/PocketMine(250): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /storage/emulated/0/PocketMine-MP/, string /storage/emulated/0/PocketMine-MP/plugins/) [13:20:22] [Server thread/DEBUG]: #11 (1): require(string phar:///storage/emulated/0/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
Code: [07:26:36] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '{'" (EXCEPTION) in "plugins/Private/src/com/hawari/Gg/Main" at line 13
That error shouldn't happen with the code you posted. Try deleting the first 13 lines and manually type them again.
can you post your current code in hastebin or something? make sure you're editing the right file, sometimes I edit the same file name but in a different directory make sure it saves too, try CTRL + S make sure you restarted your server too
I gave u all informations up ! I can't give u anything more... You can test the plugin in your server , and thx
https://drive.google.com/file/d/1DEJBxzp-6cU2cJoKCGxHO4nTfRE0p16h/view?usp=sharing I fixed your plugin. Again please consider learn how to make your code more "clean".