ChestShop-3/com/Acrobot/ChestShop/Permission.java
Acrobot dc4d9961c1 - Fancy sign formatting :D
- Fixed LWC, Lockette and Default protections
- Added restricted signs (Changed how they work)
- Added an option to use another name
- Fixed a bug where default protection was initialized too many times
- Disallowed players to place another chest near a shop chest
- Speeded up and fixed enchantment and durability in itemstacks
- Changed /iteminfo a bit
- Added /chestshop reload
- Added many default permission kits
- Fixed dye colors
- Added an option to allow towny residents place shops in their town
2012-01-09 22:39:38 +01:00

51 lines
1.5 KiB
Java

package com.Acrobot.ChestShop;
import com.nijiko.permissions.PermissionHandler;
import org.bukkit.entity.Player;
/**
* @author Acrobot
*/
public enum Permission {
SHOP_CREATION("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.");
private final String permission;
Permission(String permission) {
this.permission = permission;
}
public static PermissionHandler permissions;
public static boolean has(Player player, Permission permission) {
return has(player, permission.permission);
}
public static boolean has(Player player, String node) {
if (permissions != null) return permissions.has(player, node) || permissions.has(player, node.toLowerCase());
return player.hasPermission(node) || player.hasPermission(node.toLowerCase());
}
public static boolean otherName(Player p, String name){
String node = OTHER_NAME + name;
if (permissions != null) return permissions.has(p, node) || permissions.has(p, node.toLowerCase());
return hasPermissionSet(p, node) || hasPermissionSet(p, node.toLowerCase());
}
private static boolean hasPermissionSet(Player p, String perm){
return p.isPermissionSet(perm) && p.hasPermission(perm);
}
public String toString() {
return permission;
}
}