package eu.mhsl.craftattack.teamLobby;

import net.minestom.server.extras.MojangAuth;
import net.minestom.server.extras.bungee.BungeeCordProxy;
import net.minestom.server.extras.velocity.VelocityProxy;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

public class Authentication {
    public enum Method {
        NONE,
        VANILLA,
        BUNGEECORD,
        VELOCITY
    }

    public record Values(String method, @Nullable String secret) {
    }

    public static void init(Values values) {
        Method method = Method.valueOf(values.method);

        switch(method) {
            case VANILLA -> MojangAuth.init();
            case BUNGEECORD -> BungeeCordProxy.enable();
            case VELOCITY -> {
                Objects.requireNonNull(values.secret, "Velocity proxy needs an secret");
                VelocityProxy.enable(values.secret);
            }
        }

        System.out.printf("Server authentication requirement is set to '%s'!%n", method);
    }
}
