diff --git a/src/com/onarandombox/MultiverseCore/MVPermissions.java b/src/com/onarandombox/MultiverseCore/MVPermissions.java index 1ac31ca3..d2e81822 100644 --- a/src/com/onarandombox/MultiverseCore/MVPermissions.java +++ b/src/com/onarandombox/MultiverseCore/MVPermissions.java @@ -45,9 +45,9 @@ public class MVPermissions { return true; } Player player = (Player) sender; - // TODO: - if (player.isOp()) { - // If Player is Op we always let them use it. + boolean opFallback = this.plugin.configMV.getBoolean("opfallback", true); + if (player.isOp() && opFallback) { + // If Player is Op we always let them use it if they have the fallback enabled! return true; } else if (MultiverseCore.Permissions != null && MultiverseCore.Permissions.has(player, node)) { // If Permissions is enabled we check against them. @@ -55,7 +55,10 @@ public class MVPermissions { } // If the Player doesn't have Permissions and isn't an Op then // we return true if OP is not required, otherwise we return false - return !isOpRequired; + // This allows us to act as a default permission guidance + + // If they have the op fallback disabled, NO commands will work without a permissions plugin. + return !isOpRequired && opFallback; } diff --git a/src/com/onarandombox/MultiverseCore/MVPluginListener.java b/src/com/onarandombox/MultiverseCore/MVPluginListener.java index 10782ce7..9f7354d5 100644 --- a/src/com/onarandombox/MultiverseCore/MVPluginListener.java +++ b/src/com/onarandombox/MultiverseCore/MVPluginListener.java @@ -28,15 +28,15 @@ public class MVPluginListener extends ServerListener { * Check to see if Permissions was just enabled, we only wan't to perform the following if GroupManager is not found. */ if (event.getPlugin().getDescription().getName().equals("Permissions")) { - MultiverseCore.Permissions = ((Permissions) plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler(); - plugin.log(Level.INFO, "- Attached to Permissions"); + MultiverseCore.Permissions = ((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler(); + this.plugin.log(Level.INFO, "- Attached to Permissions"); } - + // TODO: Use AllPay /** * Use the METHOD supplied by iConomy to register it etc... */ - if (MultiverseCore.getiConomy() == null) { - Plugin iConomy = plugin.getServer().getPluginManager().getPlugin("iConomy"); + if(event.getPlugin().getDescription().getName().equals("iConomy")) { + Plugin iConomy = this.plugin.getServer().getPluginManager().getPlugin("iConomy"); if (iConomy != null) { if (iConomy.isEnabled()) { diff --git a/src/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/com/onarandombox/MultiverseCore/MultiverseCore.java index cca0fb1a..3ac05471 100644 --- a/src/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -61,7 +61,7 @@ public class MultiverseCore extends JavaPlugin { private boolean debug; // Setup our Map for our Commands using the CommandHandler. - private CommandManager commandManager = new CommandManager(); + private CommandManager commandManager; private final String tag = "[Multiverse-Core]"; @@ -117,6 +117,8 @@ public class MultiverseCore extends JavaPlugin { this.registerEvents(); // Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP(). this.setupPermissions(); + // Setup thte command manager + this.commandManager = new CommandManager(this); // Setup iConomy. this.setupEconomy(); // Call the Function to assign all the Commands to their Class. diff --git a/src/com/onarandombox/MultiverseCore/command/CommandManager.java b/src/com/onarandombox/MultiverseCore/command/CommandManager.java index 32d7e01a..17d15700 100644 --- a/src/com/onarandombox/MultiverseCore/command/CommandManager.java +++ b/src/com/onarandombox/MultiverseCore/command/CommandManager.java @@ -21,9 +21,11 @@ import com.onarandombox.MultiverseCore.MultiverseCore; public class CommandManager { protected List commands; + private MultiverseCore plugin; - public CommandManager() { + public CommandManager(MultiverseCore plugin) { this.commands = new ArrayList(); + this.plugin = plugin; } public boolean dispatch(CommandSender sender, Command command, String label, String[] args) { @@ -46,7 +48,7 @@ public class CommandManager { } if (match != null) { - if (this.hasPermission(sender, match.getPermission(), match.isOpRequired())) { + if (this.plugin.ph.hasPermission(sender, match.getPermission(), match.isOpRequired())) { if (trimmedArgs != null) { match.execute(sender, trimmedArgs); } else { @@ -77,7 +79,7 @@ public class CommandManager { public List getCommands(CommandSender sender) { ArrayList playerCommands = new ArrayList(); for(BaseCommand c : this.commands) { - if(this.hasPermission(sender, c.permission, c.isOpRequired())) { + if(this.plugin.ph.hasPermission(sender, c.permission, c.isOpRequired())) { playerCommands.add(c); } } @@ -138,23 +140,4 @@ public class CommandManager { } return returnVal.replace("\"", ""); } - - public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) { - - if (!(sender instanceof Player)) { - return true; - } - Player player = (Player) sender; - - if (player.isOp()) { - // If Player is Op we always let them use it. - return true; - } else if (MultiverseCore.Permissions != null && MultiverseCore.Permissions.has(player, node)) { - // If Permissions is enabled we check against them. - return true; - } - // If the Player doesn't have Permissions and isn't an Op then - // we return true if OP is not required, otherwise we return false - return !isOpRequired; - } } diff --git a/src/defaults/config.yml b/src/defaults/config.yml index 60d612cd..7f87c8b7 100644 --- a/src/defaults/config.yml +++ b/src/defaults/config.yml @@ -24,4 +24,4 @@ worldnameprefix: true # people defined in ops.txt? Remember, if you use ops based permissions # the awesome Multiverse devs get to decide which commands require op! # (Which is why we highly recomend a permissions plugin! You shouldn't trust us this much...) -fallbacktoops: true \ No newline at end of file +opfallback: true \ No newline at end of file