Add gamemode check when game moding self.

This commit is contained in:
drtshock 2015-08-10 09:58:20 -05:00
parent 6c38b6c6fb
commit ee2018416e

View File

@ -53,9 +53,16 @@ public class Commandgamemode extends EssentialsCommand {
throw new NotEnoughArgumentsException();
}
}
if (gameMode == null) {
gameMode = user.getBase().getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getBase().getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
}
if (!canChangeToMode(user.getBase(), gameMode)) {
user.sendMessage(tl("cantGamemode", gameMode.name()));
return;
}
user.getBase().setGameMode(gameMode);
user.sendMessage(tl("gameMode", tl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
}