Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.79 KB | None | 0 0
  1. package com.customhcf.hcf;
  2.  
  3. import com.customhcf.hcf.tab.HCTab;
  4. import com.sk89q.worldedit.bukkit.WorldEditPlugin;
  5. import com.customhcf.base.BasePlugin;
  6. import com.customhcf.base.ServerHandler;
  7. import com.customhcf.hcf.Utils.Chat;
  8. import com.customhcf.hcf.Utils.ConfigurationService;
  9. import com.customhcf.hcf.Utils.Cooldowns;
  10. import com.customhcf.hcf.Utils.DateTimeFormats;
  11. import com.customhcf.hcf.Utils.Message;
  12. import com.customhcf.hcf.balance.EconomyCommand;
  13. import com.customhcf.hcf.balance.EconomyManager;
  14. import com.customhcf.hcf.balance.FlatFileEconomyManager;
  15. import com.customhcf.hcf.balance.PayCommand;
  16. import com.customhcf.hcf.balance.ShopSignListener;
  17. import com.customhcf.hcf.balance.SpawnerTradeListener;
  18. import com.customhcf.hcf.classes.PvpClassManager;
  19. import com.customhcf.hcf.classes.archer.ArcherClass;
  20. import com.customhcf.hcf.combatlog.CombatLogListener;
  21. import com.customhcf.hcf.combatlog.CustomEntityRegistration;
  22. import com.customhcf.hcf.command.*;
  23. import com.customhcf.hcf.config.PotionLimiterData;
  24. import com.customhcf.hcf.crate.KeyListener;
  25. import com.customhcf.hcf.crate.KeyManager;
  26. import com.customhcf.hcf.crate.LootExecutor;
  27. import com.customhcf.hcf.deathban.Deathban;
  28. import com.customhcf.hcf.deathban.DeathbanListener;
  29. import com.customhcf.hcf.deathban.DeathbanManager;
  30. import com.customhcf.hcf.deathban.FlatFileDeathbanManager;
  31. import com.customhcf.hcf.faction.FactionExecutor;
  32. import com.customhcf.hcf.faction.FactionManager;
  33. import com.customhcf.hcf.faction.FactionMember;
  34. import com.customhcf.hcf.faction.FlatFileFactionManager;
  35. import com.customhcf.hcf.faction.claim.Claim;
  36. import com.customhcf.hcf.faction.claim.ClaimHandler;
  37. import com.customhcf.hcf.faction.claim.ClaimWandListener;
  38. import com.customhcf.hcf.faction.claim.Subclaim;
  39. import com.customhcf.hcf.faction.type.ClaimableFaction;
  40. import com.customhcf.hcf.faction.type.EndPortalFaction;
  41. import com.customhcf.hcf.faction.type.Faction;
  42. import com.customhcf.hcf.faction.type.GlowstoneFaction;
  43. import com.customhcf.hcf.faction.type.PlayerFaction;
  44. import com.customhcf.hcf.faction.type.RoadFaction;
  45. import com.customhcf.hcf.faction.type.SpawnFaction;
  46. import com.customhcf.hcf.fixes.*;
  47. import com.customhcf.hcf.kothgame.CaptureZone;
  48. import com.customhcf.hcf.kothgame.EventExecutor;
  49. import com.customhcf.hcf.kothgame.EventScheduler;
  50. import com.customhcf.hcf.kothgame.conquest.ConquestExecutor;
  51. import com.customhcf.hcf.kothgame.eotw.EOTWHandler;
  52. import com.customhcf.hcf.kothgame.eotw.EotwCommand;
  53. import com.customhcf.hcf.kothgame.eotw.EotwListener;
  54. import com.customhcf.hcf.kothgame.faction.CapturableFaction;
  55. import com.customhcf.hcf.kothgame.faction.ConquestFaction;
  56. import com.customhcf.hcf.kothgame.faction.KothFaction;
  57. import com.customhcf.hcf.kothgame.koth.KothExecutor;
  58. import com.customhcf.hcf.listener.*;
  59. import com.customhcf.hcf.lives.LivesExecutor;
  60. import com.customhcf.hcf.scoreboard.ScoreboardHandler;
  61. import com.customhcf.hcf.timer.TimerExecutor;
  62. import com.customhcf.hcf.timer.TimerManager;
  63. import com.customhcf.hcf.timer.type.SotwTimer;
  64. import com.customhcf.hcf.user.FactionUser;
  65. import com.customhcf.hcf.user.UserManager;
  66. import com.customhcf.hcf.visualise.ProtocolLibHook;
  67. import com.customhcf.hcf.visualise.VisualiseHandler;
  68. import com.customhcf.hcf.visualise.WallBorderListener;
  69. import com.google.common.base.Joiner;
  70.  
  71.  
  72. import java.util.*;
  73. import java.util.concurrent.TimeUnit;
  74. import org.apache.commons.lang3.time.DurationFormatUtils;
  75. import org.bukkit.Bukkit;
  76. import org.bukkit.World;
  77. import org.bukkit.command.CommandExecutor;
  78. import org.bukkit.command.PluginCommand;
  79. import org.bukkit.configuration.serialization.ConfigurationSerialization;
  80. import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
  81. import org.bukkit.event.Listener;
  82. import org.bukkit.plugin.Plugin;
  83. import org.bukkit.plugin.PluginManager;
  84. import org.bukkit.plugin.java.JavaPlugin;
  85. import org.bukkit.scheduler.BukkitRunnable;
  86. import org.github.paperspigot.PaperSpigotConfig;
  87.  
  88.  
  89. public class HCF extends JavaPlugin {
  90.  
  91. public static final Joiner SPACE_JOINER = Joiner.on(' ');
  92. public static final Joiner COMMA_JOINER = Joiner.on(", ");
  93. private static final long MINUTE = TimeUnit.MINUTES.toMillis(1);
  94. private static final long HOUR = TimeUnit.HOURS.toMillis(1);
  95. private static HCF plugin;
  96. private Message message;
  97. public EventScheduler eventScheduler;
  98. private Random random = new Random();
  99.  
  100. public String scoreboardTitle;
  101. public String helpTitle;
  102.  
  103. private WorldEditPlugin worldEdit;
  104. private FoundDiamondsListener foundDiamondsListener;
  105. private ClaimHandler claimHandler;
  106. private SotwTimer sotwTimer;
  107. private KeyManager keyManager;
  108. private DeathbanManager deathbanManager;
  109. private EconomyManager economyManager;
  110. private EOTWHandler eotwHandler;
  111. private FactionManager factionManager;
  112. private PvpClassManager pvpClassManager;
  113. private ScoreboardHandler scoreboardHandler;
  114. private TimerManager timerManager;
  115. private UserManager userManager;
  116. private VisualiseHandler visualiseHandler;
  117. public String epearl;
  118. public String ctag;
  119. public String pvptimer;
  120. public String log;
  121. public String stuck;
  122. public String tele;
  123. public String armor;
  124.  
  125. public static HCF getPlugin() {
  126. return plugin;
  127. }
  128.  
  129. public static String getReaming(long millis) {
  130. return HCF.getRemaining(millis, true, true);
  131. }
  132.  
  133. public static String getRemaining(long millis, boolean milliseconds) {
  134. return HCF.getRemaining(millis, milliseconds, true);
  135. }
  136.  
  137. public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
  138. if (milliseconds && duration < MINUTE) {
  139. return (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get().format((double)duration * 0.001) + 's';
  140. }
  141. return DurationFormatUtils.formatDuration((long)duration, (String)((duration >= HOUR ? "HH:" : "") + "mm:ss"));
  142. }
  143.  
  144. public void onEnable() {
  145. plugin = this;
  146. CustomEntityRegistration.registerCustomEntities();
  147. ProtocolLibHook.hook(this);
  148.  
  149. this.saveDefaultConfig();
  150.  
  151. ConfigurationService.init(this.getConfig());
  152.  
  153. PotionLimiterData.getInstance().setup(this);
  154.  
  155. PotionLimitListener.reload();
  156.  
  157. Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
  158. this.worldEdit = wep instanceof WorldEditPlugin && wep.isEnabled() ? (WorldEditPlugin)wep : null;
  159. this.registerConfiguration();
  160. this.registerCommands();
  161. this.registerManagers();
  162. Cooldowns.createCooldown("revive_cooldown");
  163. this.registerListeners();
  164. Cooldowns.createCooldown("Assassin_item_cooldown");
  165. Cooldowns.createCooldown("Archer_item_cooldown");
  166. Cooldowns.createCooldown("Archer_jump_cooldown");
  167. Cooldowns.createCooldown("report_cooldown");
  168. Cooldowns.createCooldown("helpop_cooldown");
  169.  
  170. this.helpTitle = Chat.translateColors(getConfig().getString("Help title"));
  171. this.scoreboardTitle = Chat.translateColors(getConfig().getString("Scoreboard title"));
  172. this.armor = Chat.translateColors(getConfig().getString("Active Class"));
  173.  
  174. this.timerManager.enable();
  175.  
  176. HCTab.enable();
  177. new BukkitRunnable() {
  178.  
  179. @Override
  180. public void run() {
  181. for(World world : Bukkit.getWorlds()){
  182. ((CraftWorld)world).getHandle().paperSpigotConfig.loadUnloadedEnderPearls = true;
  183. ((CraftWorld)world).getHandle().paperSpigotConfig.removeUnloadedEnderPearls = false;
  184.  
  185. }
  186. }
  187. }.runTaskLater(this, 20);
  188. }
  189.  
  190.  
  191. private void saveData() {
  192. this.deathbanManager.saveDeathbanData();
  193. this.economyManager.saveEconomyData();
  194. this.factionManager.saveFactionData();
  195. this.keyManager.saveKeyData();
  196. this.userManager.saveUserData();
  197. }
  198.  
  199. public void onDisable() {
  200. CustomEntityRegistration.unregisterCustomEntities();
  201. CombatLogListener.removeCombatLoggers();
  202. this.pvpClassManager.onDisable();
  203. this.scoreboardHandler.clearBoards();
  204. this.saveData();
  205. saveConfig();
  206. this.timerManager.disable();
  207.  
  208. HCTab.disable();
  209. }
  210.  
  211. private void registerConfiguration() {
  212. ConfigurationSerialization.registerClass((Class)CaptureZone.class);
  213. ConfigurationSerialization.registerClass((Class)Deathban.class);
  214. ConfigurationSerialization.registerClass((Class)Claim.class);
  215. ConfigurationSerialization.registerClass((Class)Subclaim.class);
  216. ConfigurationSerialization.registerClass((Class)Deathban.class);
  217. ConfigurationSerialization.registerClass((Class)FactionUser.class);
  218. ConfigurationSerialization.registerClass((Class)ClaimableFaction.class);
  219. ConfigurationSerialization.registerClass((Class)ConquestFaction.class);
  220. ConfigurationSerialization.registerClass((Class)CapturableFaction.class);
  221. ConfigurationSerialization.registerClass((Class)KothFaction.class);
  222. ConfigurationSerialization.registerClass((Class)EndPortalFaction.class);
  223. ConfigurationSerialization.registerClass((Class)Faction.class);
  224. ConfigurationSerialization.registerClass((Class)FactionMember.class);
  225. ConfigurationSerialization.registerClass((Class)PlayerFaction.class);
  226. ConfigurationSerialization.registerClass((Class)RoadFaction.class);
  227. ConfigurationSerialization.registerClass((Class)RoadFaction.class);
  228. ConfigurationSerialization.registerClass((Class)SpawnFaction.class);
  229. ConfigurationSerialization.registerClass((Class)RoadFaction.NorthRoadFaction.class);
  230. ConfigurationSerialization.registerClass((Class)RoadFaction.EastRoadFaction.class);
  231. ConfigurationSerialization.registerClass((Class)RoadFaction.SouthRoadFaction.class);
  232. ConfigurationSerialization.registerClass((Class)RoadFaction.WestRoadFaction.class);
  233. ConfigurationSerialization.registerClass((Class)GlowstoneFaction.class);
  234.  
  235. }
  236.  
  237. private void registerListeners() {
  238. PluginManager manager = this.getServer().getPluginManager();
  239. manager.registerEvents((Listener)new ColonFix(), (Plugin)this);
  240. manager.registerEvents((Listener)new PexCrashFix(), (Plugin)this);
  241. manager.registerEvents((Listener)new DupeGlitchFix(), (Plugin)this);
  242. manager.registerEvents((Listener)new DonorOnlyListener(), (Plugin)this);
  243. manager.registerEvents((Listener)new ArcherClass(this), (Plugin)this);
  244. manager.registerEvents((Listener)new KeyListener(this), (Plugin)this);
  245. manager.registerEvents((Listener)new WeatherFixListener(), (Plugin)this);
  246. manager.registerEvents((Listener)new MinecartElevatorListener(), (Plugin)this);
  247. //manager.registerEvents((Listener)new NoPermissionClickListener(), (Plugin)this);
  248. manager.registerEvents((Listener)new AutoSmeltOreListener(), (Plugin)this);
  249. manager.registerEvents((Listener)new BlockHitFixListener(), (Plugin)this);
  250. manager.registerEvents((Listener)new BlockJumpGlitchFixListener(), (Plugin)this);
  251. manager.registerEvents((Listener)new HungerFixListener(), (Plugin)this);
  252. manager.registerEvents((Listener)new BoatGlitchFixListener(), (Plugin)this);
  253. manager.registerEvents((Listener)new BookDeenchantListener(), (Plugin)this);
  254. manager.registerEvents((Listener)new BorderListener(), (Plugin)this);
  255. manager.registerEvents((Listener)new BottledExpListener(), (Plugin)this);
  256. manager.registerEvents((Listener)new ChatListener(this), (Plugin)this);
  257. manager.registerEvents((Listener)new ClaimWandListener(this), (Plugin)this);
  258. manager.registerEvents((Listener)new CombatLogListener(this), (Plugin)this);
  259. manager.registerEvents((Listener)new CoreListener(this), (Plugin)this);
  260. manager.registerEvents((Listener)new CreeperFriendlyListener(), (Plugin)this);
  261. manager.registerEvents((Listener)new CrowbarListener(this), (Plugin)this);
  262. manager.registerEvents((Listener)new DeathListener(this), (Plugin)this);
  263. manager.registerEvents((Listener)new DeathMessageListener(this), (Plugin)this);
  264. manager.registerEvents((Listener)new DeathSignListener(this), (Plugin)this);
  265. manager.registerEvents((Listener)new DeathbanListener(this), (Plugin)this);
  266. manager.registerEvents((Listener)new EnchantLimitListener(), (Plugin)this);
  267. manager.registerEvents((Listener)new EnderChestRemovalListener(), (Plugin)this);
  268. manager.registerEvents((Listener)new EntityLimitListener(), (Plugin)this);
  269. manager.registerEvents((Listener)new FlatFileFactionManager(this), (Plugin)this);
  270. manager.registerEvents((Listener)new EndListener(), (Plugin)this);
  271. manager.registerEvents((Listener)new EotwListener(this), (Plugin)this);
  272. manager.registerEvents((Listener)new EventSignListener(), (Plugin)this);
  273. manager.registerEvents((Listener)new ExpMultiplierListener(), (Plugin)this);
  274. manager.registerEvents((Listener)new FactionListener(this), (Plugin)this);
  275. manager.registerEvents((Listener)new HitDetectionListener(), (Plugin)this);
  276. this.foundDiamondsListener = new FoundDiamondsListener(this);
  277. manager.registerEvents((Listener)new SpawnerTradeListener(this), (Plugin)this);
  278. manager.registerEvents((Listener)this.foundDiamondsListener, (Plugin)this);
  279. manager.registerEvents((Listener)new FurnaceSmeltSpeederListener(), (Plugin)this);
  280. manager.registerEvents((Listener)new InfinityArrowFixListener(), (Plugin)this);
  281. manager.registerEvents((Listener)new KitListener(this), (Plugin)this);
  282. manager.registerEvents((Listener)new ItemStatTrackingListener(), (Plugin)this);
  283. manager.registerEvents((Listener)new PearlGlitchListener(this), (Plugin)this);
  284. manager.registerEvents((Listener)new PotionLimitListener(), (Plugin)this);
  285. manager.registerEvents((Listener)new FactionsCoreListener(this), (Plugin)this);
  286. manager.registerEvents((Listener)new SignSubclaimListener(this), (Plugin)this);
  287. manager.registerEvents((Listener)new ShopSignListener(this), (Plugin)this);
  288. manager.registerEvents((Listener)new SkullListener(), (Plugin)this);
  289. manager.registerEvents((Listener)new BeaconStrengthFixListener(), (Plugin)this);
  290. manager.registerEvents((Listener)new VoidGlitchFixListener(), (Plugin)this);
  291. manager.registerEvents((Listener)new WallBorderListener(this), (Plugin)this);
  292. manager.registerEvents((Listener)new WorldListener(this), (Plugin)this);
  293. manager.registerEvents((Listener)new UnRepairableListener(), (Plugin)this);
  294. manager.registerEvents(new SotwListener(this), (Plugin)this);
  295. //manager.registerEvents(new StatTrackListener(), this);
  296. manager.registerEvents(new CobbleCommand(), this);
  297.  
  298. }
  299.  
  300. private void registerCommands() {
  301. this.getCommand("toggleend").setExecutor((CommandExecutor)new ToggleEnd(this));
  302. this.getCommand("focus").setExecutor(new FactionFocusArgument(this));
  303. this.getCommand("tpcoords").setExecutor((CommandExecutor)new tpcoords());
  304. this.getCommand("spawner").setExecutor((CommandExecutor)new SpawnerCommand(this));
  305. this.getCommand("spawndragon").setExecutor((CommandExecutor)new EndDragonCommand(this));
  306. this.getCommand("sotw").setExecutor(new SotwCommand(this));
  307. this.getCommand("conquest").setExecutor((CommandExecutor)new ConquestExecutor(this));
  308. this.getCommand("crowbar").setExecutor((CommandExecutor)new CrowbarCommand());
  309. this.getCommand("economy").setExecutor((CommandExecutor)new EconomyCommand(this));
  310. this.getCommand("eotw").setExecutor((CommandExecutor)new EotwCommand(this));
  311. this.getCommand("game").setExecutor((CommandExecutor)new EventExecutor(this));
  312. this.getCommand("help").setExecutor((CommandExecutor)new HelpCommand());
  313. this.getCommand("faction").setExecutor((CommandExecutor)new FactionExecutor(this));
  314. this.getCommand("gopple").setExecutor((CommandExecutor)new GoppleCommand(this));
  315. this.getCommand("stats").setExecutor((CommandExecutor)new PlayerStats());
  316. this.getCommand("lff").setExecutor((CommandExecutor)new LFFCommand(this));
  317. this.getCommand("koth").setExecutor((CommandExecutor)new KothExecutor(this));
  318. this.getCommand("lives").setExecutor((CommandExecutor)new LivesExecutor(this));
  319. this.getCommand("location").setExecutor((CommandExecutor)new LocationCommand(this));
  320. this.getCommand("logout").setExecutor((CommandExecutor)new LogoutCommand(this));
  321. this.getCommand("mapkit").setExecutor((CommandExecutor)new com.customhcf.hcf.command.MapKitCommand(this));
  322. this.getCommand("pay").setExecutor((CommandExecutor)new PayCommand(this));
  323. this.getCommand("pvptimer").setExecutor((CommandExecutor)new PvpTimerCommand(this));
  324. this.getCommand("refund").setExecutor((CommandExecutor)new RefundCommand());
  325. this.getCommand("coords").setExecutor(new coords(this));
  326. this.getCommand("servertime").setExecutor((CommandExecutor)new ServerTimeCommand());
  327. this.getCommand("spawn").setExecutor((CommandExecutor)new SpawnCommand(this));
  328. this.getCommand("timer").setExecutor((CommandExecutor)new TimerExecutor(this));
  329. this.getCommand("revive").setExecutor(new ReviveCommand(this));
  330. this.getCommand("staffinfo").setExecutor(new StaffScript());
  331. this.getCommand("setborder").setExecutor((CommandExecutor)new SetBorderCommand());
  332. this.getCommand("loot").setExecutor((CommandExecutor)new LootExecutor(this));
  333. this.getCommand("staffrevive").setExecutor(new StaffReviveCommand(this));
  334. //this.getCommand("icons").setExecutor(new IconsCommand());
  335. this.getCommand("cobble").setExecutor(new CobbleCommand());
  336. this.getCommand("ores").setExecutor(new OresCommand());
  337. this.getCommand("crowgive").setExecutor(new CrowbarGiveCommand());
  338. final Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>)this.getDescription().getCommands();
  339. for (final Map.Entry<String, Map<String, Object>> entry : map.entrySet()) {
  340. final PluginCommand command = this.getCommand((String)entry.getKey());
  341. command.setPermission("command." + entry.getKey());
  342. }
  343. }
  344.  
  345. private void registerManagers() {
  346. this.claimHandler = new ClaimHandler(this);
  347. this.deathbanManager = new FlatFileDeathbanManager(this);
  348. this.economyManager = new FlatFileEconomyManager(this);
  349. this.eotwHandler = new EOTWHandler(this);
  350. this.eventScheduler = new EventScheduler(this);
  351. this.factionManager = new FlatFileFactionManager(this);
  352. this.pvpClassManager = new PvpClassManager(this);
  353. this.timerManager = new TimerManager(this);
  354. this.scoreboardHandler = new ScoreboardHandler(this);
  355. this.userManager = new UserManager(this);
  356. this.visualiseHandler = new VisualiseHandler();
  357. this.sotwTimer = new SotwTimer();
  358. this.keyManager = new KeyManager(this);
  359. this.message = new Message(this);
  360.  
  361. }
  362.  
  363.  
  364. public Message getMessage() {
  365. return this.message;
  366. }
  367.  
  368. public ServerHandler getServerHandler() {
  369. return BasePlugin.getPlugin().getServerHandler();
  370. }
  371.  
  372. public Random getRandom() {
  373. return this.random;
  374. }
  375.  
  376. public static HCF getInstance() {
  377. return plugin;
  378. }
  379.  
  380. public WorldEditPlugin getWorldEdit() {
  381. return this.worldEdit;
  382. }
  383.  
  384. public KeyManager getKeyManager() {
  385. return this.keyManager;
  386. }
  387.  
  388. public ClaimHandler getClaimHandler() {
  389. return this.claimHandler;
  390. }
  391.  
  392. public DeathbanManager getDeathbanManager() {
  393. return this.deathbanManager;
  394. }
  395.  
  396.  
  397. public EconomyManager getEconomyManager() {
  398. return this.economyManager;
  399. }
  400.  
  401. public EOTWHandler getEotwHandler() {
  402. return this.eotwHandler;
  403. }
  404.  
  405. public FactionManager getFactionManager() {
  406. return this.factionManager;
  407. }
  408.  
  409. public PvpClassManager getPvpClassManager() {
  410. return this.pvpClassManager;
  411. }
  412.  
  413. public ScoreboardHandler getScoreboardHandler() {
  414. return this.scoreboardHandler;
  415. }
  416.  
  417. public TimerManager getTimerManager() {
  418. return this.timerManager;
  419. }
  420.  
  421. public UserManager getUserManager() {
  422. return this.userManager;
  423. }
  424.  
  425. public VisualiseHandler getVisualiseHandler() {
  426. return this.visualiseHandler;
  427. }
  428.  
  429. public SotwTimer getSotwTimer() {
  430. return this.sotwTimer;
  431. }
  432.  
  433. public String scoreboardTitle() {
  434. return this.scoreboardTitle;
  435. }
  436.  
  437. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement