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

import eu.mhsl.minenet.minigames.command.PrivilegedCommand;
import eu.mhsl.minenet.minigames.instance.room.Room;
import eu.mhsl.minenet.minigames.util.PluginMessageUtil;
import net.minestom.server.command.builder.arguments.ArgumentWord;
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;

public class InstanceProxyMoveCommand extends PrivilegedCommand {
    public InstanceProxyMoveCommand() {
        super("instanceProxyMove");

        ArgumentWord serverArgument = new ArgumentWord("server");

        addSyntax((sender, context) -> {
            Instance room = ((Player) sender).getInstance();
            room.getPlayers().forEach(player -> {
                Room.unsetRoom(player);
                PluginMessageUtil.connect(player, context.get(serverArgument));
            });
        }, serverArgument);
    }
}
