New permission nodes to disable any command, factions.disableCommand.<command>, along with factions.disableCommand.none node which forcibly makes none disabled (for * permission users or similar); for <command>, you must use the first command alias given in the /f help information (for example, "show" instead of "who" for that particular command)

This commit is contained in:
Brettflan 2011-07-20 16:22:54 -05:00
parent 5b73ebc456
commit 1e9c83decc
3 changed files with 134 additions and 0 deletions

View File

@ -340,6 +340,10 @@ public class Factions extends JavaPlugin {
return hasPerm(sender, "factions.worldOptions"); 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) { private static boolean hasPerm(CommandSender sender, String permNode) {
if (Factions.Permissions == null || ! (sender instanceof Player)) { if (Factions.Permissions == null || ! (sender instanceof Player)) {
return sender.isOp() || sender.hasPermission(permNode); return sender.isOp() || sender.hasPermission(permNode);

View File

@ -87,6 +87,12 @@ public class FBaseCommand {
return false; 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()) { if (parameters.size() < requiredParameters.size()) {
sendMessage("Usage: "+this.getUseageTemplate(false)); sendMessage("Usage: "+this.getUseageTemplate(false));
return false; return false;

View File

@ -26,6 +26,7 @@ permissions:
factions.lock: true factions.lock: true
factions.disband: true factions.disband: true
factions.worldOptions: true factions.worldOptions: true
factions.commandDisable.none: true
factions.participate: factions.participate:
description: Allows the player to participate in a faction description: Allows the player to participate in a faction
default: true default: true
@ -56,3 +57,126 @@ permissions:
factions.worldOptions: factions.worldOptions:
description: Can use the /f worldnoclaim and /f worldnopowerloss commands description: Can use the /f worldnoclaim and /f worldnopowerloss commands
default: op 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