package de.simolzimol.mclogger.consent.util;

import de.simolzimol.mclogger.consent.ConsentConfig;
import org.bukkit.entity.Player;

/**
 * Simple placeholder replacement helper.
 */
public final class MessageUtil {

    private MessageUtil() {}

    /**
     * Replaces standard placeholders in a MiniMessage string.
     *
     * <p>Supported placeholders:
     * <ul>
     *   <li>{@code {player}}      – player's display name</li>
     *   <li>{@code {url}}         – configured policy URL</li>
     *   <li>{@code {policy_url}}  – configured policy URL (alias for {url})</li>
     *   <li>{@code {command}}     – consent command name (e.g. "consent")</li>
     *   <li>{@code {version}}     – policy version string</li>
     * </ul>
     */
    public static String replace(String template, Player player, ConsentConfig cfg) {
        if (template == null) return "";
        return template
                .replace("{player}",     player.getName())
                .replace("{url}",        cfg.getPolicyUrl())
                .replace("{policy_url}", cfg.getPolicyUrl())
                .replace("{command}",    cfg.getCommand())
                .replace("{version}",    cfg.getPolicyVersion());
    }
}
