package com.bitnix.dirtcryptostore.util;

import com.bitnix.dirtcryptostore.DirtCryptoStorePlugin;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;

public final class TitleUtil {

    private TitleUtil() {
    }

    public static void sendTitle(DirtCryptoStorePlugin plugin, Player player, String key) {
        if (!plugin.getConfig().getBoolean("titles.enabled", true)) {
            return;
        }

        ConfigurationSection section = plugin.getConfig().getConfigurationSection("titles." + key);
        if (section == null) {
            return;
        }

        String title = ColorUtil.color(section.getString("title", ""));
        String subtitle = ColorUtil.color(section.getString("subtitle", ""));
        int fadeIn = section.getInt("fade-in", 10);
        int stay = section.getInt("stay", 50);
        int fadeOut = section.getInt("fade-out", 10);

        player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
    }
}
