package pw.hamzantal.vagueenchants.commands

import hazae41.minecraft.kutils.bukkit.msg
import org.bukkit.ChatColor
import org.bukkit.command.CommandSender
import org.bukkit.enchantments.Enchantment
import pw.hamzantal.vagueenchants.Msgs

val String.c
    get() = ChatColor.translateAlternateColorCodes('&', this)

fun String.ench(p: CommandSender? = null): Enchantment? = Enchantment.getByName(toUpperCase()) ?: run {
    if (toUpperCase() == "EFFICIENCY") return Enchantment.DIG_SPEED
    if (toUpperCase() == "FORTUNE") return Enchantment.LOOT_BONUS_BLOCKS

    p?.err("Enchantment $this was not found.")
    null
}

fun CommandSender.err(msg: String, vararg placeholder: Pair<String, String>) {
    msg(Msgs.error(msg, *placeholder))
}

fun CommandSender.general(msg: String, vararg placeholder: Pair<String, String>) {
    msg(Msgs.general(msg, *placeholder))
}

fun CommandSender.success(msg: String, vararg placeholder: Pair<String, String>) {
    msg(Msgs.success(msg, *placeholder))
}

