Files
src
pom.xml
Code
31 2,046
src/main/java/com/novagui/shop/NovaGUIPlugin.java
package com.novagui.shop;
import com.novagui.shop.command.ShopCommand;
import com.novagui.shop.config.ConfigService;
import com.novagui.shop.economy.EconomyService;
import com.novagui.shop.gui.GuiListener;
import com.novagui.shop.gui.GuiManager;
import com.novagui.shop.item.ItemFactory;
import com.novagui.shop.message.MessageService;
import com.novagui.shop.purchase.PurchaseService;
import com.novagui.shop.sound.SoundService;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public final class NovaGUIPlugin extends JavaPlugin {
private ConfigService configService;
private EconomyService economyService;
private MessageService messageService;
private SoundService soundService;
private ItemFactory itemFactory;
private PurchaseService purchaseService;
private GuiManager guiManager;
@Override
public void onEnable() {
this.configService = new ConfigService(this);
this.configService.load();
RegisteredServiceProvider<Economy> registration =
Bukkit.getServicesManager().getRegistration(Economy.class);
if (registration == null || registration.getProvider() == null) {
getLogger().severe("Vault economy provider was not found. NovaGUI Shop is disabling.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.economyService = new EconomyService(registration.getProvider());
this.messageService = new MessageService(configService);
this.soundService = new SoundService(configService);
this.itemFactory = new ItemFactory(configService);
this.purchaseService = new PurchaseService(
economyService,
messageService,
soundService,
itemFactory
);
this.guiManager = new GuiManager(
this,
configService,
messageService,
soundService,
itemFactory,
purchaseService
);
GuiListener listener = new GuiListener(guiManager, purchaseService);
Bukkit.getPluginManager().registerEvents(listener, this);
ShopCommand shopCommand = new ShopCommand(guiManager, messageService);
getCommand("shop").setExecutor(shopCommand);
getCommand("market").setExecutor(shopCommand);
getLogger().info("NovaGUI Shop enabled with " + registration.getProvider().getName() + ".");
}
public ConfigService getConfigService() {
return configService;
}
public EconomyService getEconomyService() {
return economyService;
}
public GuiManager getGuiManager() {
return guiManager;
}
}