/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

  1. package com.fullwall.Gastronomic;
  2. import com.nijiko.permissions.PermissionHandler;
  3. import com.nijikokun.bukkit.Permissions.Permissions;
  4. import java.util.logging.Level;
  5. import java.util.logging.Logger;
  6. import org.bukkit.Server;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.Plugin;
  9. import org.bukkit.plugin.PluginManager;
  10. public class Permission
  11. {
  12. private static Permissions permissionsPlugin;
  13. private static boolean permissionsEnabled = false;
  14. public static void initialize(Server server) {
  15. Plugin test = server.getPluginManager().getPlugin("Permissions");
  16. if (test != null) {
  17. Logger log = Logger.getLogger("Minecraft");
  18. permissionsPlugin = (Permissions)test;
  19. permissionsEnabled = true;
  20. log.log(Level.INFO, "[Gastronomic]: Permissions enabled.");
  21. } else {
  22. Logger log = Logger.getLogger("Minecraft");
  23. log.log(Level.SEVERE,
  24. "[Gastronomic]: Nijikokuns' Permissions plugin isn't loaded, only ops can use commands.");
  25. }
  26. }
  27. public static boolean isAdmin(Player player) {
  28. if (permissionsEnabled) {
  29. return permission(player, "gastronomic.admin");
  30. }
  31. return player.isOp();
  32. }
  33. public static boolean isOp(Player player) {
  34. return player.isOp();
  35. }
  36. private static boolean permission(Player player, String string) {
  37. return Permissions.Security.permission(player, string);
  38. }
  39. public static boolean enable(Player player) {
  40. if (permissionsEnabled) {
  41. return permission(player, "gastronomic.admin.enable");
  42. }
  43. return isOp(player);
  44. }
  45. public static boolean checkhunger(Player player) {
  46. if (permissionsEnabled) {
  47. return permission(player, "gastronomic.player.checkhunger");
  48. }
  49. return isOp(player);
  50. }
  51. public static boolean sethunger(Player player) {
  52. if (permissionsEnabled) {
  53. return permission(player, "gastronomic.admin.sethunger");
  54. }
  55. return isOp(player);
  56. }
  57. public static boolean hunger(Player player) {
  58. if (permissionsEnabled) {
  59. return permission(player, "gastronomic.disablehunger");
  60. }
  61. return false;
  62. }
  63. public static boolean reload(Player player) {
  64. if (permissionsEnabled) {
  65. return permission(player, "gastronomic.admin.reload");
  66. }
  67. return isOp(player);
  68. }
  69. public static boolean food(Player player) {
  70. if (permissionsEnabled) {
  71. return permission(player, "gastronomic.player.checkfood");
  72. }
  73. return isOp(player);
  74. }
  75. }