Advertisement
Prestige_PvP

Untitled

Apr 11th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.18 KB | None | 0 0
  1. package com.customhcf.hcf;
  2.  
  3.  
  4. import com.customhcf.hcf.command.*;
  5. import com.customhcf.hcf.balance.EconomyManager;
  6. import com.customhcf.hcf.faction.type.*;
  7. import com.customhcf.hcf.key.KeyListener;
  8. import com.customhcf.hcf.key.KeyManager;
  9. import com.customhcf.hcf.key.LootExecutor;
  10. import com.customhcf.hcf.kothgame.*;
  11. import com.customhcf.hcf.kothgame.eotw.EOTWHandler;
  12. import com.customhcf.hcf.listener.*;
  13. import com.customhcf.hcf.fixes.*;
  14. import com.customhcf.hcf.classes.PvpClassManager;
  15. import com.customhcf.hcf.classes.type.archer.ArcherClass;
  16. import com.customhcf.hcf.user.FactionUser;
  17. import com.customhcf.hcf.deathban.Deathban;
  18. import com.customhcf.hcf.deathban.DeathbanListener;
  19. import com.customhcf.hcf.deathban.DeathbanManager;
  20. import com.customhcf.hcf.deathban.FlatFileDeathbanManager;
  21. import com.customhcf.hcf.lives.LivesExecutor;
  22. import com.customhcf.hcf.balance.EconomyCommand;
  23. import com.customhcf.hcf.balance.FlatFileEconomyManager;
  24. import com.customhcf.hcf.balance.PayCommand;
  25. import com.customhcf.hcf.balance.ShopSignListener;
  26. import com.customhcf.hcf.kothgame.eotw.EotwCommand;
  27. import com.customhcf.hcf.kothgame.eotw.EotwListener;
  28. import com.customhcf.hcf.kothgame.faction.CapturableFaction;
  29. import com.customhcf.hcf.kothgame.faction.ConquestFaction;
  30. import com.customhcf.hcf.kothgame.faction.KothFaction;
  31. import com.customhcf.hcf.kothgame.koth.KothExecutor;
  32. import com.customhcf.hcf.faction.FactionExecutor;
  33. import com.customhcf.hcf.faction.FactionManager;
  34. import com.customhcf.hcf.faction.FactionMember;
  35. import com.customhcf.hcf.faction.FlatFileFactionManager;
  36. import com.customhcf.hcf.faction.claim.Claim;
  37. import com.customhcf.hcf.faction.claim.ClaimHandler;
  38. import com.customhcf.hcf.faction.claim.ClaimWandListener;
  39. import com.customhcf.hcf.faction.claim.Subclaim;
  40. import com.customhcf.hcf.scoreboard.ScoreboardHandler;
  41. import com.customhcf.hcf.timer.TimerExecutor;
  42. import com.customhcf.hcf.timer.TimerManager;
  43. import com.customhcf.hcf.user.UserManager;
  44. import com.customhcf.hcf.visualise.ProtocolLibHook;
  45. import com.customhcf.hcf.visualise.VisualiseHandler;
  46. import com.customhcf.hcf.visualise.WallBorderListener;
  47. import com.customhcf.hcf.combatlog.CombatLogListener;
  48. import com.customhcf.hcf.combatlog.CustomEntityRegistration;
  49. import com.sk89q.worldedit.bukkit.WorldEditPlugin;
  50. import org.apache.commons.lang3.time.DurationFormatUtils;
  51. import org.bukkit.Bukkit;
  52. import org.bukkit.ChatColor;
  53. import org.bukkit.command.CommandExecutor;
  54. import org.bukkit.command.PluginCommand;
  55. import org.bukkit.configuration.serialization.ConfigurationSerialization;
  56. import org.bukkit.plugin.Plugin;
  57. import org.bukkit.plugin.PluginManager;
  58. import org.bukkit.plugin.java.JavaPlugin;
  59. import org.bukkit.scheduler.BukkitRunnable;
  60.  
  61. import java.util.Map;
  62. import java.util.Random;
  63. import java.util.concurrent.TimeUnit;
  64.  
  65. public class HCF extends JavaPlugin {
  66. private static final long MINUTE;
  67. private static final long HOUR;
  68. private static HCF plugin;
  69.  
  70. static {
  71. MINUTE = TimeUnit.MINUTES.toMillis(1L);
  72. HOUR = TimeUnit.HOURS.toMillis(1L);
  73. }
  74.  
  75. private Message message;
  76. public EventScheduler eventScheduler;
  77. private Random random;
  78. private HCFHandler hcfHandler;
  79. private WorldEditPlugin worldEdit;
  80. private ClaimHandler claimHandler;
  81. private KeyManager keyManager;
  82. private DeathbanManager deathbanManager;
  83. private EconomyManager economyManager;
  84. private EOTWHandler eotwHandler;
  85. private FactionManager factionManager;
  86. private PvpClassManager pvpClassManager;
  87. private ScoreboardHandler scoreboardHandler;
  88. private TimerManager timerManager;
  89. private UserManager userManager;
  90. private VisualiseHandler visualiseHandler;
  91.  
  92. public HCF() {
  93. this.random = new Random();
  94. }
  95.  
  96. public static HCF getPlugin() {
  97. return HCF.plugin;
  98. }
  99.  
  100. public static String getReaming(final long millis){
  101. return getRemaining(millis, true, true);
  102. }
  103.  
  104. public static String getRemaining(final long millis, final boolean milliseconds) {
  105. return getRemaining(millis, milliseconds, true);
  106. }
  107.  
  108. public static String getRemaining(final long duration, final boolean milliseconds, final boolean trail) {
  109. if(milliseconds && duration < HCF.MINUTE) {
  110. return (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get().format(duration * 0.001) + 's';
  111. }
  112. return DurationFormatUtils.formatDuration(duration, ((duration >= HCF.HOUR) ? "HH:" : "") + "mm:ss");
  113. }
  114.  
  115. public void onEnable() {
  116. HCF.plugin = this;
  117. CustomEntityRegistration.registerCustomEntities();
  118. ProtocolLibHook.hook(this);
  119. final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
  120. this.worldEdit = ((wep instanceof WorldEditPlugin && wep.isEnabled()) ? ((WorldEditPlugin) wep) : null);
  121. this.registerConfiguration();
  122. this.registerCommands();
  123. this.registerManagers();
  124. this.registerListeners();
  125. Cooldowns.createCooldown("Assassin_item_cooldown");
  126. Cooldowns.createCooldown("Archer_item_cooldown");
  127. new BukkitRunnable() {
  128. public void run() {
  129. HCF.this.saveData();
  130. }
  131. }.runTaskTimerAsynchronously((Plugin) HCF.plugin, TimeUnit.SECONDS.toMillis(20L), TimeUnit.SECONDS.toMillis(20L));
  132. }
  133.  
  134. private void saveData() {
  135. this.deathbanManager.saveSoulLivesData();
  136. this.deathbanManager.saveDeathbanData();
  137. this.economyManager.saveEconomyData();
  138. this.factionManager.saveFactionData();
  139. this.hcfHandler.saveHCFSettings();
  140. this.keyManager.saveKeyData();
  141. this.userManager.saveUserData();
  142. }
  143.  
  144. public void onDisable() {
  145. CustomEntityRegistration.unregisterCustomEntities();
  146. CombatLogListener.removeCombatLoggers();
  147. this.pvpClassManager.onDisable();
  148. this.scoreboardHandler.clearBoards();
  149. saveData();
  150. HCF.plugin = null;
  151. }
  152.  
  153. private void registerConfiguration() {
  154. ConfigurationSerialization.registerClass(RefillBox.class);
  155. ConfigurationSerialization.registerClass(CaptureZone.class);
  156. ConfigurationSerialization.registerClass(Deathban.class);
  157. ConfigurationSerialization.registerClass(Claim.class);
  158. ConfigurationSerialization.registerClass(Subclaim.class);
  159. ConfigurationSerialization.registerClass(Deathban.class);
  160. ConfigurationSerialization.registerClass(FactionUser.class);
  161. ConfigurationSerialization.registerClass(ClaimableFaction.class);
  162. ConfigurationSerialization.registerClass(ConquestFaction.class);
  163. ConfigurationSerialization.registerClass(CapturableFaction.class);
  164. ConfigurationSerialization.registerClass(KothFaction.class);
  165. ConfigurationSerialization.registerClass(SandDuneFaction.class);
  166. ConfigurationSerialization.registerClass(EndPortalFaction.class);
  167. ConfigurationSerialization.registerClass(Faction.class);
  168. ConfigurationSerialization.registerClass(FactionMember.class);
  169. ConfigurationSerialization.registerClass(PlayerFaction.class);
  170. ConfigurationSerialization.registerClass(RoadFaction.class);
  171. ConfigurationSerialization.registerClass(SpawnFaction.class);
  172. ConfigurationSerialization.registerClass(RoadFaction.NorthRoadFaction.class);
  173. ConfigurationSerialization.registerClass(RoadFaction.EastRoadFaction.class);
  174. ConfigurationSerialization.registerClass(RoadFaction.SouthRoadFaction.class);
  175. ConfigurationSerialization.registerClass(RoadFaction.WestRoadFaction.class);
  176. }
  177.  
  178. private void registerListeners() {
  179. final PluginManager manager = this.getServer().getPluginManager();
  180. manager.registerEvents(new DonorOnlyListener(), this);
  181. manager.registerEvents(new ArcherClass(this), this);
  182. manager.registerEvents(new PortalTrapFixListener(), this);
  183. manager.registerEvents(new MOTDListener(), this);
  184. manager.registerEvents(new KeyListener(this), (Plugin) this);
  185. manager.registerEvents(new PexCrashFix(), this);
  186. manager.registerEvents(new WeatherFixListener(), this);
  187. manager.registerEvents(new NoPermissionClickListener(), this);
  188. manager.registerEvents(new AutoSmeltOreListener(), (Plugin) this);
  189. manager.registerEvents(new BlockHitFixListener(), (Plugin) this);
  190. manager.registerEvents(new BlockJumpGlitchFixListener(), (Plugin) this);
  191. manager.registerEvents(new BoatGlitchFixListener(), (Plugin) this);
  192. manager.registerEvents(new BookDeenchantListener(), (Plugin) this);
  193. manager.registerEvents(new BorderListener(), (Plugin) this);
  194. manager.registerEvents(new BottledExpListener(), (Plugin) this);
  195. manager.registerEvents(new ChatListener(this), (Plugin) this);
  196. manager.registerEvents(new ClaimWandListener(this), (Plugin) this);
  197. manager.registerEvents(new CombatLogListener(this), (Plugin) this);
  198. manager.registerEvents(new CoreListener(this), (Plugin) this);
  199. manager.registerEvents(new CrowbarListener(this), (Plugin) this);
  200. manager.registerEvents(new DeathListener(this), (Plugin) this);
  201. manager.registerEvents(new DeathMessageListener(this), (Plugin) this);
  202. manager.registerEvents(new DeathSignListener(this), (Plugin) this);
  203. manager.registerEvents(new DeathbanListener(this), (Plugin) this);
  204. manager.registerEvents(new EnchantLimitListener(), (Plugin) this);
  205. manager.registerEvents(new EnderChestRemovalListener(), (Plugin) this);
  206. manager.registerEvents(new EntityLimitListener(), (Plugin) this);
  207. manager.registerEvents(new FlatFileFactionManager(this), (Plugin) this);
  208. manager.registerEvents(new EndListener(), (Plugin) this);
  209. manager.registerEvents(new EotwListener(this), (Plugin) this);
  210. manager.registerEvents(new EventSignListener(), (Plugin) this);
  211. manager.registerEvents(new ExpMultiplierListener(), (Plugin) this);
  212. manager.registerEvents(new FactionListener(this), (Plugin) this);
  213. manager.registerEvents(new SandDuneFaction(), this);
  214. manager.registerEvents(new FoundDiamondsListener(this), (Plugin) this);
  215. manager.registerEvents(new FurnaceSmeltSpeederListener(), (Plugin) this);
  216. manager.registerEvents(new InfinityArrowFixListener(), (Plugin) this);
  217. manager.registerEvents(new KitListener(this), (Plugin) this);
  218. manager.registerEvents(new ItemStatTrackingListener(), this);
  219. manager.registerEvents(new KitMapListener(this), (Plugin) this);
  220. manager.registerEvents(new ServerSecurityListener(), this);
  221. manager.registerEvents(new PhaseListener(), this);
  222. manager.registerEvents(new HungerFixListener(), (Plugin) this);
  223. manager.registerEvents(new PotionLimitListener(), (Plugin) this);
  224. manager.registerEvents(new FactionsCoreListener(this), (Plugin) this);
  225. manager.registerEvents(new SignSubclaimListener(this), (Plugin) this);
  226. manager.registerEvents(new ShopSignListener(this), (Plugin) this);
  227. manager.registerEvents(new SkullListener(), (Plugin) this);
  228. manager.registerEvents(new BeaconStrengthFixListener(), (Plugin) this);
  229. manager.registerEvents(new VoidGlitchFixListener(), this);
  230. manager.registerEvents(new WallBorderListener(this), (Plugin) this);
  231. manager.registerEvents(new WorldListener(this), (Plugin) this);
  232. manager.registerEvents(new UnRepairableListener(), (Plugin) this);
  233.  
  234. }
  235.  
  236. private void registerCommands() {
  237. this.getCommand("toggleend").setExecutor(new ToggleEndCommand(this));
  238. this.getCommand("spawndragon").setExecutor(new EndDragonCommand(this));
  239. this.getCommand("sotw").setExecutor(new SOTWCommand());
  240. this.getCommand("random").setExecutor(new RandomCommand(this));
  241. this.getCommand("crowbar").setExecutor((CommandExecutor) new CrowbarCommand());
  242. this.getCommand("economy").setExecutor((CommandExecutor) new EconomyCommand(this));
  243. this.getCommand("eotw").setExecutor((CommandExecutor) new EotwCommand(this));
  244. this.getCommand("game").setExecutor((CommandExecutor) new EventExecutor(this));
  245. this.getCommand("help").setExecutor((CommandExecutor) new HelpCommand());
  246. this.getCommand("faction").setExecutor((CommandExecutor) new FactionExecutor(this));
  247. this.getCommand("gopple").setExecutor((CommandExecutor) new GoppleCommand(this));
  248. this.getCommand("stats").setExecutor(new PlayerStatsCommand());
  249. this.getCommand("koth").setExecutor((CommandExecutor) new KothExecutor(this));
  250. this.getCommand("stafflives").setExecutor((CommandExecutor) new LivesExecutor(this));
  251. this.getCommand("location").setExecutor((CommandExecutor) new LocationCommand(this));
  252. this.getCommand("logout").setExecutor((CommandExecutor) new LogoutCommand(this));
  253. this.getCommand("pay").setExecutor((CommandExecutor) new PayCommand(this));
  254. this.getCommand("pvptimer").setExecutor((CommandExecutor) new PvpTimerCommand(this));
  255. this.getCommand("refund").setExecutor( new RefundCommand());
  256. this.getCommand("servertime").setExecutor((CommandExecutor) new ServerTimeCommand());
  257. this.getCommand("spawn").setExecutor((CommandExecutor) new SpawnCommand(this));
  258. this.getCommand("timer").setExecutor((CommandExecutor) new TimerExecutor(this));
  259. this.getCommand("setborder").setExecutor((CommandExecutor) new SetBorderCommand());
  260. this.getCommand("key").setExecutor((CommandExecutor) new LootExecutor(this));
  261. final Map<String, Map<String, Object>> map = this.getDescription().getCommands();
  262. for(final Map.Entry<String, Map<String, Object>> entry : map.entrySet()) {
  263. final PluginCommand command = this.getCommand(entry.getKey());
  264. command.setPermission("command." + entry.getKey());
  265. command.setPermissionMessage(ChatColor.RED + "You do not have permission for this command.");
  266. }
  267. }
  268.  
  269. private void registerManagers() {
  270. this.claimHandler = new ClaimHandler(this);
  271. this.deathbanManager = new FlatFileDeathbanManager(this);
  272. this.economyManager = new FlatFileEconomyManager(this);
  273. this.eotwHandler = new EOTWHandler(this);
  274. this.eventScheduler = new EventScheduler(this);
  275. this.factionManager = new FlatFileFactionManager(this);
  276. this.pvpClassManager = new PvpClassManager(this);
  277. this.timerManager = new TimerManager(this);
  278. this.scoreboardHandler = new ScoreboardHandler(this);
  279. this.userManager = new UserManager(this);
  280. this.visualiseHandler = new VisualiseHandler();
  281. this.keyManager = new KeyManager(this);
  282. this.hcfHandler = new HCFHandler(this);
  283. this.message = new Message(this);
  284. }
  285.  
  286.  
  287. public Message getMessage(){
  288. return message;
  289. }
  290.  
  291.  
  292. public Random getRandom() {
  293. return this.random;
  294. }
  295.  
  296. public WorldEditPlugin getWorldEdit() {
  297. return this.worldEdit;
  298. }
  299.  
  300. public KeyManager getKeyManager() {
  301. return this.keyManager;
  302. }
  303.  
  304.  
  305. public ClaimHandler getClaimHandler() {
  306. return this.claimHandler;
  307. }
  308.  
  309. public DeathbanManager getDeathbanManager() {
  310. return this.deathbanManager;
  311. }
  312.  
  313. public EconomyManager getEconomyManager() {
  314. return this.economyManager;
  315. }
  316.  
  317. public EOTWHandler getEotwHandler() {
  318. return this.eotwHandler;
  319. }
  320.  
  321. public FactionManager getFactionManager() {
  322. return this.factionManager;
  323. }
  324.  
  325. public PvpClassManager getPvpClassManager() {
  326. return this.pvpClassManager;
  327. }
  328.  
  329. public ScoreboardHandler getScoreboardHandler() {
  330. return this.scoreboardHandler;
  331. }
  332.  
  333. public TimerManager getTimerManager() {
  334. return this.timerManager;
  335. }
  336.  
  337. public UserManager getUserManager() {
  338. return this.userManager;
  339. }
  340.  
  341. public VisualiseHandler getVisualiseHandler() {
  342. return this.visualiseHandler;
  343. }
  344.  
  345. public HCFHandler getHcfHandler(){
  346. return hcfHandler;
  347. }
  348.  
  349.  
  350. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement