Guest User

Untitled

a guest
Sep 1st, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* */ import it.feargames.auracheck.AuraCheck;
  2. /* */ import it.feargames.auracheck.config.ConfigProperties;
  3. /* */ import it.feargames.auracheck.data.Checker;
  4. /* */ import it.feargames.auracheck.data.CheckerManager;
  5. /* */ import it.feargames.auracheck.libs.configme.SettingsManager;
  6. /* */ import it.feargames.auracheck.libs.injector.Injector;
  7. /* */ import it.feargames.auracheck.libs.injector.InjectorBuilder;
  8. /* */ import it.feargames.auracheck.tasks.AutoTask;
  9. /* */ import org.bukkit.Bukkit;
  10. /* */ import org.bukkit.ChatColor;
  11. /* */ import org.bukkit.command.Command;
  12. /* */ import org.bukkit.command.CommandSender;
  13. /* */ import org.bukkit.entity.Player;
  14. /* */ import org.bukkit.event.Listener;
  15. /* */ import org.bukkit.plugin.java.JavaPlugin;
  16. /* */ import org.bukkit.scheduler.BukkitTask;
  17. /* */
  18. /* */
  19. /* */
  20. /* */
  21. /* */
  22. /* */
  23. /* */
  24. /* */
  25. /* */
  26. /* */
  27. /* */ public class AuraCheck
  28. /* */ extends JavaPlugin
  29. /* */ {
  30. /* */ private Injector injector;
  31. /* */ private SettingsManager settings;
  32. /* */ private CheckerManager checkerManager;
  33. /* 33 */ private BukkitTask autoTask = null;
  34. /* */
  35. /* */
  36. /* */
  37. /* */
  38. /* */ public void onEnable() {
  39. /* 39 */ if (getDataFolder().mkdir()) {
  40. /* 40 */ getLogger().info("Thank you for using AuraCheck! Please check the config file to customize the plugin's behaviour!");
  41. /* */ }
  42. /* */
  43. /* */
  44. /* 44 */ setupInjector();
  45. /* */
  46. /* */
  47. /* 47 */ this.settings = (SettingsManager)this.injector.getSingleton(SettingsManager.class);
  48. /* 48 */ this.checkerManager = (CheckerManager)this.injector.getSingleton(CheckerManager.class);
  49. /* */
  50. /* */
  51. /* 51 */ getServer().getPluginManager().registerEvents((Listener)this.injector.getSingleton(it.feargames.auracheck.listeners.PlayerListener.class), this);
  52. /* */
  53. /* */
  54. /* 54 */ setupAutoTask();
  55. /* */ }
  56. /* */
  57. /* */ private void setupInjector() {
  58. /* 58 */ this.injector = (new InjectorBuilder()).addDefaultHandlers("it.feargames.auracheck").create();
  59. /* 59 */ this.injector.register(AuraCheck.class, this);
  60. /* 60 */ this.injector.register(org.bukkit.Server.class, getServer());
  61. /* 61 */ this.injector.register(org.bukkit.plugin.PluginManager.class, getServer().getPluginManager());
  62. /* 62 */ this.injector.register(org.bukkit.scheduler.BukkitScheduler.class, getServer().getScheduler());
  63. /* 63 */ this.injector.provide(it.feargames.auracheck.annotations.DataFolder.class, getDataFolder());
  64. /* 64 */ this.injector.registerProvider(SettingsManager.class, it.feargames.auracheck.config.SettingsProvider.class);
  65. /* */ }
  66. /* */
  67. /* */ private void setupAutoTask() {
  68. /* 68 */ if (this.autoTask != null) {
  69. /* 69 */ this.autoTask.cancel();
  70. /* */ }
  71. /* 71 */ if (((Boolean)this.settings.getProperty(ConfigProperties.AUTO)).booleanValue()) {
  72. /* 72 */ this.autoTask = (new AutoTask(this)).runTaskTimer(this, 200L, 6000L);
  73. /* */ } else {
  74. /* 74 */ this.autoTask = null;
  75. /* */ }
  76. /* */ }
  77. /* */
  78. /* */
  79. /* */
  80. /* */
  81. /* */
  82. /* */
  83. /* */ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  84. /* 84 */ if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
  85. /* 85 */ sendHelp(sender);
  86. /* 86 */ return true;
  87. /* */ }
  88. /* 88 */ String subCmd = args[0];
  89. /* */
  90. /* */
  91. /* 91 */ if (subCmd.equalsIgnoreCase("reload")) {
  92. /* 92 */ this.settings.reload();
  93. /* 93 */ sender.sendMessage(ChatColor.GREEN + "Configuration reloaded successfully!");
  94. /* 94 */ setupInjector();
  95. /* 95 */ return true;
  96. /* */ }
  97. /* */
  98. /* */
  99. /* 99 */ if (subCmd.equalsIgnoreCase("auto")) {
  100. /* */
  101. /* 101 */ if (args.length < 2) {
  102. /* 102 */ sendHelp(sender);
  103. /* 103 */ return true;
  104. /* */ }
  105. /* 105 */ String param = args[1];
  106. /* */
  107. /* 107 */ switch (param.toLowerCase())
  108. /* */ { case "on":
  109. /* 109 */ sender.sendMessage(ChatColor.GREEN + "Auto mode enabled!");
  110. /* 110 */ this.settings.setProperty(ConfigProperties.AUTO, Boolean.valueOf(true));
  111. /* 111 */ this.settings.save();
  112. /* */
  113. /* */
  114. /* */
  115. /* */
  116. /* */
  117. /* */
  118. /* */
  119. /* */
  120. /* */
  121. /* 121 */ setupAutoTask();
  122. /* 122 */ return true;case "off": sender.sendMessage(ChatColor.RED + "Auto mode disabled!"); this.settings.setProperty(ConfigProperties.AUTO, Boolean.valueOf(false)); this.settings.save(); setupAutoTask(); return true; } sendHelp(sender); setupAutoTask(); return true;
  123. /* */ }
  124. /* */
  125. /* */
  126. /* 126 */ if (subCmd.equalsIgnoreCase("check")) {
  127. /* */
  128. /* 128 */ if (args.length < 2) {
  129. /* 129 */ sendHelp(sender);
  130. /* 130 */ return true;
  131. /* */ }
  132. /* 132 */ String param = args[1];
  133. /* */
  134. /* */
  135. /* 135 */ if (param.equals("*")) {
  136. /* 136 */ for (Player player : Bukkit.getOnlinePlayers()) {
  137. /* 137 */ checkPlayer(sender, player, true, false);
  138. /* */
  139. /* */ }
  140. /* */ }
  141. /* */ else {
  142. /* */
  143. /* 143 */ Player player = Bukkit.getPlayerExact(param);
  144. /* 144 */ if (player == null) {
  145. /* 145 */ sender.sendMessage(ChatColor.RED + "Player is not online.");
  146. /* */ } else {
  147. /* 147 */ checkPlayer(sender, player, false, false);
  148. /* */ }
  149. /* */ }
  150. /* 150 */ return true;
  151. /* */ }
  152. /* */
  153. /* */
  154. /* 154 */ if (subCmd.equalsIgnoreCase("checkmob")) {
  155. /* */
  156. /* */
  157. /* 157 */ if (args.length < 2) {
  158. /* 158 */ sendHelp(sender);
  159. /* 159 */ return true;
  160. /* */ }
  161. /* 161 */ String param = args[1];
  162. /* */
  163. /* */
  164. /* 164 */ if (param.equals("*")) {
  165. /* 165 */ for (Player player : Bukkit.getOnlinePlayers()) {
  166. /* 166 */ checkPlayer(sender, player, true, true);
  167. /* */
  168. /* */ }
  169. /* */ }
  170. /* */ else {
  171. /* */
  172. /* 172 */ Player player = Bukkit.getPlayerExact(param);
  173. /* 173 */ if (player == null) {
  174. /* 174 */ sender.sendMessage(ChatColor.RED + "Player is not online.");
  175. /* */ } else {
  176. /* 176 */ checkPlayer(sender, player, false, true);
  177. /* */ }
  178. /* */ }
  179. /* 179 */ return true;
  180. /* */ }
  181. /* 181 */ sendHelp(sender);
  182. /* 182 */ return true;
  183. /* */ }
  184. /* */
  185. /* */ private void sendHelp(CommandSender sender) {
  186. /* 186 */ sender.sendMessage("-----[ AuraCheck Help ]-----");
  187. /* 187 */ sender.sendMessage(" /ac help");
  188. /* 188 */ sender.sendMessage(" /ac reload");
  189. /* 189 */ sender.sendMessage(" /ac check <playername>");
  190. /* 190 */ sender.sendMessage(" /ac check *");
  191. /* 191 */ sender.sendMessage(" /ac checkmob <playername>");
  192. /* 192 */ sender.sendMessage(" /ac checkmob *");
  193. /* 193 */ sender.sendMessage(" /ac auto [on/off]");
  194. /* 194 */ sender.sendMessage("----------------------------");
  195. /* */ }
  196. /* */
  197. /* */
  198. /* */
  199. /* */
  200. /* */
  201. /* */
  202. /* */
  203. /* */
  204. /* */
  205. /* */ public void checkPlayer(CommandSender sender, Player player, boolean ignoreLegit, boolean useMobs) {
  206. /* 206 */ Checker checker = this.checkerManager.addCheck(player, useMobs);
  207. /* 207 */ Checker.Callback callback = (amount, killed, invoker, target) -> {
  208. /* */
  209. /* 209 */ if (invoker instanceof Player && !((Player)invoker).isOnline()) {
  210. /* */ return;
  211. /* */ }
  212. /* */
  213. /* */
  214. /* 214 */ if (ignoreLegit && killed == 0) {
  215. /* */ return;
  216. /* */ }
  217. /* */
  218. /* 218 */ if (killed < ((Integer)this.settings.getProperty(ConfigProperties.COMMAND_TRIGGER)).intValue()) {
  219. /* 219 */ invoker.sendMessage(ChatColor.DARK_PURPLE + target.getName() + " has killed " + killed + " out of " + amount);
  220. /* */
  221. /* */ return;
  222. /* */ }
  223. /* 223 */ String command = ((String)this.settings.getProperty(ConfigProperties.COMMAND)).replaceAll("%p", target.getName());
  224. /* 224 */ Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
  225. /* 225 */ invoker.sendMessage(ChatColor.RED + target.getName() + " have been kicked!" + ChatColor.DARK_PURPLE + " Killed " + killed + " out of " + amount);
  226. /* */ };
  227. /* 227 */ checker.invoke(this, this.checkerManager, sender, callback);
  228. /* */ }
  229. /* */ }
  230.  
  231.  
  232. /* Location: C:\Users\Fabio\Desktop\!\AuraCheck.class
  233. * Java compiler version: 8 (52.0)
  234. * JD-Core Version: 1.0.7
  235. */
RAW Paste Data