Skip to content

Commit

Permalink
8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Exxarion committed Jul 5, 2015
1 parent 6116753 commit 6103ad3
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/WorldGM/WorldGM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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> <world>\n".TextFormat::AQUA."/wgm <include/exclude> <player>\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> <world>\n".TextFormat::AQUA."/wgm <include/exclude> <player>\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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6103ad3

Please sign in to comment.