Files
src
build.gradle
manifest.kod
Code
24 1,614
src/main/java/com/lilysell/LilySell.java
package com.lilysell;
import com.lilysell.command.LilySellCommand;
import com.lilysell.command.SellAllCommand;
import com.lilysell.command.SellGUICommand;
import com.lilysell.command.SellHandCommand;
import com.lilysell.inventory.gui.GUIListener;
import com.lilysell.inventory.gui.GUIManager;
import com.lilysell.listener.InventoryListener;
import com.lilysell.listener.PlayerListener;
import com.lilysell.manager.ConfigManager;
import com.lilysell.manager.EconomyManager;
import com.lilysell.manager.PacketManager;
import com.lilysell.manager.PriceManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class LilySell extends JavaPlugin {
private ConfigManager configManager;
private PriceManager priceManager;
private EconomyManager economyManager;
private PacketManager packetManager;
private GUIManager guiManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.priceManager = new PriceManager(this);
this.economyManager = new EconomyManager(this);
this.packetManager = new PacketManager(this);
this.guiManager = new GUIManager();
if (!economyManager.setupEconomy()) {
getLogger().severe("Vault not found! Disabling plugin.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
priceManager.loadPrices();
packetManager.initialize();
registerCommands();
registerListeners();
getLogger().info("LilySell has been enabled!");
}
@Override
public void onDisable() {
if (packetManager != null) {
packetManager.shutdown();
}
getLogger().info("LilySell has been disabled!");
}
private void registerCommands() {
getCommand("sellhand").setExecutor(new SellHandCommand(this));
getCommand("sellall").setExecutor(new SellAllCommand(this));
getCommand("sellgui").setExecutor(new SellGUICommand(this));
getCommand("lilysell").setExecutor(new LilySellCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new InventoryListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
}
public void reload() {
reloadConfig();
configManager = new ConfigManager(this);
priceManager.loadPrices();
packetManager.refreshAllPlayers();
}
}