瀏覽代碼

Update command registration for /mcgod

GJ 12 年之前
父節點
當前提交
2e3c1d53f5

+ 10 - 0
src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java

@@ -8,6 +8,7 @@ import org.bukkit.command.PluginCommand;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.commands.admin.AddlevelsCommand;
 import com.gmail.nossr50.commands.admin.AddxpCommand;
+import com.gmail.nossr50.commands.admin.McgodCommand;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
 import com.gmail.nossr50.skills.archery.ArcheryCommand;
@@ -131,4 +132,13 @@ public final class CommandRegistrationHelper {
         command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">"));
         command.setExecutor(new AddxpCommand());
     }
+
+    public static void registerMcgodCommand() {
+        PluginCommand command = mcMMO.p.getCommand("mcgod");
+        command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
+        command.setPermission("mcmmo.commands.mcgod");
+        command.setPermissionMessage(permissionsMessage);
+        command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
+        command.setExecutor(new McgodCommand());
+    }
 }

+ 4 - 5
src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java

@@ -23,11 +23,7 @@ public class McgodCommand implements CommandExecutor {
                 return true;
             }
 
-            if (!Permissions.mcgodCommand(sender)) {
-                return true;
-            }
-
-            profile = Users.getProfile((Player) sender);
+            profile = Users.getPlayer((Player) sender).getProfile();
 
             if (profile == null) {
                 sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
@@ -43,11 +39,13 @@ public class McgodCommand implements CommandExecutor {
 
             profile.toggleGodMode();
             return true;
+
         case 1:
             if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) {
                 sender.sendMessage(command.getPermissionMessage());
                 return true;
             }
+
             McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
 
             // If the mcMMOPlayer doesn't exist, create a temporary profile and
@@ -77,6 +75,7 @@ public class McgodCommand implements CommandExecutor {
 
             profile.toggleGodMode();
             return true;
+
         default:
             return false;
         }

+ 1 - 2
src/main/java/com/gmail/nossr50/mcMMO.java

@@ -25,7 +25,6 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
 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.admin.McgodCommand;
 import com.gmail.nossr50.commands.admin.McrefreshCommand;
 import com.gmail.nossr50.commands.admin.MmoeditCommand;
 import com.gmail.nossr50.commands.admin.SkillResetCommand;
@@ -397,7 +396,7 @@ public class mcMMO extends JavaPlugin {
         getCommand("mcremove").setExecutor(new McremoveCommand());
         getCommand("mcability").setExecutor(new McabilityCommand());
         getCommand("mcc").setExecutor(new MccCommand());
-        getCommand("mcgod").setExecutor(new McgodCommand());
+        CommandRegistrationHelper.registerMcgodCommand();
         getCommand("mcmmo").setExecutor(new McmmoCommand());
         getCommand("mcrefresh").setExecutor(new McrefreshCommand());
         getCommand("mctop").setExecutor(new MctopCommand());

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

@@ -688,4 +688,5 @@ Smelting.SkillName=SMELTING
 #COMMAND DESCRIPTIONS
 Commands.Description.addlevels=Add mcMMO levels to a user
 Commands.Description.addxp=Add mcMMO XP to a user
+Commands.Description.mcgod=Toggles mcMMO god-mode on/off
 Commands.Description.Skill=Detailed mcMMO skill info for {0}