Files
src
build.gradle
settings.gradle
Code
17 1,051
src/main/java/com/categoryshop/CategoryShop.java
package com.categoryshop;
import com.categoryshop.command.ShopCommand;
import com.categoryshop.inventory.gui.GUIListener;
import com.categoryshop.inventory.gui.GUIManager;
import com.categoryshop.manager.ShopManager;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class CategoryShop extends JavaPlugin {
private GUIManager guiManager;
private ShopManager shopManager;
private Economy economy;
@Override
public void onEnable() {
saveDefaultConfig();
if (!setupEconomy()) {
getLogger().severe("Vault or an economy plugin was not found. Disabling CategoryShop.");
getServer().getPluginManager().disablePlugin(this);
return;
}
this.guiManager = new GUIManager();
this.shopManager = new ShopManager(this);
this.shopManager.load();
getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
getCommand("shop").setExecutor(new ShopCommand(this));
}
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
this.economy = rsp.getProvider();
return this.economy != null;
}
}