Fixed the provider 'BALANCED'

This commit is contained in:
Jaime Martínez Rincón 2017-09-21 14:42:16 +02:00
parent a6c7cdbfac
commit a6864b9b51

View File

@ -18,6 +18,13 @@ public enum ProviderType {
}
},
RANDOM {
@Override
public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, List<ServerInfo> servers, ProxiedPlayer player) {
return ProviderType.getRandom(servers);
}
},
LOWEST {
@Override
public ServerInfo requestTarget(PlayerBalancer plugin, ServerSection section, List<ServerInfo> 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<ServerInfo> 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<ServerInfo> servers, ProxiedPlayer player);
private static ServerInfo getRandom(List<ServerInfo> list) {
return list.get(ThreadLocalRandom.current().nextInt(list.size()));
}
}