mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-20 07:17:34 +01:00
f1ee558e3a
- Switched from YamlConfiguration to BreezeConfiguration (from ChestShop 4) - Fixed getDouble() - Instead of checking for Admin Shops, we just pass in a new AdminShop Container - Created events for shop creation, protection checks and protection creation - Expanded string data value parsing, for example - you can use "Ocelot Monster" on the sign - Collected all external plugin wrappers in a single folder - Instead of using statics, now we use objects - Fixed enchantments for armour - Made config more readable - Added a setting for removing empty shops - Switched from System.out to logger - Also, switched from ugly file logging to Java's native one (FileHandler) - Added an option to tax transactions even when SERVER_ECONOMY_ACCOUNT is empty - Changed the Container interface
57 lines
1.4 KiB
Java
57 lines
1.4 KiB
Java
package com.Acrobot.ChestShop;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
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");
|
|
|
|
private final String permission;
|
|
|
|
Permission(String permission) {
|
|
this.permission = permission;
|
|
}
|
|
|
|
public static boolean has(Player player, Permission permission) {
|
|
return has(player, permission.permission);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
public String toString() {
|
|
return permission;
|
|
}
|
|
}
|