Files
src
build.gradle
settings.gradle
Code
33 2,631
src/main/java/com/kodari/shopbox/ShopBoxPlugin.java
package com.kodari.shopbox;
import com.kodari.shopbox.command.AhCommand;
import com.kodari.shopbox.command.ShopBoxCommand;
import com.kodari.shopbox.economy.EconomyHook;
import com.kodari.shopbox.gui.GUIListener;
import com.kodari.shopbox.gui.GUIManager;
import com.kodari.shopbox.gui.AuctionHouseGUI;
import com.kodari.shopbox.listener.ShopBoxListener;
import com.kodari.shopbox.listener.ShopInventoryListener;
import com.kodari.shopbox.service.FormManager;
import com.kodari.shopbox.service.HologramManager;
import com.kodari.shopbox.service.MessageManager;
import com.kodari.shopbox.service.DatabaseManager;
import com.kodari.shopbox.service.PermissionManager;
import com.kodari.shopbox.service.ProtectionStonesHook;
import com.kodari.shopbox.service.PurchaseService;
import com.kodari.shopbox.service.RecipeManager;
import com.kodari.shopbox.service.ShopBoxManager;
import com.kodari.shopbox.service.TeleportWarmupManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class ShopBoxPlugin extends JavaPlugin {
private MessageManager messages;
private DatabaseManager database;
private EconomyHook economy;
private PermissionManager permissions;
private HologramManager holograms;
private ShopBoxManager boxes;
private PurchaseService purchases;
private FormManager forms;
private GUIManager guiManager;
private TeleportWarmupManager teleports;
@Override
public void onEnable() {
saveDefaultConfig();
saveResource("messages.yml", false);
messages = new MessageManager(this);
database = new DatabaseManager(this);
if (!database.initialize()) {
messages.send(getServer().getConsoleSender(), "database-error");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
economy = new EconomyHook(this);
if (!economy.setup()) {
messages.send(getServer().getConsoleSender(), "no-economy");
database.close();
Bukkit.getPluginManager().disablePlugin(this);
return;
}
permissions = new PermissionManager(this);
permissions.registerConfiguredPermissions();
holograms = new HologramManager(this);
holograms.cleanupStale();
boxes = new ShopBoxManager(this, holograms, database);
boxes.load();
boxes.startLifecycleTask();
purchases = new PurchaseService(this, boxes, economy, messages);
forms = new FormManager(this, boxes, purchases, messages);
guiManager = new GUIManager();
teleports = new TeleportWarmupManager(this);
RecipeManager recipeManager = new RecipeManager(this);
recipeManager.register();
Bukkit.getPluginManager().registerEvents(recipeManager, this);
Bukkit.getPluginManager().registerEvents(new ShopBoxListener(this, boxes, forms, permissions, messages), this);
Bukkit.getPluginManager().registerEvents(new ShopInventoryListener(boxes, forms, messages), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(teleports, this);
getCommand("ah").setExecutor(new AhCommand(this, guiManager, boxes, forms));
ShopBoxCommand shopBoxCommand = new ShopBoxCommand(this, permissions, messages, holograms, guiManager);
getCommand("shopbox").setExecutor(shopBoxCommand);
getCommand("shopbox").setTabCompleter(shopBoxCommand);
}
@Override
public void onDisable() {
if (boxes != null) {
boxes.shutdown();
boxes.save();
}
if (holograms != null) {
holograms.shutdown();
}
if (teleports != null) {
teleports.shutdown();
}
if (database != null) {
database.close();
}
}
public void reloadSettings() {
reloadConfig();
messages.reload();
holograms.reload();
for (var box : boxes.all()) {
holograms.update(box);
}
}
public MessageManager messages() { return messages; }
public EconomyHook economy() { return economy; }
public PermissionManager permissions() { return permissions; }
public ShopBoxManager boxes() { return boxes; }
public PurchaseService purchases() { return purchases; }
public FormManager forms() { return forms; }
public TeleportWarmupManager teleports() { return teleports; }
}