Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.customhcf.hcf;
- import com.customhcf.hcf.command.*;
- import com.customhcf.hcf.balance.EconomyManager;
- import com.customhcf.hcf.faction.type.*;
- import com.customhcf.hcf.key.KeyListener;
- import com.customhcf.hcf.key.KeyManager;
- import com.customhcf.hcf.key.LootExecutor;
- import com.customhcf.hcf.kothgame.*;
- import com.customhcf.hcf.kothgame.eotw.EOTWHandler;
- import com.customhcf.hcf.listener.*;
- import com.customhcf.hcf.fixes.*;
- import com.customhcf.hcf.classes.PvpClassManager;
- import com.customhcf.hcf.classes.type.archer.ArcherClass;
- import com.customhcf.hcf.user.FactionUser;
- import com.customhcf.hcf.deathban.Deathban;
- import com.customhcf.hcf.deathban.DeathbanListener;
- import com.customhcf.hcf.deathban.DeathbanManager;
- import com.customhcf.hcf.deathban.FlatFileDeathbanManager;
- import com.customhcf.hcf.lives.LivesExecutor;
- import com.customhcf.hcf.balance.EconomyCommand;
- import com.customhcf.hcf.balance.FlatFileEconomyManager;
- import com.customhcf.hcf.balance.PayCommand;
- import com.customhcf.hcf.balance.ShopSignListener;
- import com.customhcf.hcf.kothgame.eotw.EotwCommand;
- import com.customhcf.hcf.kothgame.eotw.EotwListener;
- import com.customhcf.hcf.kothgame.faction.CapturableFaction;
- import com.customhcf.hcf.kothgame.faction.ConquestFaction;
- import com.customhcf.hcf.kothgame.faction.KothFaction;
- import com.customhcf.hcf.kothgame.koth.KothExecutor;
- import com.customhcf.hcf.faction.FactionExecutor;
- import com.customhcf.hcf.faction.FactionManager;
- import com.customhcf.hcf.faction.FactionMember;
- import com.customhcf.hcf.faction.FlatFileFactionManager;
- import com.customhcf.hcf.faction.claim.Claim;
- import com.customhcf.hcf.faction.claim.ClaimHandler;
- import com.customhcf.hcf.faction.claim.ClaimWandListener;
- import com.customhcf.hcf.faction.claim.Subclaim;
- import com.customhcf.hcf.scoreboard.ScoreboardHandler;
- import com.customhcf.hcf.timer.TimerExecutor;
- import com.customhcf.hcf.timer.TimerManager;
- import com.customhcf.hcf.user.UserManager;
- import com.customhcf.hcf.visualise.ProtocolLibHook;
- import com.customhcf.hcf.visualise.VisualiseHandler;
- import com.customhcf.hcf.visualise.WallBorderListener;
- import com.customhcf.hcf.combatlog.CombatLogListener;
- import com.customhcf.hcf.combatlog.CustomEntityRegistration;
- import com.sk89q.worldedit.bukkit.WorldEditPlugin;
- import org.apache.commons.lang3.time.DurationFormatUtils;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.PluginCommand;
- import org.bukkit.configuration.serialization.ConfigurationSerialization;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitRunnable;
- import java.util.Map;
- import java.util.Random;
- import java.util.concurrent.TimeUnit;
- public class HCF extends JavaPlugin {
- private static final long MINUTE;
- private static final long HOUR;
- private static HCF plugin;
- static {
- MINUTE = TimeUnit.MINUTES.toMillis(1L);
- HOUR = TimeUnit.HOURS.toMillis(1L);
- }
- private Message message;
- public EventScheduler eventScheduler;
- private Random random;
- private HCFHandler hcfHandler;
- private WorldEditPlugin worldEdit;
- private ClaimHandler claimHandler;
- private KeyManager keyManager;
- private DeathbanManager deathbanManager;
- private EconomyManager economyManager;
- private EOTWHandler eotwHandler;
- private FactionManager factionManager;
- private PvpClassManager pvpClassManager;
- private ScoreboardHandler scoreboardHandler;
- private TimerManager timerManager;
- private UserManager userManager;
- private VisualiseHandler visualiseHandler;
- public HCF() {
- this.random = new Random();
- }
- public static HCF getPlugin() {
- return HCF.plugin;
- }
- public static String getReaming(final long millis){
- return getRemaining(millis, true, true);
- }
- public static String getRemaining(final long millis, final boolean milliseconds) {
- return getRemaining(millis, milliseconds, true);
- }
- public static String getRemaining(final long duration, final boolean milliseconds, final boolean trail) {
- if(milliseconds && duration < HCF.MINUTE) {
- return (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get().format(duration * 0.001) + 's';
- }
- return DurationFormatUtils.formatDuration(duration, ((duration >= HCF.HOUR) ? "HH:" : "") + "mm:ss");
- }
- public void onEnable() {
- HCF.plugin = this;
- CustomEntityRegistration.registerCustomEntities();
- ProtocolLibHook.hook(this);
- final Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
- this.worldEdit = ((wep instanceof WorldEditPlugin && wep.isEnabled()) ? ((WorldEditPlugin) wep) : null);
- this.registerConfiguration();
- this.registerCommands();
- this.registerManagers();
- this.registerListeners();
- Cooldowns.createCooldown("Assassin_item_cooldown");
- Cooldowns.createCooldown("Archer_item_cooldown");
- new BukkitRunnable() {
- public void run() {
- HCF.this.saveData();
- }
- }.runTaskTimerAsynchronously((Plugin) HCF.plugin, TimeUnit.SECONDS.toMillis(20L), TimeUnit.SECONDS.toMillis(20L));
- }
- private void saveData() {
- this.deathbanManager.saveSoulLivesData();
- this.deathbanManager.saveDeathbanData();
- this.economyManager.saveEconomyData();
- this.factionManager.saveFactionData();
- this.hcfHandler.saveHCFSettings();
- this.keyManager.saveKeyData();
- this.userManager.saveUserData();
- }
- public void onDisable() {
- CustomEntityRegistration.unregisterCustomEntities();
- CombatLogListener.removeCombatLoggers();
- this.pvpClassManager.onDisable();
- this.scoreboardHandler.clearBoards();
- saveData();
- HCF.plugin = null;
- }
- private void registerConfiguration() {
- ConfigurationSerialization.registerClass(RefillBox.class);
- ConfigurationSerialization.registerClass(CaptureZone.class);
- ConfigurationSerialization.registerClass(Deathban.class);
- ConfigurationSerialization.registerClass(Claim.class);
- ConfigurationSerialization.registerClass(Subclaim.class);
- ConfigurationSerialization.registerClass(Deathban.class);
- ConfigurationSerialization.registerClass(FactionUser.class);
- ConfigurationSerialization.registerClass(ClaimableFaction.class);
- ConfigurationSerialization.registerClass(ConquestFaction.class);
- ConfigurationSerialization.registerClass(CapturableFaction.class);
- ConfigurationSerialization.registerClass(KothFaction.class);
- ConfigurationSerialization.registerClass(SandDuneFaction.class);
- ConfigurationSerialization.registerClass(EndPortalFaction.class);
- ConfigurationSerialization.registerClass(Faction.class);
- ConfigurationSerialization.registerClass(FactionMember.class);
- ConfigurationSerialization.registerClass(PlayerFaction.class);
- ConfigurationSerialization.registerClass(RoadFaction.class);
- ConfigurationSerialization.registerClass(SpawnFaction.class);
- ConfigurationSerialization.registerClass(RoadFaction.NorthRoadFaction.class);
- ConfigurationSerialization.registerClass(RoadFaction.EastRoadFaction.class);
- ConfigurationSerialization.registerClass(RoadFaction.SouthRoadFaction.class);
- ConfigurationSerialization.registerClass(RoadFaction.WestRoadFaction.class);
- }
- private void registerListeners() {
- final PluginManager manager = this.getServer().getPluginManager();
- manager.registerEvents(new DonorOnlyListener(), this);
- manager.registerEvents(new ArcherClass(this), this);
- manager.registerEvents(new PortalTrapFixListener(), this);
- manager.registerEvents(new MOTDListener(), this);
- manager.registerEvents(new KeyListener(this), (Plugin) this);
- manager.registerEvents(new PexCrashFix(), this);
- manager.registerEvents(new WeatherFixListener(), this);
- manager.registerEvents(new NoPermissionClickListener(), this);
- manager.registerEvents(new AutoSmeltOreListener(), (Plugin) this);
- manager.registerEvents(new BlockHitFixListener(), (Plugin) this);
- manager.registerEvents(new BlockJumpGlitchFixListener(), (Plugin) this);
- manager.registerEvents(new BoatGlitchFixListener(), (Plugin) this);
- manager.registerEvents(new BookDeenchantListener(), (Plugin) this);
- manager.registerEvents(new BorderListener(), (Plugin) this);
- manager.registerEvents(new BottledExpListener(), (Plugin) this);
- manager.registerEvents(new ChatListener(this), (Plugin) this);
- manager.registerEvents(new ClaimWandListener(this), (Plugin) this);
- manager.registerEvents(new CombatLogListener(this), (Plugin) this);
- manager.registerEvents(new CoreListener(this), (Plugin) this);
- manager.registerEvents(new CrowbarListener(this), (Plugin) this);
- manager.registerEvents(new DeathListener(this), (Plugin) this);
- manager.registerEvents(new DeathMessageListener(this), (Plugin) this);
- manager.registerEvents(new DeathSignListener(this), (Plugin) this);
- manager.registerEvents(new DeathbanListener(this), (Plugin) this);
- manager.registerEvents(new EnchantLimitListener(), (Plugin) this);
- manager.registerEvents(new EnderChestRemovalListener(), (Plugin) this);
- manager.registerEvents(new EntityLimitListener(), (Plugin) this);
- manager.registerEvents(new FlatFileFactionManager(this), (Plugin) this);
- manager.registerEvents(new EndListener(), (Plugin) this);
- manager.registerEvents(new EotwListener(this), (Plugin) this);
- manager.registerEvents(new EventSignListener(), (Plugin) this);
- manager.registerEvents(new ExpMultiplierListener(), (Plugin) this);
- manager.registerEvents(new FactionListener(this), (Plugin) this);
- manager.registerEvents(new SandDuneFaction(), this);
- manager.registerEvents(new FoundDiamondsListener(this), (Plugin) this);
- manager.registerEvents(new FurnaceSmeltSpeederListener(), (Plugin) this);
- manager.registerEvents(new InfinityArrowFixListener(), (Plugin) this);
- manager.registerEvents(new KitListener(this), (Plugin) this);
- manager.registerEvents(new ItemStatTrackingListener(), this);
- manager.registerEvents(new KitMapListener(this), (Plugin) this);
- manager.registerEvents(new ServerSecurityListener(), this);
- manager.registerEvents(new PhaseListener(), this);
- manager.registerEvents(new HungerFixListener(), (Plugin) this);
- manager.registerEvents(new PotionLimitListener(), (Plugin) this);
- manager.registerEvents(new FactionsCoreListener(this), (Plugin) this);
- manager.registerEvents(new SignSubclaimListener(this), (Plugin) this);
- manager.registerEvents(new ShopSignListener(this), (Plugin) this);
- manager.registerEvents(new SkullListener(), (Plugin) this);
- manager.registerEvents(new BeaconStrengthFixListener(), (Plugin) this);
- manager.registerEvents(new VoidGlitchFixListener(), this);
- manager.registerEvents(new WallBorderListener(this), (Plugin) this);
- manager.registerEvents(new WorldListener(this), (Plugin) this);
- manager.registerEvents(new UnRepairableListener(), (Plugin) this);
- }
- private void registerCommands() {
- this.getCommand("toggleend").setExecutor(new ToggleEndCommand(this));
- this.getCommand("spawndragon").setExecutor(new EndDragonCommand(this));
- this.getCommand("sotw").setExecutor(new SOTWCommand());
- this.getCommand("random").setExecutor(new RandomCommand(this));
- this.getCommand("crowbar").setExecutor((CommandExecutor) new CrowbarCommand());
- this.getCommand("economy").setExecutor((CommandExecutor) new EconomyCommand(this));
- this.getCommand("eotw").setExecutor((CommandExecutor) new EotwCommand(this));
- this.getCommand("game").setExecutor((CommandExecutor) new EventExecutor(this));
- this.getCommand("help").setExecutor((CommandExecutor) new HelpCommand());
- this.getCommand("faction").setExecutor((CommandExecutor) new FactionExecutor(this));
- this.getCommand("gopple").setExecutor((CommandExecutor) new GoppleCommand(this));
- this.getCommand("stats").setExecutor(new PlayerStatsCommand());
- this.getCommand("koth").setExecutor((CommandExecutor) new KothExecutor(this));
- this.getCommand("stafflives").setExecutor((CommandExecutor) new LivesExecutor(this));
- this.getCommand("location").setExecutor((CommandExecutor) new LocationCommand(this));
- this.getCommand("logout").setExecutor((CommandExecutor) new LogoutCommand(this));
- this.getCommand("pay").setExecutor((CommandExecutor) new PayCommand(this));
- this.getCommand("pvptimer").setExecutor((CommandExecutor) new PvpTimerCommand(this));
- this.getCommand("refund").setExecutor( new RefundCommand());
- this.getCommand("servertime").setExecutor((CommandExecutor) new ServerTimeCommand());
- this.getCommand("spawn").setExecutor((CommandExecutor) new SpawnCommand(this));
- this.getCommand("timer").setExecutor((CommandExecutor) new TimerExecutor(this));
- this.getCommand("setborder").setExecutor((CommandExecutor) new SetBorderCommand());
- this.getCommand("key").setExecutor((CommandExecutor) new LootExecutor(this));
- final Map<String, Map<String, Object>> map = this.getDescription().getCommands();
- for(final Map.Entry<String, Map<String, Object>> entry : map.entrySet()) {
- final PluginCommand command = this.getCommand(entry.getKey());
- command.setPermission("command." + entry.getKey());
- command.setPermissionMessage(ChatColor.RED + "You do not have permission for this command.");
- }
- }
- private void registerManagers() {
- this.claimHandler = new ClaimHandler(this);
- this.deathbanManager = new FlatFileDeathbanManager(this);
- this.economyManager = new FlatFileEconomyManager(this);
- this.eotwHandler = new EOTWHandler(this);
- this.eventScheduler = new EventScheduler(this);
- this.factionManager = new FlatFileFactionManager(this);
- this.pvpClassManager = new PvpClassManager(this);
- this.timerManager = new TimerManager(this);
- this.scoreboardHandler = new ScoreboardHandler(this);
- this.userManager = new UserManager(this);
- this.visualiseHandler = new VisualiseHandler();
- this.keyManager = new KeyManager(this);
- this.hcfHandler = new HCFHandler(this);
- this.message = new Message(this);
- }
- public Message getMessage(){
- return message;
- }
- public Random getRandom() {
- return this.random;
- }
- public WorldEditPlugin getWorldEdit() {
- return this.worldEdit;
- }
- public KeyManager getKeyManager() {
- return this.keyManager;
- }
- public ClaimHandler getClaimHandler() {
- return this.claimHandler;
- }
- public DeathbanManager getDeathbanManager() {
- return this.deathbanManager;
- }
- public EconomyManager getEconomyManager() {
- return this.economyManager;
- }
- public EOTWHandler getEotwHandler() {
- return this.eotwHandler;
- }
- public FactionManager getFactionManager() {
- return this.factionManager;
- }
- public PvpClassManager getPvpClassManager() {
- return this.pvpClassManager;
- }
- public ScoreboardHandler getScoreboardHandler() {
- return this.scoreboardHandler;
- }
- public TimerManager getTimerManager() {
- return this.timerManager;
- }
- public UserManager getUserManager() {
- return this.userManager;
- }
- public VisualiseHandler getVisualiseHandler() {
- return this.visualiseHandler;
- }
- public HCFHandler getHcfHandler(){
- return hcfHandler;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement