package eu.mhsl.minenet.minigames.command;

import eu.mhsl.minenet.minigames.command.privileged.SkinCommand;
import eu.mhsl.minenet.minigames.command.privileged.*;
import eu.mhsl.minenet.minigames.command.anonymous.HubCommand;
import eu.mhsl.minenet.minigames.command.anonymous.LeaveCommand;
import eu.mhsl.minenet.minigames.message.Icon;
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command;

public enum Commands {
    HUB(new HubCommand()),
    LEAVE(new LeaveCommand()),

    DEBUG(new DebugCommand()),
    FLY(new FlyCommand()),
    GAMEMODE(new GamemodeCommand()),
    GC(new GcCommand()),
    LANGTEST(new LangTestCommand()),
    ROOM(new RoomCommand()),
    UPDATE(new RefreshCommandsCommand()),
    OP(new OpCommand()),
    FAKEPLAYER(new FakeplayerCommand()),
    KICK(new KickCommand()),
    SKIN(new SkinCommand()),
    SETOWNER(new SetRoomOwnerCommand()),
    SETREWARD(new SetRewardCommand()),
    PUBLISHREWARD(new PublishRewardCommand()),
    ROOMPROXYMOVE(new InstanceProxyMoveCommand()),
    GAMESTART(new GameStartCommand()),
    GAMESTOP(new GameStopCommand()),
    GAMETIMEOUT(new GameTimeoutCommand()),
    PLAYERLIMIT(new PlayerLimitCommand()),
    SETMEMORIAL(new SetMemorialCommand());

    Commands(Command handler) {
        MinecraftServer.getCommandManager().register(handler);
    }

    static {
        MinecraftServer.getCommandManager().setUnknownCommandCallback((sender, command) -> {
            if(command.isBlank()) return;
            new ChatMessage(Icon.ERROR).appendStatic("Unknown command: ").quote(command).send(sender);
        });
    }
}
