package eu.mhsl.minenet.minigames.command.privileged;

import eu.mhsl.minenet.minigames.command.PrivilegedCommand;
import eu.mhsl.minenet.minigames.lang.Languages;
import eu.mhsl.minenet.minigames.lang.Lang;
import eu.mhsl.minenet.minigames.message.Icon;
import eu.mhsl.minenet.minigames.message.TranslatableMessage;
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
import net.minestom.server.command.builder.arguments.ArgumentType;
import net.minestom.server.entity.Player;

public class LangTestCommand extends PrivilegedCommand {
    public LangTestCommand() {
        super("langtest");

        setDefaultExecutor((sender, context) -> sendMessage(Languages.getInstance().getLanguage((Player) sender), "sample").send(sender));

        var targetString = ArgumentType.String("mapId");

        addSyntax((sender, context) -> sendMessage(Languages.getInstance().getLanguage((Player) sender), context.get("mapId")).send(sender), targetString);
    }

    private TranslatableMessage sendMessage(Lang lang, String mapId) {
        return new ChatMessage(Icon.SCIENCE).appendStatic(lang.getLangId()).newLine().appendTranslated(lang.getEntry(mapId));
    }
}
