Files
src
pom.xml
Code
18 1,654
src/main/java/com/iconicbots/IconicBotsPlugin.java
package com.iconicbots;
import com.iconicbots.command.BotCommand;
import com.iconicbots.core.BotManager;
import com.iconicbots.integration.IconicBotsExpansion;
import com.iconicbots.integration.VaultHook;
import com.iconicbots.listener.BotListener;
import com.iconicbots.storage.BotStorage;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
/**
* Main lifecycle class. World access and entity mutation stay on the server
* thread; only persistence preparation and optional integrations are isolated.
*/
public final class IconicBotsPlugin extends JavaPlugin {
private BotStorage storage;
private BotManager botManager;
private VaultHook vaultHook;
@Override
public void onEnable() {
saveDefaultConfig();
this.storage = new BotStorage(this);
this.botManager = new BotManager(this, storage);
this.botManager.loadProfiles();
this.botManager.start();
Bukkit.getPluginManager().registerEvents(new BotListener(botManager), this);
BotCommand botCommand = new BotCommand(this, botManager);
if (getCommand("bot") != null) {
getCommand("bot").setExecutor(botCommand);
getCommand("bot").setTabCompleter(botCommand);
}
if (Bukkit.getPluginManager().isPluginEnabled("Vault")) {
this.vaultHook = new VaultHook();
if (vaultHook.setup()) {
getLogger().info("Vault economy integration enabled.");
}
}
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new IconicBotsExpansion(this).register();
getLogger().info("PlaceholderAPI integration enabled.");
}
getLogger().info("IconicBots enabled with " + botManager.getBots().size() + " profiles.");
}
@Override
public void onDisable() {
if (botManager != null) {
botManager.shutdown();
}
if (storage != null) {
storage.saveAll(botManager == null ? java.util.List.of() : botManager.getProfiles());
}
getLogger().info("IconicBots disabled.");
}
public BotStorage getStorage() {
return storage;
}
public BotManager getBotManager() {
return botManager;
}
public VaultHook getVaultHook() {
return vaultHook;
}
public void reportError(String message, Throwable throwable) {
getLogger().log(Level.WARNING, message, throwable);
}
}