Factions/src/com/massivecraft/factions/struct/Permission.java

110 lines
3.1 KiB
Java
Raw Normal View History

2011-10-08 18:44:47 +02:00
package com.massivecraft.factions.struct;
import org.bukkit.command.CommandSender;
2011-10-08 23:22:02 +02:00
import com.massivecraft.factions.P;
2011-10-08 18:44:47 +02:00
public enum Permission
{
PARTICIPATE("participate"),
CREATE("create"),
VIEW_ANY_POWER("viewAnyPower"),
VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"),
PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"),
CONFIG("config"),
DISBAND("disband"),
LOCK("lock"),
MANAGE_SAFE_ZONE("manageSafeZone"),
MANAGE_WAR_ZONE("manageWarZone"),
OWNERSHIP_BYPASS("ownershipBypass"),
RELOAD("reload"),
SAVE_ALL("saveall"),
SET_PEACEFUL("setPeaceful"),
SET_PERMANENT("setPermanent"),
2011-10-09 18:35:39 +02:00
COMMAND_ADMIN("command.admin"),
COMMAND_AUTOCLAIM("command.autoClaim"),
COMMAND_BALANCE("command.balance"),
COMMAND_WITHDRAW("command.withdraw"),
COMMAND_PAY("command.pay"),
2011-10-09 18:35:39 +02:00
COMMAND_BYPASS("command.bypass"),
COMMAND_CHAT("command.chat"),
COMMAND_CLAIM("command.claim"),
COMMAND_CONFIG("command.config"),
COMMAND_DEINVITE("command.deinvite"),
COMMAND_DEPOSIT("command.deposit"),
COMMAND_DESCRIPTION("command.description"),
COMMAND_DISBAND("command.disband"),
COMMAND_DISBAND_ANY("command.disband.any"),
COMMAND_HELP("command.help"),
COMMAND_HOME("command.home"),
COMMAND_INVITE("command.invite"),
COMMAND_JOIN("command.join"),
COMMAND_KICK("command.kick"),
COMMAND_KICK_ANY("command.kick.any"),
COMMAND_LEAVE("command.leave"),
COMMAND_LIST("command.list"),
COMMAND_LOCK("command.lock"),
COMMAND_MAP("command.map"),
COMMAND_MOD("command.mod"),
2011-10-09 18:35:39 +02:00
COMMAND_NO_BOOM("command.noBoom"),
COMMAND_OPEN("command.open"),
COMMAND_OWNER("command.owner"),
COMMAND_OWNERLIST("command.ownerlist"),
COMMAND_SET_PEACEFUL("command.setPeaceful"),
COMMAND_SET_PERMANENT("command.setPermanent"),
COMMAND_POWER("command.power"),
COMMAND_POWER_ANY("command.power.any"),
COMMAND_RELATION("command.relation"),
COMMAND_RELOAD("command.reload"),
COMMAND_SAVE("command.save"),
COMMAND_SETHOME("command.sethome"),
COMMAND_SETHOME_ANY("command.sethome.any"),
COMMAND_SHOW("command.show"),
COMMAND_TAG("command.tag"),
COMMAND_TITLE("command.title"),
COMMAND_UNCLAIM("command.unclaim"),
COMMAND_VERSION("command.version"),
2011-10-08 18:44:47 +02:00
;
public final String node;
Permission(final String node)
{
this.node = "factions."+node;
2011-10-08 18:44:47 +02:00
}
2011-10-08 23:22:02 +02:00
public boolean has(CommandSender sender, boolean informSenderIfNot)
{
return P.p.perm.has(sender, this.node, informSenderIfNot);
}
2011-10-08 18:44:47 +02:00
public boolean has(CommandSender sender)
2011-10-08 23:22:02 +02:00
{
return has(sender, false);
}
/*public boolean has(CommandSender sender)
2011-10-08 18:44:47 +02:00
{
//return CreativeGates.p.perm.has(sender, this.node);
}
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);
}
Player player = (Player)sender;
return Factions.Permissions.has(player, permNode);
2011-10-08 23:22:02 +02:00
}*/
2011-10-08 18:44:47 +02:00
}