/src/com/fullwall/Gastronomic/Permission.java
https://bitbucket.org/jyc/gastronomic · Java · 87 lines · 75 code · 12 blank · 0 comment · 10 complexity · 632d08f30c4a26a62f245b66a277aa55 MD5 · raw file
- package com.fullwall.Gastronomic;
-
- import com.nijiko.permissions.PermissionHandler;
- import com.nijikokun.bukkit.Permissions.Permissions;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import org.bukkit.Server;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.PluginManager;
-
- public class Permission
- {
- private static Permissions permissionsPlugin;
- private static boolean permissionsEnabled = false;
-
- public static void initialize(Server server) {
- Plugin test = server.getPluginManager().getPlugin("Permissions");
- if (test != null) {
- Logger log = Logger.getLogger("Minecraft");
- permissionsPlugin = (Permissions)test;
- permissionsEnabled = true;
- log.log(Level.INFO, "[Gastronomic]: Permissions enabled.");
- } else {
- Logger log = Logger.getLogger("Minecraft");
- log.log(Level.SEVERE,
- "[Gastronomic]: Nijikokuns' Permissions plugin isn't loaded, only ops can use commands.");
- }
- }
-
- public static boolean isAdmin(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.admin");
- }
- return player.isOp();
- }
-
- public static boolean isOp(Player player) {
- return player.isOp();
- }
-
- private static boolean permission(Player player, String string) {
- return Permissions.Security.permission(player, string);
- }
-
- public static boolean enable(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.admin.enable");
- }
- return isOp(player);
- }
-
- public static boolean checkhunger(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.player.checkhunger");
- }
- return isOp(player);
- }
-
- public static boolean sethunger(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.admin.sethunger");
- }
- return isOp(player);
- }
-
- public static boolean hunger(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.disablehunger");
- }
- return false;
- }
-
- public static boolean reload(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.admin.reload");
- }
- return isOp(player);
- }
-
- public static boolean food(Player player) {
- if (permissionsEnabled) {
- return permission(player, "gastronomic.player.checkfood");
- }
- return isOp(player);
- }
- }