Added nullability checks on configuraton values
This commit is contained in:
parent
9a67b10ab1
commit
60cb957b19
@ -1,21 +1,24 @@
|
||||
package com.glyart.authmevelocity.proxy.config;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import com.moandjiezana.toml.Toml;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class AuthMeConfig {
|
||||
private final List<String> authServers;
|
||||
private final ServerOnLogin serverOnLogin;
|
||||
private final Commands commands;
|
||||
private final EnsureAuthServer ensure;
|
||||
|
||||
public AuthMeConfig(Toml toml){
|
||||
this.authServers = toml.getList("authServers");
|
||||
this.serverOnLogin = toml.getTable("SendOnLogin").to(ServerOnLogin.class);
|
||||
this.commands = toml.getTable("Commands").to(Commands.class);
|
||||
this.ensure = toml.getTable("EnsureAuthServer").to(EnsureAuthServer.class);
|
||||
public AuthMeConfig(@NotNull Toml toml){
|
||||
this.authServers = Objects.requireNonNull(toml.getList("authServers"), "the list of auth servers is not available, please check your configuration for any failure");
|
||||
this.serverOnLogin = Objects.requireNonNull(toml.getTable("SendOnLogin"), "SendOnLogin options are not available, check your configuration").to(ServerOnLogin.class);
|
||||
this.commands = Objects.requireNonNull(toml.getTable("Commands"), "Commands options are not available, check your configuration").to(Commands.class);
|
||||
this.ensure = Objects.requireNonNull(toml.getTable("EnsureAuthServer"), "EnsureAuthServer options are not available, check your configuration").to(EnsureAuthServer.class);
|
||||
}
|
||||
|
||||
public static class ServerOnLogin {
|
||||
@ -26,7 +29,7 @@ public final class AuthMeConfig {
|
||||
return this.sendToServerOnLogin;
|
||||
}
|
||||
|
||||
public List<String> getTeleportServers(){
|
||||
public @NotNull List<String> getTeleportServers(){
|
||||
return this.teleportServers;
|
||||
}
|
||||
}
|
||||
@ -35,11 +38,11 @@ public final class AuthMeConfig {
|
||||
private Set<String> allowedCommands;
|
||||
private String blockedCommandMessage;
|
||||
|
||||
public Set<String> getAllowedCommands(){
|
||||
public @NotNull Set<String> getAllowedCommands(){
|
||||
return this.allowedCommands;
|
||||
}
|
||||
|
||||
public String getBlockedMessage() {
|
||||
public @NotNull String getBlockedMessage() {
|
||||
return this.blockedCommandMessage;
|
||||
}
|
||||
}
|
||||
@ -52,25 +55,25 @@ public final class AuthMeConfig {
|
||||
return this.ensureFirstServerIsAuthServer;
|
||||
}
|
||||
|
||||
public String getDisconnectMessage(){
|
||||
public @NotNull String getDisconnectMessage(){
|
||||
return this.disconnectMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Commands getCommandsConfig(){
|
||||
public @NotNull Commands getCommandsConfig(){
|
||||
return this.commands;
|
||||
}
|
||||
|
||||
public ServerOnLogin getToServerOptions(){
|
||||
public @NotNull ServerOnLogin getToServerOptions(){
|
||||
return this.serverOnLogin;
|
||||
}
|
||||
|
||||
public EnsureAuthServer getEnsureOptions(){
|
||||
public @NotNull EnsureAuthServer getEnsureOptions(){
|
||||
return this.ensure;
|
||||
}
|
||||
|
||||
public List<String> getAuthServers(){
|
||||
public @NotNull List<String> getAuthServers(){
|
||||
return this.authServers;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user