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

import eu.mhsl.minenet.minigames.command.PrivilegedCommand;
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
import net.minestom.server.command.builder.arguments.ArgumentType;
import net.minestom.server.command.builder.arguments.number.ArgumentInteger;
import net.minestom.server.entity.Player;

public class GameTimeoutCommand extends PrivilegedCommand {
    public GameTimeoutCommand() {
        super("gameTimeout");

        ArgumentInteger timeout = ArgumentType.Integer("timeout");

        addSyntax((sender, context) -> {
            Player player = (Player) sender;
            if(player.getInstance() instanceof StatelessGame game) {
                game.setTimeLimit(context.get(timeout));
            }
        }, timeout);
    }
}
