package me.proxylink.plugin.paper;

import me.proxylink.common.AgentConfig;
import me.proxylink.plugin.PluginRuntime;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class DirtSimplePaperPlugin extends JavaPlugin {
    private PluginRuntime runtime;

    @Override
    public void onEnable() {
        runtime = new PluginRuntime(getLogger());
        runtime.start(getDataFolder().toPath(), "paper-default.properties", AgentConfig.Role.BACKEND);

        PluginCommand command = getCommand("dsp2p");
        if (command != null) {
            DirtSimplePaperCommand commandHandler = new DirtSimplePaperCommand(runtime);
            command.setExecutor(commandHandler);
            command.setTabCompleter(commandHandler);
        }
    }

    @Override
    public void onDisable() {
        if (runtime != null) {
            runtime.stop();
            runtime = null;
        }
    }
}
