mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-27 13:15:29 +01:00
Little changes to section servers set
This commit is contained in:
parent
e96640f54c
commit
f84b6eb5f2
@ -1,5 +1,6 @@
|
||||
package com.jaimemartz.playerbalancer.commands;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.jaimemartz.playerbalancer.PlayerBalancer;
|
||||
import com.jaimemartz.playerbalancer.connection.ConnectionIntent;
|
||||
import com.jaimemartz.playerbalancer.section.ServerSection;
|
||||
@ -41,15 +42,8 @@ public class FallbackCommand extends Command {
|
||||
} else if (number > target.getServers().size()) {
|
||||
MessageUtils.send(player, messages.getFailureMessage());
|
||||
} else {
|
||||
int iterations = 0;
|
||||
for (ServerInfo server : target.getServers()) {
|
||||
if (iterations++ < number - 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ConnectionIntent.direct(plugin, player, server, (response, throwable) -> { });
|
||||
break;
|
||||
}
|
||||
ServerInfo server = Iterables.get(target.getServers(), number - 1);
|
||||
ConnectionIntent.direct(plugin, player, server, (response, throwable) -> {});
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
MessageUtils.send(player, messages.getInvalidInputMessage());
|
||||
|
@ -22,7 +22,7 @@ public class SectionManager {
|
||||
private ServerSection principal;
|
||||
private ScheduledTask refreshTask;
|
||||
|
||||
private final Map<String, Stage> stages = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<String, Stage> stages = Collections.synchronizedMap(new LinkedHashMap<>());
|
||||
private final Map<String, ServerSection> sections = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<ServerInfo, ServerSection> servers = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.jaimemartz.playerbalancer.utils.AlphanumComparator;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@ -20,7 +21,7 @@ public class ServerSection {
|
||||
|
||||
private ServerInfo server;
|
||||
private SectionCommand command;
|
||||
private Set<ServerInfo> servers;
|
||||
private NavigableSet<ServerInfo> servers;
|
||||
private AbstractProvider externalProvider;
|
||||
|
||||
private boolean valid = false;
|
||||
@ -29,7 +30,7 @@ public class ServerSection {
|
||||
this.name = name;
|
||||
this.props = props;
|
||||
|
||||
this.servers = Collections.synchronizedSortedSet(new TreeSet<>((lhs, rhs) ->
|
||||
this.servers = Collections.synchronizedNavigableSet(new TreeSet<>((lhs, rhs) ->
|
||||
AlphanumComparator.getInstance().compare(lhs.getName(), rhs.getName())
|
||||
));
|
||||
}
|
||||
@ -108,7 +109,7 @@ public class ServerSection {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public Set<ServerInfo> getServers() {
|
||||
public NavigableSet<ServerInfo> getServers() {
|
||||
return servers;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user