mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-10-05 17:57:42 +02:00
dc4d9961c1
- 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
51 lines
1.5 KiB
Java
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;
|
|
}
|
|
}
|