Files
src
build.gradle
Code
44 2,370
src/main/java/com/apocalypticprogression/ApocalypticProgression.java
package com.apocalypticprogression;
import com.apocalypticprogression.commands.ApocalypseCommand;
import com.apocalypticprogression.commands.ClassCommand;
import com.apocalypticprogression.commands.StatsCommand;
import com.apocalypticprogression.data.PlayerDataManager;
import com.apocalypticprogression.environment.CorruptionManager;
import com.apocalypticprogression.environment.VillageDecayManager;
import com.apocalypticprogression.environment.WeatherManager;
import com.apocalypticprogression.events.EventManager;
import com.apocalypticprogression.listeners.*;
import com.apocalypticprogression.managers.ConfigManager;
import com.apocalypticprogression.mobs.BossManager;
import com.apocalypticprogression.mobs.EliteManager;
import com.apocalypticprogression.mobs.MobEvolutionManager;
import com.apocalypticprogression.progression.DayProgressionManager;
import com.apocalypticprogression.progression.MilestoneManager;
import com.apocalypticprogression.rpg.ClassManager;
import com.apocalypticprogression.rpg.LevelingManager;
import com.apocalypticprogression.rpg.LootManager;
import com.apocalypticprogression.rpg.SkillManager;
import com.apocalypticprogression.survival.DarknessManager;
import com.apocalypticprogression.survival.InjuryManager;
import com.apocalypticprogression.survival.StaminaManager;
import com.apocalypticprogression.survival.TemperatureManager;
import com.apocalypticprogression.survival.ThirstManager;
import com.apocalypticprogression.util.MessageUtil;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class ApocalypticProgression extends JavaPlugin {
@Getter
private static ApocalypticProgression instance;
private ConfigManager configManager;
private PlayerDataManager playerDataManager;
private DayProgressionManager dayProgressionManager;
private MilestoneManager milestoneManager;
private MobEvolutionManager mobEvolutionManager;
private EliteManager eliteManager;
private BossManager bossManager;
private CorruptionManager corruptionManager;
private VillageDecayManager villageDecayManager;
private WeatherManager weatherManager;
private EventManager eventManager;
private TemperatureManager temperatureManager;
private ThirstManager thirstManager;
private InjuryManager injuryManager;
private DarknessManager darknessManager;
private StaminaManager staminaManager;
private ClassManager classManager;
private LevelingManager levelingManager;
private SkillManager skillManager;
private LootManager lootManager;
@Override
public void onEnable() {
instance = this;
long startTime = System.currentTimeMillis();
getLogger().info("=================================");
getLogger().info(" APOCALYPTIC PROGRESSION v1.0");
getLogger().info("=================================");
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.playerDataManager = new PlayerDataManager(this);
initializeManagers();
registerListeners();
registerCommands();
long loadTime = System.currentTimeMillis() - startTime;
getLogger().info("Loaded successfully in " + loadTime + "ms");
getLogger().info("The apocalypse has begun...");
}
@Override
public void onDisable() {
getLogger().info("Saving player data...");
playerDataManager.saveAll();
if (dayProgressionManager != null) {
dayProgressionManager.shutdown();
}
if (temperatureManager != null) {
temperatureManager.shutdown();
}
if (thirstManager != null) {
thirstManager.shutdown();
}
if (staminaManager != null) {
staminaManager.shutdown();
}
if (eventManager != null) {
eventManager.shutdown();
}
getLogger().info("Apocalyptic Progression disabled.");
}
private void initializeManagers() {
getLogger().info("Initializing managers...");
this.dayProgressionManager = new DayProgressionManager(this);
this.milestoneManager = new MilestoneManager(this);
this.mobEvolutionManager = new MobEvolutionManager(this);
this.eliteManager = new EliteManager(this);
this.bossManager = new BossManager(this);
this.corruptionManager = new CorruptionManager(this);
this.villageDecayManager = new VillageDecayManager(this);
this.weatherManager = new WeatherManager(this);
this.eventManager = new EventManager(this);
this.temperatureManager = new TemperatureManager(this);
this.thirstManager = new ThirstManager(this);
this.injuryManager = new InjuryManager(this);
this.darknessManager = new DarknessManager(this);
this.staminaManager = new StaminaManager(this);
this.classManager = new ClassManager(this);
this.levelingManager = new LevelingManager(this);
this.skillManager = new SkillManager(this);
this.lootManager = new LootManager(this);
dayProgressionManager.start();
temperatureManager.start();
thirstManager.start();
staminaManager.start();
eventManager.start();
}
private void registerListeners() {
getLogger().info("Registering listeners...");
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerJoinListener(this), this);
pm.registerEvents(new PlayerQuitListener(this), this);
pm.registerEvents(new PlayerDeathListener(this), this);
pm.registerEvents(new MobSpawnListener(this), this);
pm.registerEvents(new MobDamageListener(this), this);
pm.registerEvents(new MobDeathListener(this), this);
pm.registerEvents(new BlockBreakListener(this), this);
pm.registerEvents(new PlayerMoveListener(this), this);
pm.registerEvents(new PlayerInteractListener(this), this);
pm.registerEvents(new EntityDamageListener(this), this);
pm.registerEvents(new FoodLevelChangeListener(this), this);
pm.registerEvents(new WeatherChangeListener(this), this);
}
private void registerCommands() {
getLogger().info("Registering commands...");
getCommand("apocalypse").setExecutor(new ApocalypseCommand(this));
getCommand("stats").setExecutor(new StatsCommand(this));
getCommand("class").setExecutor(new ClassCommand(this));
}
public void reload() {
reloadConfig();
configManager = new ConfigManager(this);
MessageUtil.broadcast("&aApocalyptic Progression reloaded!");
}
}