Files
src
pom.xml
Code
38 2,408
src/main/java/com/celestialsmp/plugin/CelestialSMP.java
package com.celestialsmp.plugin;
import com.celestialsmp.plugin.command.*;
import com.celestialsmp.plugin.cycle.ZodiacCycleManager;
import com.celestialsmp.plugin.inventory.gui.GUIListener;
import com.celestialsmp.plugin.inventory.gui.GUIManager;
import com.celestialsmp.plugin.listener.PlayerJoinListener;
import com.celestialsmp.plugin.placeholder.ZodiacPlaceholder;
import com.celestialsmp.plugin.player.DataManager;
import com.celestialsmp.plugin.shop.ShopManager;
import com.celestialsmp.plugin.skill.SkillListener;
import com.celestialsmp.plugin.skill.SkillManager;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class CelestialSMP extends JavaPlugin {
private DataManager dataManager;
private ZodiacCycleManager cycleManager;
private SkillManager skillManager;
private ShopManager shopManager;
private GUIManager guiManager;
private Economy economy;
@Override
public void onEnable() {
saveDefaultConfig();
this.dataManager = new DataManager(this);
this.cycleManager = new ZodiacCycleManager(this);
this.skillManager = new SkillManager(this);
this.shopManager = new ShopManager(this);
this.guiManager = new GUIManager();
setupEconomy();
registerCommands();
registerListeners();
registerPlaceholders();
getLogger().info("CelestialSMP has been enabled!");
}
@Override
public void onDisable() {
if (dataManager != null) {
dataManager.saveData();
}
getLogger().info("CelestialSMP has been disabled!");
}
private void setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
getLogger().warning("Vault not found! Economy features will not work.");
return;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
getLogger().warning("Economy provider not found! Shop features will not work.");
return;
}
economy = rsp.getProvider();
getLogger().info("Hooked into Vault Economy!");
}
private void registerCommands() {
getCommand("zodiacsign").setExecutor(new ZodiacSignCommand(this));
getCommand("list").setExecutor(new ListCommand(this));
getCommand("stock").setExecutor(new StockCommand(this));
getCommand("restock").setExecutor(new RestockCommand(this));
SetZodiacSignCommand setZodiacCmd = new SetZodiacSignCommand(this);
getCommand("setzodiacsign").setExecutor(setZodiacCmd);
getCommand("setzodiacsign").setTabCompleter(setZodiacCmd);
getCommand("zodiaclib").setExecutor(new ZodiacLibCommand(this));
getCommand("celestialhelp").setExecutor(new HelpCommand());
getCommand("adminhelp").setExecutor(new AdminHelpCommand());
getCommand("status").setExecutor(new StatusCommand(this));
getCommand("lockskill").setExecutor(new LockSkillCommand(this));
getCommand("day").setExecutor(new DayCommand(this));
getCommand("night").setExecutor(new NightCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new SkillListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Bukkit.getPluginManager().registerEvents(new com.celestialsmp.plugin.listener.SkillDamageListener(this), this);
}
private void registerPlaceholders() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new ZodiacPlaceholder(this).register();
getLogger().info("Registered PlaceholderAPI expansion!");
}
}
public DataManager getDataManager() {
return dataManager;
}
public ZodiacCycleManager getCycleManager() {
return cycleManager;
}
public SkillManager getSkillManager() {
return skillManager;
}
public ShopManager getShopManager() {
return shopManager;
}
public GUIManager getGuiManager() {
return guiManager;
}
public Economy getEconomy() {
return economy;
}
}