diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java index 8fe902d..01eb39a 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java @@ -15,9 +15,9 @@ public final class AuthMeConfig { public AuthMeConfig(@NotNull Toml toml){ this.authServers = toml.getList("authServers", List.of("auth1", "auth2")); - this.serverOnLogin = ConfigUtils.getOrElse(toml, "SendOnLogin", () -> new ServerOnLogin(false, List.of("lobby1", "lobby2"))); - this.commands = ConfigUtils.getOrElse(toml, "Commands", () -> new Commands(Set.of("login", "register", "l", "reg", "email", "captcha"),"You cannot execute commands if you are not logged in yet")); - this.ensure = ConfigUtils.getOrElse(toml, "EnsureAuthServer", () -> new EnsureAuthServer(false, "You could not connect to a login server, please try again later")); + this.serverOnLogin = ConfigUtils.getOrElse(toml, "SendOnLogin", new ServerOnLogin(false, List.of("lobby1", "lobby2"))); + this.commands = ConfigUtils.getOrElse(toml, "Commands", new Commands(Set.of("login", "register", "l", "reg", "email", "captcha"),"You cannot execute commands if you are not logged in yet")); + this.ensure = ConfigUtils.getOrElse(toml, "EnsureAuthServer", new EnsureAuthServer(false, "You could not connect to a login server, please try again later")); } public static class ServerOnLogin { diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/ConfigUtils.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/ConfigUtils.java index f3f887d..7e4556e 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/ConfigUtils.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/ConfigUtils.java @@ -1,7 +1,5 @@ package com.glyart.authmevelocity.proxy.config; -import java.util.function.Supplier; - import com.moandjiezana.toml.Toml; import com.velocitypowered.api.proxy.Player; @@ -18,9 +16,9 @@ public final class ConfigUtils { } @SuppressWarnings("unchecked") - static T getOrElse(Toml config, String key, Supplier defaultValue){ + static T getOrElse(Toml config, String key, T defaultValue){ Toml configTable = config.getTable(key); - return configTable == null ? defaultValue.get() : (T)configTable.to(defaultValue.getClass()); + return configTable == null ? defaultValue : (T)configTable.to(defaultValue.getClass()); } private ConfigUtils(){} }