2011-05-15 19:33:03 +02:00
|
|
|
package com.Acrobot.ChestShop;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2011-05-29 13:25:25 +02:00
|
|
|
public enum Permission {
|
2012-03-01 22:03:59 +01:00
|
|
|
SHOP_CREATION_BUY("ChestShop.shop.create.buy"),
|
|
|
|
SHOP_CREATION_SELL("ChestShop.shop.create.sell"),
|
|
|
|
|
|
|
|
SHOP_CREATION_ID("ChestShop.shop.create."),
|
|
|
|
|
2011-06-23 23:25:34 +02:00
|
|
|
BUY("ChestShop.shop.buy"),
|
2011-08-13 12:08:34 +02:00
|
|
|
BUY_ID("ChestShop.shop.buy."),
|
2012-03-01 22:03:59 +01:00
|
|
|
|
2011-08-13 12:08:34 +02:00
|
|
|
SELL_ID("ChestShop.shop.sell."),
|
2011-06-23 23:25:34 +02:00
|
|
|
SELL("ChestShop.shop.sell"),
|
2012-03-01 22:03:59 +01:00
|
|
|
|
2011-07-01 14:12:26 +02:00
|
|
|
ADMIN("ChestShop.admin"),
|
2011-12-01 14:02:58 +01:00
|
|
|
MOD("ChestShop.mod"),
|
2012-01-09 22:39:38 +01:00
|
|
|
OTHER_NAME("ChestShop.name."),
|
2012-01-25 16:32:34 +01:00
|
|
|
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) {
|
2011-07-23 21:00:47 +02:00
|
|
|
return has(player, permission.permission);
|
2011-05-29 13:25:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean has(Player player, String node) {
|
2011-12-01 14:02:58 +01:00
|
|
|
return player.hasPermission(node) || player.hasPermission(node.toLowerCase());
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
2012-03-17 15:00:25 +01:00
|
|
|
|
|
|
|
public static boolean otherName(Player p, String name) {
|
2012-05-10 16:32:25 +02:00
|
|
|
if (has(p, Permission.ADMIN)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-09 22:39:38 +01:00
|
|
|
String node = OTHER_NAME + name;
|
|
|
|
return hasPermissionSet(p, node) || hasPermissionSet(p, node.toLowerCase());
|
|
|
|
}
|
2012-03-17 15:00:25 +01:00
|
|
|
|
|
|
|
private static boolean hasPermissionSet(Player p, String perm) {
|
2012-01-09 22:39:38 +01:00
|
|
|
return p.isPermissionSet(perm) && p.hasPermission(perm);
|
|
|
|
}
|
2011-06-09 22:54:01 +02:00
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
return permission;
|
|
|
|
}
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|