diff --git a/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java b/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java index dee0d54..29968c8 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java +++ b/src/main/java/com/jaimemartz/playerbalancer/connection/ProviderType.java @@ -18,6 +18,13 @@ public enum ProviderType { } }, + RANDOM { + @Override + public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, List servers, ProxiedPlayer player) { + return ProviderType.getRandom(servers); + } + }, + LOWEST { @Override public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, List servers, ProxiedPlayer player) { @@ -55,14 +62,7 @@ public enum ProviderType { } } - return results.get(ThreadLocalRandom.current().nextInt(servers.size())); - } - }, - - RANDOM { - @Override - public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, List servers, ProxiedPlayer player) { - return servers.get(ThreadLocalRandom.current().nextInt(servers.size())); + return ProviderType.getRandom(results); } }, @@ -76,7 +76,7 @@ public enum ProviderType { } } - return servers.get(ThreadLocalRandom.current().nextInt(servers.size())); + return ProviderType.getRandom(servers); } }, @@ -101,4 +101,8 @@ public enum ProviderType { }; public abstract ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, List servers, ProxiedPlayer player); + + private static ServerInfo getRandom(List list) { + return list.get(ThreadLocalRandom.current().nextInt(list.size())); + } } \ No newline at end of file