summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
index 85aeaa673..5b9b854cb 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
@@ -19,12 +19,22 @@ public class Commandgamemode extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
- if (args.length < 2)
+ GameMode gameMode;
+ if (args.length == 0)
{
throw new NotEnoughArgumentsException();
}
- GameMode gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
- gamemodeOtherPlayers(server, sender, gameMode, args[1]);
+ else if (args.length == 1)
+ {
+ gameMode = matchGameMode(commandLabel);
+ gamemodeOtherPlayers(server, sender, gameMode, args[0]);
+ }
+ else if (args.length == 2)
+ {
+ gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
+ gamemodeOtherPlayers(server, sender, gameMode, args[1]);
+ }
+
}
@Override
@@ -43,16 +53,23 @@ public class Commandgamemode extends EssentialsCommand
}
else
{
- try {
+ try
+ {
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
}
- catch (NotEnoughArgumentsException e) {
- gameMode = matchGameMode(commandLabel);
- gamemodeOtherPlayers(server, user, gameMode, args[0]);
- return;
+ catch (NotEnoughArgumentsException e)
+ {
+ if (user.isAuthorized("essentials.gamemode.others"))
+ {
+ gameMode = matchGameMode(commandLabel);
+ gamemodeOtherPlayers(server, user, gameMode, args[0]);
+ return;
+ }
+ throw new NotEnoughArgumentsException();
}
}
- if (gameMode == null) {
+ if (gameMode == null)
+ {
gameMode = user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
}
user.setGameMode(gameMode);
@@ -104,11 +121,12 @@ public class Commandgamemode extends EssentialsCommand
mode = GameMode.ADVENTURE;
}
else if (modeString.equalsIgnoreCase("gmt") || modeString.equalsIgnoreCase("egmt")
- || modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
+ || modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
{
mode = null;
}
- else {
+ else
+ {
throw new NotEnoughArgumentsException();
}
return mode;