Revert Supplier changes

- Fix #29
This commit is contained in:
4drian3d 2022-03-20 17:55:38 +00:00
parent 7279ed7f9d
commit bf8db139ff
2 changed files with 5 additions and 7 deletions

View File

@ -15,9 +15,9 @@ public final class AuthMeConfig {
public AuthMeConfig(@NotNull Toml toml){ public AuthMeConfig(@NotNull Toml toml){
this.authServers = toml.getList("authServers", List.of("auth1", "auth2")); this.authServers = toml.getList("authServers", List.of("auth1", "auth2"));
this.serverOnLogin = ConfigUtils.getOrElse(toml, "SendOnLogin", () -> new ServerOnLogin(false, List.of("lobby1", "lobby2"))); 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"),"<red>You cannot execute commands if you are not logged in yet")); this.commands = ConfigUtils.getOrElse(toml, "Commands", new Commands(Set.of("login", "register", "l", "reg", "email", "captcha"),"<red>You cannot execute commands if you are not logged in yet"));
this.ensure = ConfigUtils.getOrElse(toml, "EnsureAuthServer", () -> new EnsureAuthServer(false, "<red>You could not connect to a login server, please try again later")); this.ensure = ConfigUtils.getOrElse(toml, "EnsureAuthServer", new EnsureAuthServer(false, "<red>You could not connect to a login server, please try again later"));
} }
public static class ServerOnLogin { public static class ServerOnLogin {

View File

@ -1,7 +1,5 @@
package com.glyart.authmevelocity.proxy.config; package com.glyart.authmevelocity.proxy.config;
import java.util.function.Supplier;
import com.moandjiezana.toml.Toml; import com.moandjiezana.toml.Toml;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
@ -18,9 +16,9 @@ public final class ConfigUtils {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static <T>T getOrElse(Toml config, String key, Supplier<T> defaultValue){ static <T>T getOrElse(Toml config, String key, T defaultValue){
Toml configTable = config.getTable(key); 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(){} private ConfigUtils(){}
} }