package org.twipnetwork.colorfulwords;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.UUID;

public final class ColorfulWords extends JavaPlugin {

    @Override
    public void onEnable() {
        // Plugin startup logic
        saveDefaultConfig();
        getServer().getPluginManager().registerEvents(new ChatListener(this), this);
        getCommand("color").setExecutor(new ColorCommand(this));
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    public String getPlayerColor(UUID playerId) {
        FileConfiguration config = getConfig();
        return config.getString("players." + playerId.toString());
    }

    public void setPlayerColor(UUID playerId, String colorHex) {
        FileConfiguration config = getConfig();
        config.set("players." + playerId.toString(), colorHex);
        saveConfig();
    }

    public void resetPlayerColor(UUID playerId) {
        FileConfiguration config = getConfig();
        config.set("players." + playerId.toString(), null);
        saveConfig();
    }
}
