From f17a790d7879a41822e8e523d78b24293ffd4bd4 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 12 Aug 2012 01:12:10 +0100 Subject: [PATCH] Improve player matching in /gamemode Add extra aliases to /gamemode --- Essentials/nbproject/project.properties | 2 +- .../essentials/commands/Commandgamemode.java | 14 +++++++++++++- Essentials/src/plugin.yml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 7a5ffe7bb..a9cebbb92 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -1,5 +1,5 @@ annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false +annotation.processing.enabled.in.editor=true annotation.processing.processors.list=lombok.core.AnnotationProcessor annotation.processing.run.all.processors=false annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index 39f7d936a..5fb1a11ba 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -43,8 +43,15 @@ public class Commandgamemode extends EssentialsCommand user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName())); } - private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args) + private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args) throws NotEnoughArgumentsException { + //TODO: TL this + if (args[1].trim().length() < 2) + { + throw new NotEnoughArgumentsException("You need to specify a valid player/mode."); + } + + boolean foundUser = false; for (Player matchPlayer : server.matchPlayer(args[1])) { final User player = ess.getUser(matchPlayer); @@ -54,6 +61,11 @@ public class Commandgamemode extends EssentialsCommand } performSetMode(args[0].toLowerCase(Locale.ENGLISH), player); sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName())); + foundUser = true; + } + if (!foundUser) + { + throw new NotEnoughArgumentsException(_("playerNotFound")); } } diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 98af00ea3..813e0d774 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -118,7 +118,7 @@ commands: gamemode: description: Change player gamemode. usage: / [player] - aliases: [gm,creative,creativemode,egamemode,ecreative,ecreativemode,egm] + aliases: [gm,creative,creativemode,survival,survivalmode,adventure,adventuremode,gmc,gma,gms,egamemod,eecreative,ecreativemode,esurvival,esurvivalmode,eadventure,eadventuremode,egmc,egma,egms,egm] getpos: description: Get your current coordinates or those of a player. usage: / [player]