package eu.mhsl.craftattack.teamLobby.util;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.entity.Player;

import java.util.UUID;

public record DisconnectInfo(String error, String description, String help, UUID user) {
    public void applyKick(Player player) {
        player.kick(this.getComponent());
    }

    public Component getComponent() {
        return Component.text()
            .appendNewline().appendNewline()
            .append(Component.text(this.error, NamedTextColor.DARK_RED)).appendNewline()
            .append(Component.text(this.description, NamedTextColor.RED)).appendNewline().appendNewline()
            .append(Component.text(this.help, NamedTextColor.GRAY)).appendNewline().appendNewline()
            .append(Component.text(this.user.toString(), NamedTextColor.DARK_GRAY)).appendNewline()
            .build();
    }

    public static class Throwable extends Exception {
        public String error;
        public String description;
        public String help;
        public UUID user;

        public Throwable(String error, String description, String help, UUID user) {
            super(description);
            this.error = error;
            this.description = description;
            this.help = help;
            this.user = user;
        }

        public DisconnectInfo getDisconnectScreen() {
            return new DisconnectInfo(this.error, this.description, this.help, this.user);
        }
    }
}
