PageRenderTime 62ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/src/net/milkbowl/vault/chat/plugins/Chat_rscPermissions.java

https://gitlab.com/MineYourMind/Vault
Java | 214 lines | 162 code | 37 blank | 15 comment | 13 complexity | 6a3c46f3a3b62e7311a7ba24044502a9 MD5 | raw file
  1. /* This file is part of Vault.
  2. Vault is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU Lesser General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. Vault is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public License
  11. along with Vault. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. package net.milkbowl.vault.chat.plugins;
  14. import java.util.logging.Logger;
  15. import net.milkbowl.vault.chat.Chat;
  16. import net.milkbowl.vault.permission.Permission;
  17. import org.bukkit.Bukkit;
  18. import org.bukkit.event.EventHandler;
  19. import org.bukkit.event.EventPriority;
  20. import org.bukkit.event.Listener;
  21. import org.bukkit.event.server.PluginDisableEvent;
  22. import org.bukkit.event.server.PluginEnableEvent;
  23. import org.bukkit.plugin.Plugin;
  24. import ru.simsonic.rscPermissions.MainPluginClass;
  25. public class Chat_rscPermissions extends Chat {
  26. private static final Logger log = Logger.getLogger("Minecraft");
  27. private final Plugin vault;
  28. private ru.simsonic.rscPermissions.MainPluginClass rscp;
  29. private ru.simsonic.rscPermissions.rscpAPI rscpAPI;
  30. public Chat_rscPermissions(Plugin plugin, Permission perm) {
  31. super(perm);
  32. this.vault = plugin;
  33. Bukkit.getServer().getPluginManager().registerEvents(new ChatServerListener(this), vault);
  34. if (rscp == null) {
  35. Plugin perms = plugin.getServer().getPluginManager().getPlugin("rscPermissions");
  36. if (perms != null && perms.isEnabled()) {
  37. this.rscp = (MainPluginClass) perms;
  38. rscpAPI = rscp.API;
  39. plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "rscPermissions"));
  40. }
  41. }
  42. }
  43. private class ChatServerListener implements Listener {
  44. private final Chat_rscPermissions bridge;
  45. public ChatServerListener(Chat_rscPermissions bridge) {
  46. this.bridge = bridge;
  47. }
  48. @EventHandler(priority = EventPriority.MONITOR)
  49. private void onPluginEnable(PluginEnableEvent event) {
  50. if(bridge.rscp == null) {
  51. Plugin plugin = event.getPlugin();
  52. if (plugin.getDescription().getName().equals("rscPermissions")) {
  53. bridge.rscp = (MainPluginClass) plugin;
  54. bridge.rscpAPI = bridge.rscp.API;
  55. log.info(String.format("[%s][Chat] %s hooked.", vault.getDescription().getName(), "rscPermissions"));
  56. }
  57. }
  58. }
  59. @EventHandler(priority = EventPriority.MONITOR)
  60. public void onPluginDisable(PluginDisableEvent event) {
  61. if(bridge.rscpAPI != null) {
  62. if(event.getPlugin().getDescription().getName().equals(bridge.rscpAPI.getName())) {
  63. bridge.rscpAPI = null;
  64. bridge.rscp = null;
  65. log.info(String.format("[%s][Chat] %s un-hooked.", vault.getDescription().getName(), "rscPermissions"));
  66. }
  67. }
  68. }
  69. }
  70. @Override
  71. public String getName() {
  72. return "rscPermissions";
  73. }
  74. @Override
  75. public boolean isEnabled() {
  76. return rscpAPI != null && rscpAPI.isEnabled();
  77. }
  78. @Override
  79. public String getPlayerPrefix(String world, String player) {
  80. return rscpAPI.getPlayerPrefix(world, player);
  81. }
  82. @Override
  83. public String getPlayerSuffix(String world, String player) {
  84. return rscpAPI.getPlayerSuffix(world, player);
  85. }
  86. @Override
  87. public String getGroupPrefix(String world, String group) {
  88. return rscpAPI.getGroupPrefix(world, group);
  89. }
  90. @Override
  91. public String getGroupSuffix(String world, String group) {
  92. return rscpAPI.getGroupSuffix(world, group);
  93. }
  94. @Override
  95. public void setPlayerPrefix(String world, String player, String prefix) {
  96. rscpAPI.setPlayerPrefix(world, player, prefix);
  97. }
  98. @Override
  99. public void setPlayerSuffix(String world, String player, String suffix) {
  100. rscpAPI.setPlayerSuffix(world, player, suffix);
  101. }
  102. @Override
  103. public void setGroupPrefix(String world, String group, String prefix) {
  104. rscpAPI.setGroupPrefix(world, group, prefix);
  105. }
  106. @Override
  107. public void setGroupSuffix(String world, String group, String suffix) {
  108. rscpAPI.setGroupSuffix(world, group, suffix);
  109. }
  110. @Override
  111. public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
  112. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  113. }
  114. @Override
  115. public void setPlayerInfoInteger(String world, String player, String node, int defaultValue) {
  116. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  117. }
  118. @Override
  119. public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
  120. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  121. }
  122. @Override
  123. public void setGroupInfoInteger(String world, String group, String node, int defaultValue) {
  124. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  125. }
  126. @Override
  127. public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
  128. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  129. }
  130. @Override
  131. public void setPlayerInfoDouble(String world, String player, String node, double defaultValue) {
  132. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  133. }
  134. @Override
  135. public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
  136. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  137. }
  138. @Override
  139. public void setGroupInfoDouble(String world, String group, String node, double defaultValue) {
  140. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  141. }
  142. @Override
  143. public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
  144. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  145. }
  146. @Override
  147. public void setPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
  148. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  149. }
  150. @Override
  151. public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
  152. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  153. }
  154. @Override
  155. public void setGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
  156. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  157. }
  158. @Override
  159. public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
  160. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  161. }
  162. @Override
  163. public void setPlayerInfoString(String world, String player, String node, String defaultValue) {
  164. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  165. }
  166. @Override
  167. public String getGroupInfoString(String world, String group, String node, String defaultValue) {
  168. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  169. }
  170. @Override
  171. public void setGroupInfoString(String world, String group, String node, String defaultValue) {
  172. throw new UnsupportedOperationException("rscPermissions does not support info nodes");
  173. }
  174. }