From b633f36131d48a9702cd9a5502b4b4029fe223a6 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Fri, 1 Feb 2013 14:36:01 -0800 Subject: [PATCH] Adding proper children for the deprecated permissions, and removing extra permissions checks. --- .../commands/admin/AddlevelsCommand.java | 7 +----- .../nossr50/commands/admin/AddxpCommand.java | 4 ++-- .../commands/admin/MmoeditCommand.java | 4 ++-- .../commands/admin/SkillResetCommand.java | 5 ++-- .../nossr50/commands/admin/XprateCommand.java | 7 +++--- .../commands/player/McabilityCommand.java | 3 +-- .../database/commands/MmoupdateCommand.java | 3 +-- .../com/gmail/nossr50/util/Permissions.java | 10 ++++---- src/main/resources/plugin.yml | 24 +++++++++++++++---- 9 files changed, 37 insertions(+), 30 deletions(-) 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 643b53c30..9a3773266 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java @@ -23,11 +23,6 @@ public class AddlevelsCommand implements CommandExecutor{ switch (args.length) { case 2: - if (!Permissions.mmoedit(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - if (sender instanceof Player) { if (!SkillTools.isSkill(args[0])) { sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); @@ -55,7 +50,7 @@ public class AddlevelsCommand implements CommandExecutor{ } case 3: - if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others") && !Permissions.mmoedit(sender)) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) { sender.sendMessage(command.getPermissionMessage()); return true; } 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 25c273b9e..4f74bd744 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java @@ -27,7 +27,7 @@ public class AddxpCommand implements CommandExecutor { switch (args.length) { case 2: - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp") && !Permissions.mmoedit((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp")) { return true; } @@ -71,7 +71,7 @@ public class AddxpCommand implements CommandExecutor { return true; case 3: - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp.others") && !Permissions.mmoedit((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp.others")) { return true; } 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 7dfaaec5b..43e73bb77 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java @@ -26,7 +26,7 @@ public class MmoeditCommand implements CommandExecutor { switch (args.length) { case 2: - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit") && !Permissions.mmoedit((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit")) { return true; } @@ -62,7 +62,7 @@ public class MmoeditCommand implements CommandExecutor { return true; case 3: - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit.others") && !Permissions.mmoedit((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit.others")) { return true; } 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 bab9b88a6..739827a27 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/SkillResetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/SkillResetCommand.java @@ -13,7 +13,6 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class SkillResetCommand implements CommandExecutor { @@ -34,7 +33,7 @@ public class SkillResetCommand implements CommandExecutor { skill = SkillTools.getSkillType(args[0]); - if (CommandHelper.noCommandPermissions((Player) sender, "mcmmo.commands.skillreset." + skill.toString().toLowerCase()) && !Permissions.skillReset((Player) sender)) { + if (CommandHelper.noCommandPermissions((Player) sender, "mcmmo.commands.skillreset." + skill.toString().toLowerCase())) { return true; } @@ -72,7 +71,7 @@ public class SkillResetCommand implements CommandExecutor { skill = SkillTools.getSkillType(args[1]); - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.skillreset.others." + skill.toString().toLowerCase()) && !Permissions.skillReset((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java index b6730fadc..bba8a80e3 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; public class XprateCommand implements CommandExecutor { private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier(); @@ -21,7 +20,7 @@ public class XprateCommand implements CommandExecutor { String usage2 = LocaleLoader.getString("Commands.xprate.proper.1"); String usage3 = LocaleLoader.getString("Commands.xprate.proper.2"); - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate") && !Permissions.admin((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate")) { return true; } @@ -30,7 +29,7 @@ public class XprateCommand implements CommandExecutor { switch (args.length) { case 1: if (args[0].equalsIgnoreCase("reset")) { - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset") && !Permissions.admin((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset")) { return true; } @@ -57,7 +56,7 @@ public class XprateCommand implements CommandExecutor { case 2: if (Misc.isInt(args[0])) { - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set") && !Permissions.admin((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set")) { return true; } if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java index b58a8cbc6..28c60960c 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McabilityCommand.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class McabilityCommand implements CommandExecutor { @@ -21,7 +20,7 @@ public class McabilityCommand implements CommandExecutor { switch (args.length) { case 0: - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability") && !Permissions.mcAbility((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability")) { return true; } diff --git a/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java b/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java index 2c9709a14..7bf269cf3 100644 --- a/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java +++ b/src/main/java/com/gmail/nossr50/database/commands/MmoupdateCommand.java @@ -10,13 +10,12 @@ import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.runnables.SQLConversionTask; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class MmoupdateCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoupdate") && !Permissions.admin((Player) sender)) { + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoupdate")) { return true; } diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 51ff5b16a..68783cb11 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -48,7 +48,7 @@ public final class Permissions { } public static boolean inspectFar(Player player) { - return (hasPermission(player, "mcmmo.commands.inspect.far") || inspectDistanceBypass(player)); + return (hasPermission(player, "mcmmo.commands.inspect.far")); } /** @@ -60,7 +60,7 @@ public final class Permissions { } public static boolean inspectOffline(Player player) { - return (hasPermission(player, "mcmmo.commands.inspect.offline") || inspectOfflineBypass(player)); + return (hasPermission(player, "mcmmo.commands.inspect.offline")); } /* @@ -561,15 +561,15 @@ public final class Permissions { */ public static boolean mmoeditCommand(Player player) { - return (hasPermission(player, "mcmmo.commands.mmoedit") || mmoedit(player)); + return (hasPermission(player, "mcmmo.commands.mmoedit")); } public static boolean skillResetCommand(Player player) { - return (hasPermission(player, "mcmmo.commands.skillreset") || skillReset(player)); + return (hasPermission(player, "mcmmo.commands.skillreset")); } public static boolean mcAbilityCommand(Player player) { - return (hasPermission(player, "mcmmo.commands.mcability") || mcAbility(player)); + return (hasPermission(player, "mcmmo.commands.mcability")); } public static boolean mcgodCommand(CommandSender sender) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2819b5ef6..9148cec6e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -123,6 +123,7 @@ permissions: default: false description: Implies all mcmmo permissions. children: + mcmmo.admin: true mcmmo.bypass.all: true mcmmo.commands.all: true mcmmo.defaults: true @@ -148,7 +149,8 @@ permissions: default: false description: Implies access to everything in mcMMO children: - mcmmo.all: true + mcmmo.commands.mmoupdate: true + mcmmo.commands.xprate.all: true mcmmo.perks.*: default: false description: implies access to all mcmmo perks @@ -316,9 +318,13 @@ permissions: mcmmo.bypass.inspect.distance: default: op description: Allows user to bypass Inspect's distance requirements + children: + mcmmo.commands.inspect.far: true mcmmo.bypass.inspect.offline: default: op description: Allows user to bypass Inspect's offline player requirements + children: + mcmmo.commands.inspect.offline: true mcmmo.tools.*: description: Implies all mcmmo.tools permissions. children: @@ -335,6 +341,13 @@ permissions: mcmmo.tools.mmoedit: default: false description: Allows access to mmoedit command + children: + mcmmo.commands.addlevels: true + mcmmo.commands.addlevels.others: true + mcmmo.commands.addxp: true + mcmmo.commands.addxp.others: true + mcmmo.commands.mmoedit: true + mcmmo.commands.mmoedit.others: true mcmmo.tools.mcgod: description: Allows access to mcgod command children: @@ -716,8 +729,9 @@ permissions: mcmmo.commands.party.all: true mcmmo.commands.ptp: true mcmmo.commands.ability: - default: false description: Allows access to the mcability command + children: + mcmmo.commands.mcability: true mcmmo.commands.addlevels: description: Allows access to the addlevels command mcmmo.commands.addlevels.others: @@ -987,5 +1001,7 @@ permissions: mcmmo.skills.smelting: description: Allows access to the Smelting skill mcmmo.skillreset: - default: false - description: Allow reset of skill levels \ No newline at end of file + description: Allow reset of skill levels + children: + mcmmo.commands.skillreset.all: true + mcmmo.commands.skillreset.others.all: false \ No newline at end of file