2011-05-15 19:33:03 +02:00
|
|
|
package com.Acrobot.ChestShop;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
|
|
|
import com.nijiko.permissions.PermissionHandler;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2011-05-29 13:25:25 +02:00
|
|
|
public enum Permission {
|
2011-06-09 22:54:01 +02:00
|
|
|
SHOP_CREATION("ChestShop.shop.create"),
|
|
|
|
EXCLUDE_ITEM("ChestShop.shop.exclude"),
|
|
|
|
ADMIN("ChestShop.admin");
|
2011-05-29 13:25:25 +02:00
|
|
|
|
|
|
|
private final String permission;
|
|
|
|
|
|
|
|
Permission(String permission) {
|
|
|
|
this.permission = permission;
|
|
|
|
}
|
|
|
|
|
2011-05-15 18:16:25 +02:00
|
|
|
public static PermissionHandler permissions;
|
|
|
|
|
2011-05-29 13:25:25 +02:00
|
|
|
public static boolean has(Player player, Permission permission) {
|
|
|
|
String node = permission.permission;
|
|
|
|
return has(player, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean has(Player player, String node) {
|
2011-05-15 18:16:25 +02:00
|
|
|
if (permissions != null) {
|
2011-05-29 13:25:25 +02:00
|
|
|
return permissions.has(player, node);
|
2011-05-15 18:16:25 +02:00
|
|
|
} else {
|
2011-05-29 13:25:25 +02:00
|
|
|
return !node.contains("exclude") && (!node.contains("admin") || player.isOp());
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
}
|
2011-06-09 22:54:01 +02:00
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
return permission;
|
|
|
|
}
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|