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