James Wiscarson

compile this

Kodari AI
KodariSep 3 at 6:02 pm 1

I can’t run the compilation here because the project environment does not provide Maven/Gradle build tools. The project uses Maven via pom.xml; compile it locally with:

Shell
mvn clean package

The resulting JAR should be:

Plain Text
target/CharacterCards-1.0.0.jar

Ensure this file exists first:

Plain Text
libs/megachat-1_0_0.jar

Otherwise Maven will fail because it is declared as a system-scoped dependency.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
README.md
Code
25 2,296
src/main/java/com/charactercards/CharacterCardsPlugin.java
package com.charactercards;

import com.charactercards.commands.CardCommand;
import com.charactercards.config.ConfigManager;
import com.charactercards.data.CardDataManager;
import com.charactercards.gui.AnvilInputManager;
import com.charactercards.gui.BiographyManager;
import com.charactercards.gui.GuiManager;
import com.charactercards.integration.CardsPlaceholderExpansion;
import com.charactercards.integration.LandsHook;
import com.charactercards.integration.MegaChatHook;
import com.charactercards.listeners.AnvilListener;
import com.charactercards.listeners.BookListener;
import com.charactercards.listeners.GuiClickListener;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class CharacterCardsPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private CardDataManager dataManager;
    private GuiManager guiManager;
    private AnvilInputManager anvilInputManager;
    private BiographyManager biographyManager;
    private LandsHook landsHook;
    private MegaChatHook megaChatHook;

    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.configManager.load();

        this.dataManager = new CardDataManager(this);
        this.guiManager = new GuiManager(this);
        this.anvilInputManager = new AnvilInputManager(this);
        this.biographyManager = new BiographyManager(this);
        this.landsHook = new LandsHook(this);
        this.megaChatHook = new MegaChatHook(this);

        getServer().getPluginManager().registerEvents(new GuiClickListener(this), this);
        getServer().getPluginManager().registerEvents(new AnvilListener(this), this);
        getServer().getPluginManager().registerEvents(new BookListener(this), this);

        CardCommand cardCommand = new CardCommand(this);
        if (getCommand("card") != null) {
            getCommand("card").setExecutor(cardCommand);
            getCommand("card").setTabCompleter(cardCommand);
        }

        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new CardsPlaceholderExpansion(this).register();
            getLogger().info("Hooked into PlaceholderAPI.");
        } else {
            getLogger().warning("PlaceholderAPI not found - %card_*% placeholders will not be available.");
        }

        if (landsHook.isAvailable()) {
            getLogger().info("Hooked into Lands for Nation/Town lookups.");
        } else {
            getLogger().info("Lands not found - Nation/Town fields will show as unknown.");
        }

        if (megaChatHook.isAvailable()) {
            getLogger().info("Hooked into MegaChat - chosen prefixes will sync to chat.");
        } else {
            getLogger().info("MegaChat not found - prefixes will only be tracked on the card itself.");
        }

        getLogger().info("CharacterCards enabled.");
    }

    @Override
    public void onDisable() {
        if (dataManager != null) {
            dataManager.saveAll();
        }
        getLogger().info("CharacterCards disabled.");
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public CardDataManager getDataManager() {
        return dataManager;
    }

    public GuiManager getGuiManager() {
        return guiManager;
    }

    public AnvilInputManager getAnvilInputManager() {
        return anvilInputManager;
    }

    public BiographyManager getBiographyManager() {
        return biographyManager;
    }

    public LandsHook getLandsHook() {
        return landsHook;
    }

    public MegaChatHook getMegaChatHook() {
        return megaChatHook;
    }
}