From 717a2584305fd139cf4ca51b8a592652a599bcdc Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Feb 2013 15:10:07 -0500 Subject: [PATCH] Added the other permissions nodes. Addresses #628 --- .../commands/CommandRegistrationHelper.java | 12 ++++++------ .../nossr50/commands/admin/AddlevelsCommand.java | 5 +++++ .../gmail/nossr50/commands/admin/AddxpCommand.java | 5 +++++ .../gmail/nossr50/commands/admin/McgodCommand.java | 5 +++++ .../nossr50/commands/admin/McrefreshCommand.java | 6 ++++++ .../nossr50/commands/admin/MmoeditCommand.java | 5 +++++ .../nossr50/commands/admin/SkillresetCommand.java | 14 ++++++++++++-- 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index be310e10d..26b7cc1d2 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -119,7 +119,7 @@ public final class CommandRegistrationHelper { public static void registerAddlevelsCommand() { PluginCommand command = mcMMO.p.getCommand("addlevels"); command.setDescription(LocaleLoader.getString("Commands.Description.addlevels")); - command.setPermission("mcmmo.commands.addlevels"); + command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); command.setExecutor(new AddlevelsCommand()); @@ -128,7 +128,7 @@ public final class CommandRegistrationHelper { public static void registerAddxpCommand() { PluginCommand command = mcMMO.p.getCommand("addxp"); command.setDescription(LocaleLoader.getString("Commands.Description.addxp")); - command.setPermission("mcmmo.commands.addxp"); + command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others"); command.setPermissionMessage(permissionsMessage); 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()); @@ -137,7 +137,7 @@ public final class CommandRegistrationHelper { public static void registerMcgodCommand() { PluginCommand command = mcMMO.p.getCommand("mcgod"); command.setDescription(LocaleLoader.getString("Commands.Description.mcgod")); - command.setPermission("mcmmo.commands.mcgod"); + command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); command.setExecutor(new McgodCommand()); @@ -146,7 +146,7 @@ public final class CommandRegistrationHelper { public static void registerMcrefreshCommand() { PluginCommand command = mcMMO.p.getCommand("mcrefresh"); command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); - command.setPermission("mcmmo.commands.mcrefresh"); + command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); command.setExecutor(new McrefreshCommand()); @@ -155,7 +155,7 @@ public final class CommandRegistrationHelper { public static void registerMmoeditCommand() { PluginCommand command = mcMMO.p.getCommand("mmoedit"); command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit")); - command.setPermission("mcmmo.commands.mmoedit"); + command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); command.setExecutor(new MmoeditCommand()); @@ -164,7 +164,7 @@ public final class CommandRegistrationHelper { public static void registerSkillresetCommand() { PluginCommand command = mcMMO.p.getCommand("skillreset"); command.setDescription(LocaleLoader.getString("Commands.Description.skillreset")); - command.setPermission("mcmmo.commands.skillreset"); + command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">")); command.setExecutor(new SkillresetCommand()); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java index 505489271..5a989c156 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java @@ -23,6 +23,11 @@ public class AddlevelsCommand implements CommandExecutor{ switch (args.length) { case 2: + if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (!(sender instanceof Player)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java index c2144703d..4f816a4f7 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java @@ -24,6 +24,11 @@ public class AddxpCommand implements CommandExecutor { switch (args.length) { case 2: + if (!Permissions.hasPermission(sender, "mcmmo.commands.addxp")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (!(sender instanceof Player)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java index 3a493c29f..62c32336b 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/McgodCommand.java @@ -18,6 +18,11 @@ public class McgodCommand implements CommandExecutor { switch (args.length) { case 0: + if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (!(sender instanceof Player)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java index a6abb1c70..841ccb4a5 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/McrefreshCommand.java @@ -18,6 +18,11 @@ public class McrefreshCommand implements CommandExecutor { switch (args.length) { case 0: + if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (!(sender instanceof Player)) { return false; } @@ -29,6 +34,7 @@ public class McrefreshCommand implements CommandExecutor { case 1: if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh.others")) { sender.sendMessage(command.getPermissionMessage()); + return true; } McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java index a745c334d..d881aefa7 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java @@ -23,6 +23,11 @@ public class MmoeditCommand implements CommandExecutor { switch (args.length) { case 2: + if (!Permissions.hasPermission(sender, "mcmmo.commands.mmoedit")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (!(sender instanceof Player)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java index ccfe440da..12678982d 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java @@ -22,6 +22,11 @@ public class SkillresetCommand implements CommandExecutor { switch (args.length) { case 1: + if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (!(sender instanceof Player)) { return false; } @@ -74,6 +79,11 @@ public class SkillresetCommand implements CommandExecutor { return true; case 2: + if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + if (args[1].equalsIgnoreCase("all")) { allSkills = true; } @@ -88,14 +98,14 @@ public class SkillresetCommand implements CommandExecutor { continue; } - if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others." + args[1].toLowerCase())) { sender.sendMessage(command.getPermissionMessage()); return true; } } } else { - if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[1].toLowerCase())) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others." + args[1].toLowerCase())) { sender.sendMessage(command.getPermissionMessage()); return true; }