Files
src
build.gradle
Code
38 2,537
src/main/java/com/kodari/customcrates/CustomCrates.java
package com.kodari.customcrates;
import com.kodari.customcrates.command.CrateCommand;
import com.kodari.customcrates.config.ConfigManager;
import com.kodari.customcrates.crate.AnimationManager;
import com.kodari.customcrates.crate.CrateBlockManager;
import com.kodari.customcrates.crate.CrateManager;
import com.kodari.customcrates.crate.KeyManager;
import com.kodari.customcrates.crate.RewardManager;
import com.kodari.customcrates.hook.CoinsEngineHook;
import com.kodari.customcrates.hook.LifestealHook;
import com.kodari.customcrates.hook.LuckPermsHook;
import com.kodari.customcrates.hook.PlaceholderHook;
import com.kodari.customcrates.hook.VaultHook;
import com.kodari.customcrates.inventory.gui.GUIListener;
import com.kodari.customcrates.inventory.gui.GUIManager;
import com.kodari.customcrates.item.CrateKeyItem;
import com.kodari.customcrates.item.CustomItemManager;
import com.kodari.customcrates.listener.CrateBlockListener;
import com.kodari.customcrates.listener.CustomItemListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class CustomCrates extends JavaPlugin {
private ConfigManager configManager;
private CrateManager crateManager;
private KeyManager keyManager;
private CrateBlockManager crateBlockManager;
private CustomItemManager customItemManager;
private CrateKeyItem crateKeyItem;
private GUIManager guiManager;
private RewardManager rewardManager;
private AnimationManager animationManager;
private VaultHook vaultHook;
private CoinsEngineHook coinsEngineHook;
private LuckPermsHook luckPermsHook;
private LifestealHook lifestealHook;
private PlaceholderHook placeholderHook;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.configManager.loadAll();
this.crateManager = new CrateManager(this);
this.crateManager.loadCrates();
this.keyManager = new KeyManager(this);
this.keyManager.load();
this.crateBlockManager = new CrateBlockManager(this);
this.crateBlockManager.load();
this.customItemManager = new CustomItemManager(this);
this.crateKeyItem = new CrateKeyItem(this);
this.rewardManager = new RewardManager(this);
this.animationManager = new AnimationManager(this);
this.vaultHook = new VaultHook();
this.coinsEngineHook = new CoinsEngineHook();
this.luckPermsHook = new LuckPermsHook();
this.lifestealHook = new LifestealHook(this);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
this.placeholderHook = new PlaceholderHook(this);
this.placeholderHook.register();
}
this.guiManager = new GUIManager();
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new CrateBlockListener(this), this);
Bukkit.getPluginManager().registerEvents(new CustomItemListener(this), this);
CrateCommand crateCommand = new CrateCommand(this);
getCommand("crate").setExecutor(crateCommand);
getCommand("crate").setTabCompleter(crateCommand);
getLogger().info("CustomCrates has been enabled.");
}
@Override
public void onDisable() {
if (keyManager != null) keyManager.save();
if (crateBlockManager != null) crateBlockManager.save();
if (crateManager != null) crateManager.saveCrates();
getLogger().info("CustomCrates has been disabled.");
}
}