What is wrong with the following code... I'm learning plugin development and this is me code PHP: <?phpnamespace yansoo\myplugin;use pocketmine\plugin\PluginBase;class Main extends PluginBase{ public function onLoad(){ //When plugin loads $this->getLogger()->info("Plugin Loading"); //send message to console. } public function onEnable(){ //when plugin enables $this->getLogger()->info("Enabled Plugin"); } public function onDisable(){//when plugin disables $this->getLogger()->info("Plugin Disabled"); }} public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $commandName = $command->getName(); if($commandName === "info"){ $sender->sendMessage("Welcome to (Servername) Gamemodes and stuff here"); return true; } return false; }
Let me show you something... PHP: package mainimport ( "fmt" "net" "os" "log")func main() { target := "164.132.137.194:25565" conn, error := net.Dial("tcp", target) if(error != nil) { log.Fatal(error) os.Exit(1) } fmt.Println("Connected!") data := "\xfe" fmt.Fprint(conn, data) fmt.Println("Sent " + data + " to " + target) line := make([]byte, 1024) for n, error := conn.Read(line); len(line) > 0; n++ { if(error != nil) { log.Fatal(error) os.Exit(3) } fmt.Println("Response:", string(line[:n])) }} Can anyone tell me why this doesn't work if I just say it doesn't?
[Server thread/CRITICAL]: ParseError: "syntax error, unexpected 'public' (T_PUBLIC), expecting end of file" (EXCEPTION) in "/My Plugin/src/yansoo/myplugin/MyPlugin" at line 26 PHP: <?phpnamespace yansoo\myplugin;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\ComamndSender;class MyPlugin extends PluginBase{ public function onLoad(){ //When plugin loads $this->getLogger()->info("Plugin Loading"); //send message to console. } public function onEnable(){ //when plugin enables $this->getLogger()->info("Enabled Plugin"); } public function onDisable(){//when plugin disables $this->getLogger()->info("Plugin Disabled"); }} public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $commandName = $command->getName(); if($commandName === "info"){ $sender->sendMessage("Welcome to (Servername) Gamemodes and stuff here"); return true; } return false; }
:/ broke my server Code: <?php namespace yansoo\myplugin; use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\command\ComamndSender; class MyPlugin extends PluginBase{ public function onLoad(){ //When plugin loads $this->getLogger()->info("Plugin Loading"); //send message to console. } public function onEnable(){ //when plugin enables $this->getLogger()->info("Enabled Plugin"); } public function onDisable(){ //when plugin disables $this->getLogger()->info("Plugin Disabled"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $commandName = $command->getName(); if($commandName === "info"){ $sender->sendMessage("Welcome to (Servername) Gamemodes and stuff here"); return true; } return false; } I moved the plugin from the folder and it still says bin/php/php.exe exit:127
ok sooooo this??? PHP: <?phpnamespace yansoo\myplugin;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\ComamndSender;class MyPlugin extends PluginBase{ public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $commandName = $command->getName(); if($commandName === "info"){ $sender->sendMessage("Welcome to (Servername) Gamemodes and stuff here"); return true; } return false; } public function onLoad(){ //When plugin loads $this->getLogger()->info("Plugin Loading"); //send message to console. } public function onEnable(){ //when plugin enables $this->getLogger()->info("Enabled Plugin"); } public function onDisable(){//when plugin disables $this->getLogger()->info("Plugin Disabled"); }
No just take the entire function on command, including function onCommand right up to the lady curly bracket for thady function... And move it to directly after any of the others
Code: PHP: <?php namespace yansoo\myplugin; use pocketmine\plugin\PluginBase; class Main extends PluginBase{ public function onLoad(){ //When plugin loads $this->getLogger()->info("Plugin Loading"); //send message to console. } public function onEnable(){ //when plugin enables $this->getLogger()->info("Enabled Plugin"); } public function onDisable(){ //when plugin disables $this->getLogger()->info("Plugin Disabled"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ $commandName = $command->getName(); if($commandName === "info"){ $sender->sendMessage("Welcome to (Servername) Gamemodes and stuff here"); return true; } return false; } }
Fatal error: Declaration of yansoo\myplugin\Main::0nCommand(yansoo\myplugin\CommandSender $sender, yansoo\myplugin\Command $command, $label, array $args) must be compatible with pocketmine\command\CommandExecutor::0nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args) in C:\Users\Yan\Desktop\My Server - Copy\plugins\My Plugin\src\yansoo\myplugin\MyPlugin.php on line 32