Files
src
build.gradle
settings.gradle
Code
45 3,002
src/main/java/com/github/nyxcrates/NyxCrates.java
package com.github.nyxcrates;
import com.github.nyxcrates.command.NCRCommand;
import com.github.nyxcrates.hook.PlaceholderAPIHook;
import com.github.nyxcrates.inventory.gui.GUIListener;
import com.github.nyxcrates.inventory.gui.GUIManager;
import com.github.nyxcrates.listener.BlockBreakListener;
import com.github.nyxcrates.listener.BlockPlaceListener;
import com.github.nyxcrates.listener.PlayerInteractListener;
import com.github.nyxcrates.listener.PlayerMoveListener;
import com.github.nyxcrates.listener.PlayerQuitListener;
import com.github.nyxcrates.manager.AnimationManager;
import com.github.nyxcrates.manager.ConfigManager;
import com.github.nyxcrates.manager.CrateManager;
import com.github.nyxcrates.manager.DataManager;
import com.github.nyxcrates.manager.HologramManager;
import com.github.nyxcrates.manager.KeyManager;
import com.github.nyxcrates.manager.ParticleManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class NyxCrates extends JavaPlugin {
private ConfigManager configManager;
private DataManager dataManager;
private CrateManager crateManager;
private KeyManager keyManager;
private GUIManager guiManager;
private AnimationManager animationManager;
private HologramManager hologramManager;
private ParticleManager particleManager;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
this.dataManager = new DataManager(this);
this.crateManager = new CrateManager(this);
this.keyManager = new KeyManager(this);
this.guiManager = new GUIManager();
this.animationManager = new AnimationManager(this);
this.hologramManager = new HologramManager(this);
this.particleManager = new ParticleManager(this);
configManager.loadConfigs();
crateManager.loadCrates();
keyManager.loadKeys();
dataManager.loadData();
registerCommands();
registerListeners();
registerHooks();
getLogger().info("NyxCrates has been enabled!");
}
@Override
public void onDisable() {
if (animationManager != null) {
animationManager.cancelAll();
}
if (hologramManager != null) {
hologramManager.removeAll();
}
if (particleManager != null) {
particleManager.stopParticleTask();
}
if (dataManager != null) {
dataManager.saveData();
}
getLogger().info("NyxCrates has been disabled!");
}
public void reload() {
configManager.loadConfigs();
crateManager.loadCrates();
keyManager.loadKeys();
dataManager.loadData();
hologramManager.reloadAll();
}
private void registerCommands() {
getCommand("ncr").setExecutor(new NCRCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new BlockPlaceListener(this), this);
Bukkit.getPluginManager().registerEvents(new BlockBreakListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerInteractListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerMoveListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerQuitListener(this), this);
}
private void registerHooks() {
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new PlaceholderAPIHook(this).register();
getLogger().info("PlaceholderAPI hook registered!");
}
}
}