Validate config

This commit is contained in:
Adrian Bergqvist 2023-02-10 19:06:49 +01:00
parent e2c49f35e6
commit c77fcbd09f
No known key found for this signature in database
GPG Key ID: FAE7D8EDE225E686
2 changed files with 8 additions and 1 deletions

View File

@ -37,6 +37,7 @@ import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3;
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
@Plugin(id = "ambassador", name = "Ambassador", version = "1.2.0-beta", authors = {"adde0109"})

View File

@ -27,7 +27,13 @@ public class AmbassadorConfig {
public void validate() {
final int connectionTimeout = Ambassador.getInstance().server.getConfiguration().getConnectTimeout();
if (resetTimeout >= connectionTimeout) {
throw new InvalidValueException("'reset-timeout' can't be larger than nor equal to 'connection-timeout': reset-timeout=" + resetTimeout + " connection-timeout=" + connectionTimeout);
throw new InvalidValueException("'reset-timeout' can't be more than nor equal to 'connection-timeout': reset-timeout=" + resetTimeout + " connection-timeout=" + connectionTimeout);
}
if (resetTimeout <= 0) {
throw new InvalidValueException("'reset-timeout' can't be less than nor equal to zero: reset-timeout=" + resetTimeout);
}
if (serverSwitchCancellationTime <= 0) {
throw new InvalidValueException("'server-switch-cancellation-time' can't be less than nor equal to zero: server-switch-cancellation-time=" + serverSwitchCancellationTime);
}
}