From f6aca88b36e168b7301c65e072f4df17d921f142 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 5 Feb 2013 08:36:08 -0500 Subject: [PATCH] Change /mcmmo to use Bukkit CommandAPI. Addresses #628 --- .../commands/CommandRegistrationHelper.java | 14 +++++++ .../nossr50/commands/player/McmmoCommand.java | 40 +++++++++---------- src/main/java/com/gmail/nossr50/mcMMO.java | 3 +- .../resources/locale/locale_en_US.properties | 2 + src/main/resources/plugin.yml | 1 - 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 813326e44..9f988f9d9 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -15,6 +15,7 @@ import com.gmail.nossr50.commands.admin.SkillresetCommand; import com.gmail.nossr50.commands.admin.XprateCommand; import com.gmail.nossr50.commands.player.InspectCommand; import com.gmail.nossr50.commands.player.McabilityCommand; +import com.gmail.nossr50.commands.player.McmmoCommand; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand; import com.gmail.nossr50.skills.archery.ArcheryCommand; @@ -203,4 +204,17 @@ public final class CommandRegistrationHelper { command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcability", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); command.setExecutor(new McabilityCommand()); } + + public static void registerMcmmoCommand() { + List aliasList = new ArrayList(); + aliasList.add("mcinfo"); + + PluginCommand command = mcMMO.p.getCommand("mcmmo"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo")); + command.setPermission("mcmmo.commands.mcmmo"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "?")); + command.setExecutor(new McmmoCommand()); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java index 34458729f..8adcd46c8 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java @@ -11,32 +11,32 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Anniversary; -import com.gmail.nossr50.util.Permissions; public class McmmoCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!Permissions.hasPermission(sender, "mcmmo.commands.mcmmo")) { + + if (args.length == 0 || (args.length == 1 && args[0].equals("?"))) { + String description = LocaleLoader.getString("mcMMO.Description"); + String[] mcSplit = description.split(","); + sender.sendMessage(mcSplit); + + if (Config.getInstance().getDonateMessageEnabled()) { + if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) { + SpoutPlayer spoutPlayer = (SpoutPlayer) sender; + spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND); + } + + sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); + sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal"); + } + + sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); + + Anniversary.anniversaryCheck(sender); return true; } - String description = LocaleLoader.getString("mcMMO.Description"); - String[] mcSplit = description.split(","); - sender.sendMessage(mcSplit); - - if (Config.getInstance().getDonateMessageEnabled()) { - if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) { - SpoutPlayer spoutPlayer = (SpoutPlayer) sender; - - spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND); - } - - sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); - sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal"); - } - sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); - - Anniversary.anniversaryCheck(sender); - return true; + return false; } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 3c76d999b..d5e2f2645 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -26,7 +26,6 @@ import com.gmail.nossr50.chat.commands.ACommand; import com.gmail.nossr50.chat.commands.PCommand; import com.gmail.nossr50.commands.CommandRegistrationHelper; import com.gmail.nossr50.commands.player.MccCommand; -import com.gmail.nossr50.commands.player.McmmoCommand; import com.gmail.nossr50.commands.player.McrankCommand; import com.gmail.nossr50.commands.player.McstatsCommand; import com.gmail.nossr50.commands.player.MctopCommand; @@ -444,7 +443,7 @@ public class mcMMO extends JavaPlugin { CommandRegistrationHelper.registerMcabilityCommand(); getCommand("mcc").setExecutor(new MccCommand()); CommandRegistrationHelper.registerMcgodCommand(); - getCommand("mcmmo").setExecutor(new McmmoCommand()); + CommandRegistrationHelper.registerMcmmoCommand(); CommandRegistrationHelper.registerMcrefreshCommand(); getCommand("mctop").setExecutor(new MctopCommand()); getCommand("mcrank").setExecutor(new McrankCommand()); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index c4fcaa5ff..f17b267ab 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -488,6 +488,7 @@ Commands.SkillInfo=/ [[RED]]- View detailed information about a skill Commands.Stats.Self=YOUR STATS Commands.Stats=[[RED]]- View your mcMMO stats Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click +Commands.Usage.0=[[RED]]Proper usage is /{0} Commands.Usage.1=[[RED]]Proper usage is /{0} {1} Commands.Usage.2=[[RED]]Proper usage is /{0} {1} {2} Commands.Usage.3=[[RED]]Proper usage is /{0} {1} {2} {3} @@ -693,6 +694,7 @@ Commands.Description.addxp=Add mcMMO XP to a user Commands.Description.inspect=View detailed mcMMO info on another player Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off Commands.Description.mcgod=Toggle mcMMO god-mode on/off +Commands.Description.mcmmo=Show a brief description of mcMMO Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO Commands.Description.mmoedit=Edit mcMMO levels for a user Commands.Description.Skill=Display detailed mcMMO skill info for {0} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0afbaf266..f87bed2a5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -32,7 +32,6 @@ commands: aliases: [] description: Lists mcMMO commands mcmmo: - aliases: [] description: Shows a brief mod description mctop: aliases: []