From 1e9c83deccccac4535bd5fb8d7a33c6eab502f01 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Wed, 20 Jul 2011 16:22:54 -0500 Subject: [PATCH] New permission nodes to disable any command, factions.disableCommand., along with factions.disableCommand.none node which forcibly makes none disabled (for * permission users or similar); for , you must use the first command alias given in the /f help information (for example, "show" instead of "who" for that particular command) --- src/com/massivecraft/factions/Factions.java | 4 + .../factions/commands/FBaseCommand.java | 6 + src/plugin.yml | 124 ++++++++++++++++++ 3 files changed, 134 insertions(+) diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 06dc81f6..567df3a2 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -340,6 +340,10 @@ public class Factions extends JavaPlugin { return hasPerm(sender, "factions.worldOptions"); } + public static boolean isCommandDisabled(CommandSender sender, String command) { + return (hasPerm(sender, "factions.commandDisable."+command) && !hasPerm(sender, "factions.commandDisable.none")); + } + private static boolean hasPerm(CommandSender sender, String permNode) { if (Factions.Permissions == null || ! (sender instanceof Player)) { return sender.isOp() || sender.hasPermission(permNode); diff --git a/src/com/massivecraft/factions/commands/FBaseCommand.java b/src/com/massivecraft/factions/commands/FBaseCommand.java index 26217c76..1bd3190c 100644 --- a/src/com/massivecraft/factions/commands/FBaseCommand.java +++ b/src/com/massivecraft/factions/commands/FBaseCommand.java @@ -87,6 +87,12 @@ public class FBaseCommand { return false; } + // make sure player doesn't have their access to the command revoked + if (Factions.isCommandDisabled(sender, aliases.get(0))) { + sendMessage("You lack the permissions to "+this.helpDescription.toLowerCase()+"."); + return false; + } + if (parameters.size() < requiredParameters.size()) { sendMessage("Usage: "+this.getUseageTemplate(false)); return false; diff --git a/src/plugin.yml b/src/plugin.yml index 075c30c7..bf67b607 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -26,6 +26,7 @@ permissions: factions.lock: true factions.disband: true factions.worldOptions: true + factions.commandDisable.none: true factions.participate: description: Allows the player to participate in a faction default: true @@ -56,3 +57,126 @@ permissions: factions.worldOptions: description: Can use the /f worldnoclaim and /f worldnopowerloss commands default: op + factions.commandDisable.none: + description: no commands disabled (ignore all other commandDisable permissions) + default: op + factions.commandDisable.admin: + description: admin command disabled + default: false + factions.commandDisable.autoclaim: + description: autoclaim command disabled + default: false + factions.commandDisable.autosafe: + description: autosafe command disabled + default: false + factions.commandDisable.autowar: + description: autowar command disabled + default: false + factions.commandDisable.bypass: + description: bypass command disabled + default: false + factions.commandDisable.chat: + description: chat command disabled + default: false + factions.commandDisable.claim: + description: claim command disabled + default: false + factions.commandDisable.create: + description: create command disabled + default: false + factions.commandDisable.deinvite: + description: deinvite command disabled + default: false + factions.commandDisable.desc: + description: desc command disabled + default: false + factions.commandDisable.disband: + description: disband command disabled + default: false + factions.commandDisable.help: + description: help command disabled + default: false + factions.commandDisable.home: + description: home command disabled + default: false + factions.commandDisable.invite: + description: invite command disabled + default: false + factions.commandDisable.join: + description: join command disabled + default: false + factions.commandDisable.kick: + description: kick command disabled + default: false + factions.commandDisable.leave: + description: leave command disabled + default: false + factions.commandDisable.list: + description: list command disabled + default: false + factions.commandDisable.lock: + description: lock command disabled + default: false + factions.commandDisable.map: + description: map command disabled + default: false + factions.commandDisable.mod: + description: mod command disabled + default: false + factions.commandDisable.open: + description: open command disabled + default: false + factions.commandDisable.ally: + description: ally command disabled + default: false + factions.commandDisable.enemy: + description: enemy command disabled + default: false + factions.commandDisable.neutral: + description: neutral command disabled + default: false + factions.commandDisable.reload: + description: reload command disabled + default: false + factions.commandDisable.safeclaim: + description: safeclaim command disabled + default: false + factions.commandDisable.safeunclaimall: + description: safeunclaimall command disabled + default: false + factions.commandDisable.saveall: + description: saveall command disabled + default: false + factions.commandDisable.sethome: + description: sethome command disabled + default: false + factions.commandDisable.show: + description: show command disabled + default: false + factions.commandDisable.tag: + description: tag command disabled + default: false + factions.commandDisable.title: + description: title command disabled + default: false + factions.commandDisable.unclaim: + description: unclaim command disabled + default: false + factions.commandDisable.unclaimall: + description: unclaimall command disabled + default: false + factions.commandDisable.version: + description: version command disabled + default: false + factions.commandDisable.warclaim: + description: warclaim command disabled + default: false + factions.commandDisable.warunclaimall: + description: warunclaimall command disabled + default: false + factions.commandDisable.worldnoclaim: + description: worldnoclaim command disabled + default: false + factions.commandDisable.worldnopowerloss: + description: worldnopowerloss command disabled + default: false