From 11e1dc7ec81ee153b0bb0cae3ea3f6e3f05e3534 Mon Sep 17 00:00:00 2001 From: TheYeti Date: Mon, 6 Feb 2012 11:24:33 -0800 Subject: [PATCH] Okay, lets fix everything that depended on Permissions --- .../gmail/nossr50/commands/general/AddxpCommand.java | 9 ++++++--- .../gmail/nossr50/commands/general/MmoeditCommand.java | 2 +- .../gmail/nossr50/commands/general/StatsCommand.java | 3 +-- .../gmail/nossr50/commands/mc/McabilityCommand.java | 9 ++++++--- .../com/gmail/nossr50/commands/mc/McgodCommand.java | 10 +++++----- .../gmail/nossr50/commands/spout/XplockCommand.java | 4 ++-- src/main/java/com/gmail/nossr50/mcPermissions.java | 8 +++----- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java index 398ebbc72..5bc5e278c 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java @@ -23,7 +23,12 @@ public class AddxpCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!mcPermissions.permissionsEnabled) { + Player player = null; + if (sender instanceof Player) { + player = (Player) sender; + } + + if (player != null && !mcPermissions.getInstance().mmoedit(player)) { sender.sendMessage("This command requires permissions."); return true; } @@ -55,8 +60,6 @@ public class AddxpCommand implements CommandExecutor { return true; } - Player player = (Player) sender; - if (!mcPermissions.getInstance().mmoedit(player)) { player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java index 336c1a8a1..39a8eb4cd 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java @@ -24,7 +24,7 @@ public class MmoeditCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!mcPermissions.permissionsEnabled) { + if (!mcPermissions.getInstance().mmoedit((Player) sender)) { sender.sendMessage("This command requires permissions."); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java index 9da733969..76ffc9002 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java @@ -33,8 +33,7 @@ public class StatsCommand implements CommandExecutor { player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats")); - if (mcPermissions.getEnabled()) - player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote")); + player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote")); ChatColor header = ChatColor.GOLD; diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java index 75ddca13d..a109883ec 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; -import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.mcLocale; @@ -14,7 +13,12 @@ import com.gmail.nossr50.locale.mcLocale; public class McabilityCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!mcPermissions.permissionsEnabled) { + Player player = null; + if (sender instanceof Player) { + player = (Player) sender; + } + + if (player != null && player.hasPermission("mcmmo.commands.ability")) { sender.sendMessage("This command requires permissions."); return true; } @@ -29,7 +33,6 @@ public class McabilityCommand implements CommandExecutor { return true; } - Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); if (PP.getAbilityUse()) { diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McgodCommand.java index 135075547..ff980ea6d 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McgodCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McgodCommand.java @@ -28,12 +28,12 @@ public class McgodCommand implements CommandExecutor { Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); - if (mcPermissions.permissionsEnabled) { - if (!mcPermissions.getInstance().mcgod(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + if (!mcPermissions.getInstance().mcgod(player)) { + player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); + return true; + } + if (mcPermissions.getInstance().mcgod(player)) { if (PP.getGodMode()) { player.sendMessage(mcLocale.getString("mcPlayerListener.GodModeDisabled")); PP.toggleGodMode(); diff --git a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java index 8d0d1ee95..d81ae7cb8 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java @@ -31,7 +31,7 @@ public class XplockCommand implements CommandExecutor { Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); - if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { + if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { if (PP.getXpBarLocked()) { PP.setSkillLock(Skills.getSkillType(args[0])); player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) })); @@ -52,7 +52,7 @@ public class XplockCommand implements CommandExecutor { } } else if (args.length >= 1 && !Skills.isSkill(args[0])) { player.sendMessage("Commands.xplock.invalid"); - } else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { + } else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); return true; } diff --git a/src/main/java/com/gmail/nossr50/mcPermissions.java b/src/main/java/com/gmail/nossr50/mcPermissions.java index 7c89c7375..b438f1f50 100644 --- a/src/main/java/com/gmail/nossr50/mcPermissions.java +++ b/src/main/java/com/gmail/nossr50/mcPermissions.java @@ -24,11 +24,9 @@ import org.bukkit.entity.Player; public class mcPermissions { private static volatile mcPermissions instance; - - - public static void initialize(Server server) - { - Logger log = Logger.getLogger("Minecraft"); + + public boolean permission(Player player, String perm) { + return player.hasPermission(perm); } public boolean admin(Player player){