diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java index 3b9d1a1..ceec29c 100644 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java +++ b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java @@ -3,15 +3,11 @@ package com.jaimemartz.playerbalancer.connection; import com.jaimemartz.playerbalancer.PlayerBalancer; import com.jaimemartz.playerbalancer.connection.provider.AbstractProvider; import com.jaimemartz.playerbalancer.connection.provider.types.*; -import com.jaimemartz.playerbalancer.ping.ServerStatus; import com.jaimemartz.playerbalancer.section.ServerSection; -import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; -import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ThreadLocalRandom; public enum ProviderType { NONE { diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/ping/PingTactic.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/ping/PingTactic.java index 0ec6d21..62ae730 100644 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/ping/PingTactic.java +++ b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/ping/PingTactic.java @@ -16,7 +16,9 @@ public enum PingTactic { public void ping(ServerInfo server, Callback callback, PlayerBalancer plugin) { plugin.getProxy().getScheduler().runAsync(plugin, () -> { try { - StatusResponse response = utility.ping(server.getAddress()); + StatusResponse response = utility.ping( + server.getAddress(), + plugin.getSettings().getServerCheckerProps().getTimeout()); callback.done(new ServerStatus( response.getDescription().toLegacyText(), response.getPlayers().getOnline(), diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/ServerCheckerProps.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/ServerCheckerProps.java index d682c51..bdbc80c 100644 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/ServerCheckerProps.java +++ b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/ServerCheckerProps.java @@ -20,6 +20,9 @@ public class ServerCheckerProps { @Setting private int interval; + @Setting + private int timeout; + @Setting(value = "marker-descs") private List markerDescs; @@ -58,6 +61,14 @@ public class ServerCheckerProps { this.interval = interval; } + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + this.timeout = timeout; + } + public List getMarkerDescs() { return markerDescs; } @@ -81,6 +92,7 @@ public class ServerCheckerProps { ", tactic=" + tactic + ", attempts=" + attempts + ", interval=" + interval + + ", timeout=" + timeout + ", markerDescs=" + markerDescs + ", debug=" + debug + '}'; diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/utils/ServerListPing.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/utils/ServerListPing.java index 4caaa52..ab2e12e 100644 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/utils/ServerListPing.java +++ b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/utils/ServerListPing.java @@ -17,7 +17,6 @@ import java.net.Socket; import java.util.List; public final class ServerListPing { - private int timeout = 7000; private static Gson gson = new GsonBuilder() .registerTypeAdapter(BaseComponent.class, new ComponentSerializer()) .registerTypeAdapter(TextComponent.class, new TextComponentSerializer()) @@ -48,7 +47,7 @@ public final class ServerListPing { } } - public StatusResponse ping(InetSocketAddress host) throws IOException { + public StatusResponse ping(InetSocketAddress host, int timeout) throws IOException { try (Socket socket = new Socket()) { socket.setSoTimeout(timeout); socket.connect(host, timeout); @@ -118,14 +117,6 @@ public final class ServerListPing { } } - public void setTimeout(int timeout) { - this.timeout = timeout; - } - - public int getTimeout() { - return timeout; - } - public static class StatusResponse { private BaseComponent description; private Players players; diff --git a/Main Plugin/src/main/resources/default.conf b/Main Plugin/src/main/resources/default.conf index c1e7157..eb6fef2 100644 --- a/Main Plugin/src/main/resources/default.conf +++ b/Main Plugin/src/main/resources/default.conf @@ -132,6 +132,9 @@ features { # The interval between every round of checks (in milliseconds) interval=10000 + # The timeout of a ping, only applied to the CUSTOM tactic + timeout=7000 + # When true, the plugin will print useful info when a server gets checked debug-info=false