ChestShop-3/com/Acrobot/ChestShop/Permission.java

57 lines
1.4 KiB
Java
Raw Normal View History

2011-05-15 19:33:03 +02:00
package com.Acrobot.ChestShop;
import org.bukkit.entity.Player;
/**
* @author Acrobot
*/
2011-05-29 13:25:25 +02:00
public enum Permission {
SHOP_CREATION_BUY("ChestShop.shop.create.buy"),
SHOP_CREATION_SELL("ChestShop.shop.create.sell"),
SHOP_CREATION_ID("ChestShop.shop.create."),
BUY("ChestShop.shop.buy"),
BUY_ID("ChestShop.shop.buy."),
SELL_ID("ChestShop.shop.sell."),
SELL("ChestShop.shop.sell"),
ADMIN("ChestShop.admin"),
MOD("ChestShop.mod"),
OTHER_NAME("ChestShop.name."),
GROUP("ChestShop.group."),
NOFEE("ChestShop.nofee");
2011-05-29 13:25:25 +02:00
private final String permission;
Permission(String permission) {
this.permission = permission;
}
public static boolean has(Player player, Permission permission) {
return has(player, permission.permission);
2011-05-29 13:25:25 +02:00
}
public static boolean has(Player player, String node) {
return player.hasPermission(node) || player.hasPermission(node.toLowerCase());
}
public static boolean otherName(Player p, String name) {
if (has(p, Permission.ADMIN)) {
return false;
}
String node = OTHER_NAME + name;
return hasPermissionSet(p, node) || hasPermissionSet(p, node.toLowerCase());
}
private static boolean hasPermissionSet(Player p, String perm) {
return p.isPermissionSet(perm) && p.hasPermission(perm);
}
2011-06-09 22:54:01 +02:00
public String toString() {
return permission;
}
}