Hey there, i have a problem with my plugin. I want to create some commands that will teleport me to other worlds, but only /worldofjobs work, the other commands are registered as command on the server, but will not teleport me. (no output at server and console) Heres the plugin.yml: Code: name: UPECoreTP main: Adversarius\Main version: 0.0.1 api: 3.0.0-ALPHA12 load: POSTWORLD author: Adversarius description: Skeleton plugin generated by PocketMine-MP DevTools website: https://github.com/pmmp/PocketMine-DevTools commands: worldofjobs: description: "Teleportiert dich in die Job Welt" worldofminer: description: "Teleportiert dich in die Miner Welt" worldofholzfaeller: description: "Teleportiert dich in die Holzfäller Welt" water: description: "Teleportiert dich in den CityBuild Water" lava: description: "Teleportiert dich in den CityBuild Lava" summer: description: "Teleportiert dich in den CityBuild Summer" fw: description: "Teleportiert dich in die Farmwelt" lobby: description: "Teleportiert dich in die Lobby" hub: description: "Teleportiert dich in die Hub" spawn: description: "Teleportiert dich zum Spawn" And here the Main.php (remember that the first Command (/worldofjobs) works!!): PHP: <?phpnamespace Adversarius;use pocketmine\plugin\PluginBase;use pocketmine\command\CommandSender;use pocketmine\command\Command;class Main extends PluginBase{ public function onEnable(){ $this->getLogger()->info("UPECore geladen"); $this->getServer()->loadLevel("Jobs"); $this->getServer()->loadLevel("Miner"); $this->getServer()->loadLevel("Holzfäller"); $this->getServer()->loadLevel("Summer"); $this->getServer()->loadLevel("FarmWelt"); $this->getServer()->loadLevel("Lava"); $this->getServer()->loadLevel("Water"); $this->getServer()->loadLevel("world"); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{ switch($command->getName()){ case "worldofjobs": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in die §eJobWelt §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("Jobs")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "worldofminer": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in die §eMinerWelt §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("Miner")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "worldofholzfaeller": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in die §eHolzfällerWelt §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("Holzfäller")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "water": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in den CityBuild §eWater §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("Water")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "lava": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in den CityBuild §eLava §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("Lava")->getSafeSpawn()); return true; default: return false; } switch($command->getname()){ case "summer": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in den CityBuild §eSummer §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("Summer")->getSafeSpawn()); return true; default: return false; } switch($cmd->getName()){ case "fw": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in die §eFarmwelt §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("FarmWelt")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "lobby": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in die §eLobby §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "hub": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest in die §eHub §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn()); return true; default: return false; } switch($command->getName()){ case "spawn": $sender->sendMessage("§8[§l§e!§r§8] §7Du wurdest zum §eSpawn §7teleportiert!"); $sender->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn()); return true; default: return false; } } public function onDisable(){ $this->getLogger()->info("Bye"); }}
First of all, I'd recommend reading on how to use switch statements: http://php.net/manual/en/control-structures.switch.php That's also why your code doesn't work, see this diagram I made with a highly sophisticated graphing program, Paint: Second, to optimize your code amount, you can set Aliases for identical commands in your plugin.yml (Because /lobby, /spawn and /hub) all teleport to the same world as it seems. Like this: Code: hub: description: "Teleportiert dich in die Hub" aliases: ["lobby", "spawn"] Then you only need to handle /hub in your code, but the same code will get executed when the player uses the aliases. Third: You can use [PHP][/PHP] for formatting of php code on here, so it displays with nice syntax highlighting.