浏览代码

Change /mcmmo to use Bukkit CommandAPI. Addresses #628

GJ 12 年之前
父节点
当前提交
f6aca88b36

+ 14 - 0
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<String> aliasList = new ArrayList<String>();
+        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());
+    }
 }

+ 16 - 16
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")) {
-            return true;
-        }
 
-        String description = LocaleLoader.getString("mcMMO.Description");
-        String[] mcSplit = description.split(",");
-        sender.sendMessage(mcSplit);
+        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;
+            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);
+                }
 
-                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.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;
         }
-        sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
 
-        Anniversary.anniversaryCheck(sender);
-        return true;
+        return false;
     }
 }

+ 1 - 2
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());

+ 2 - 0
src/main/resources/locale/locale_en_US.properties

@@ -488,6 +488,7 @@ Commands.SkillInfo=/<skill> [[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}

+ 0 - 1
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: []