Files
src
build.gradle
manifest.kod
Code
38 2,681
src/main/java/com/ghostbound/GhostBound.java
package com.ghostbound;
import com.ghostbound.commands.*;
import com.ghostbound.config.ConfigManager;
import com.ghostbound.integration.DiscordSRVIntegration;
import com.ghostbound.integration.PlaceholderIntegration;
import com.ghostbound.inventory.gui.GUIListener;
import com.ghostbound.inventory.gui.GUIManager;
import com.ghostbound.items.SpiritFragment;
import com.ghostbound.listeners.*;
import com.ghostbound.managers.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class GhostBound extends JavaPlugin {
@Getter private static GhostBound instance;
@Getter private ConfigManager configManager;
@Getter private DatabaseManager databaseManager;
@Getter private SocietyManager societyManager;
@Getter private BloodMoonManager bloodMoonManager;
@Getter private RevivalManager revivalManager;
@Getter private AltarManager altarManager;
@Getter private RuinManager ruinManager;
@Getter private GUIManager guiManager;
@Getter private DiscordSRVIntegration discordSRVIntegration;
@Override
public void onEnable() {
instance = this;
saveDefaultConfig();
configManager = new ConfigManager(this);
SpiritFragment.init(this);
databaseManager = new DatabaseManager(this);
databaseManager.initialize();
societyManager = new SocietyManager(this);
altarManager = new AltarManager(this);
revivalManager = new RevivalManager(this);
bloodMoonManager = new BloodMoonManager(this);
ruinManager = new RuinManager(this);
guiManager = new GUIManager();
registerListeners();
registerCommands();
registerIntegrations();
bloodMoonManager.startBloodMoonTask();
getLogger().info("GhostBound SMP enabled. Two Societies. One World. Death Is Only The Beginning.");
}
@Override
public void onDisable() {
if (bloodMoonManager != null) bloodMoonManager.stop();
if (societyManager != null) {
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
societyManager.saveAndUnloadPlayer(player);
}
}
getLogger().info("GhostBound SMP disabled.");
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new PlayerJoinQuitListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerDeathListener(this), this);
Bukkit.getPluginManager().registerEvents(new GhostRestrictionListener(this), this);
Bukkit.getPluginManager().registerEvents(new BloodMoonDropListener(this), this);
Bukkit.getPluginManager().registerEvents(new PhaseWalkListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new org.bukkit.event.Listener() {
@org.bukkit.event.EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
ruinManager.handleChunkLoad(event);
}
}, this);
}
private void registerCommands() {
getCommand("human").setExecutor(new HumanCommand(this));
getCommand("ghost").setExecutor(new GhostCommand(this));
getCommand("gchat").setExecutor(new GChatCommand(this));
getCommand("haunt").setExecutor(new HauntCommand(this));
getCommand("spectralvision").setExecutor(new SpectralVisionCommand(this));
getCommand("phasewalk").setExecutor(new PhaseWalkCommand(this));
getCommand("ghostaltar").setExecutor(new GhostAltarCommand(this));
getCommand("ghostbound").setExecutor(new GhostBoundCommand(this));
}
private void registerIntegrations() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderIntegration(this).register();
getLogger().info("PlaceholderAPI integration registered.");
}
if (Bukkit.getPluginManager().getPlugin("DiscordSRV") != null) {
discordSRVIntegration = new DiscordSRVIntegration(this);
discordSRVIntegration.hook();
}
}
}