From 6103ad342d4ec55d1351b46bf9a3a52e90305aad Mon Sep 17 00:00:00 2001 From: Blumieare Exxarion Date: Sun, 5 Jul 2015 12:31:21 -0400 Subject: [PATCH] 8.0 --- src/WorldGM/WorldGM.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/WorldGM/WorldGM.php b/src/WorldGM/WorldGM.php index a4d58d0..11f79a8 100644 --- a/src/WorldGM/WorldGM.php +++ b/src/WorldGM/WorldGM.php @@ -45,6 +45,13 @@ public function onDisable() { public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch ($command->getName()) { + case "s": + $sender->setGamemode(0); + return true; + case "c": + $sender->setGamemode(1); + return true; + case "wgm": switch (array_shift($args)) { case "set": @@ -69,13 +76,8 @@ public function onCommand(CommandSender $sender, Command $command, $label, array $sender->sendMessage($this->updatePlugin($sender)); return true; default: - $sender->sendMessage(TextFormat::YELLOW."-------------------\n".TextFormat::GREEN."WorldGM - Version 8.0\n".TextFormat::BLUE."Set Different gamemodes for different worlds\n".TextFormat::DARK_GREEN."Usages:\n".TextFormat::AQUA."/wgm set <0/1/2> \n".TextFormat::AQUA."/wgm \n".TextFormat::AQUA."/wgm version\n".TextFormat::AQUA."/wgm check\n".TextFormat::AQUA."/wgm gm\n".TextFormat::AQUA."/wgm update\n".TextFormat::DARK_RED."- Created by Exxarion\n".TextFormat::YELLOW."-------------------"); - return true; - case "s": - $sender->setGamemode(Survival); - case "c": - $sender->setGamemode(Creative); - + $sender->sendMessage(TextFormat::YELLOW."+-------------------+\n".TextFormat::GREEN."WorldGM - Version 8.0\n".TextFormat::BLUE."Set Different gamemodes for different worlds\n".TextFormat::DARK_GREEN."Usages:\n".TextFormat::AQUA."/wgm set <0/1/2> \n".TextFormat::AQUA."/wgm \n".TextFormat::AQUA."/wgm version\n".TextFormat::AQUA."/wgm check\n".TextFormat::AQUA."/wgm gm\n".TextFormat::AQUA."/wgm update\n".TextFormat::DARK_RED."- Created by Exxarion\n".TextFormat::YELLOW."+-------------------+"); + return true; } default: return false; @@ -113,16 +115,11 @@ public function checkPlayer($player) { $isExcluded = in_array(strtolower($player->getName()), array_map('strtolower', $this->getConfig()->get(WorldGM::CONFIG_EXCLUDED))); $worldGamemode = Utilities::getWorldGamemode($this->getConfig(), $world); - if (($gamemodeTo = Server::getGamemodeFromString($worldGamemode)) == -1) { - $this->getLogger()->warning($worldGamemode . ' is not a gamemode, until this is fixed, this plugin will use your default gamemode (Set in server.properties) instead.'); - $gamemodeTo = Server::getDefaultGamemode(); - } - - $gmNeedsChanging = $player->getGamemode() !== ($gamemodeTo); + $gmNeedsChanging = $player->getGamemode() !== ($worldGamemode); if (!$isExcluded && $gmNeedsChanging) { - $player->setGamemode($gamemodeTo); + $player->setGamemode($worldGamemode); } else { return false; }