Files
src
build.gradle
Code
17 1,723
src/main/java/com/infectedcore/InfectedCore.java
package com.infectedcore;
import com.infectedcore.commands.FactionCommand;
import com.infectedcore.commands.InfectedCommand;
import com.infectedcore.inventory.gui.GUIListener;
import com.infectedcore.inventory.gui.GUIManager;
import com.infectedcore.listeners.*;
import com.infectedcore.managers.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class InfectedCore extends JavaPlugin {
private ConfigManager configManager;
private InfectionManager infectionManager;
private ZombieManager zombieManager;
private NoiseManager noiseManager;
private AtmosphereManager atmosphereManager;
private LootManager lootManager;
private HordeManager hordeManager;
private BossManager bossManager;
private SafeZoneManager safeZoneManager;
private FactionManager factionManager;
private GUIManager guiManager;
@Override
public void onEnable() {
long startTime = System.currentTimeMillis();
getLogger().info("===========================================");
getLogger().info(" InfectedCore - Zombie Apocalypse");
getLogger().info(" Version: " + getDescription().getVersion());
getLogger().info("===========================================");
// Initialize managers
this.configManager = new ConfigManager(this);
this.configManager.loadConfigs();
this.infectionManager = new InfectionManager(this);
this.zombieManager = new ZombieManager(this);
this.noiseManager = new NoiseManager(this);
this.atmosphereManager = new AtmosphereManager(this);
this.lootManager = new LootManager(this);
this.hordeManager = new HordeManager(this);
this.bossManager = new BossManager(this);
this.safeZoneManager = new SafeZoneManager(this);
this.factionManager = new FactionManager(this);
this.guiManager = new GUIManager();
// Register listeners
registerListeners();
// Register commands
registerCommands();
// Start systems
this.infectionManager.startTask();
this.zombieManager.startTask();
this.noiseManager.startTask();
this.atmosphereManager.startTask();
this.hordeManager.startTask();
this.bossManager.startTask();
this.safeZoneManager.startTask();
long loadTime = System.currentTimeMillis() - startTime;
getLogger().info("Plugin enabled in " + loadTime + "ms");
getLogger().info("The apocalypse has begun...");
}
@Override
public void onDisable() {
getLogger().info("Saving data...");
// Stop all tasks
if (this.infectionManager != null) this.infectionManager.shutdown();
if (this.zombieManager != null) this.zombieManager.shutdown();
if (this.noiseManager != null) this.noiseManager.shutdown();
if (this.atmosphereManager != null) this.atmosphereManager.shutdown();
if (this.hordeManager != null) this.hordeManager.shutdown();
if (this.bossManager != null) this.bossManager.shutdown();
if (this.safeZoneManager != null) this.safeZoneManager.shutdown();
if (this.factionManager != null) this.factionManager.shutdown();
getLogger().info("InfectedCore disabled. Stay safe out there...");
}
private void registerListeners() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new InfectionListener(this), this);
pm.registerEvents(new ZombieListener(this), this);
pm.registerEvents(new NoiseListener(this), this);
pm.registerEvents(new PlayerListener(this), this);
pm.registerEvents(new WorldListener(this), this);
pm.registerEvents(new GUIListener(this.guiManager), this);
getLogger().info("Registered 6 event listeners");
}
private void registerCommands() {
getCommand("infected").setExecutor(new InfectedCommand(this));
getCommand("faction").setExecutor(new FactionCommand(this));
getLogger().info("Registered 2 commands");
}
public void reload() {
this.configManager.loadConfigs();
getLogger().info("Configuration reloaded!");
}
}