mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-23 19:25:12 +01:00
The servers set was being reassigned to a non ordered set
This commit is contained in:
parent
dc69839366
commit
135f109782
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.jaimemartz</groupId>
|
<groupId>com.jaimemartz</groupId>
|
||||||
<artifactId>playerbalancer</artifactId>
|
<artifactId>playerbalancer</artifactId>
|
||||||
<version>2.1</version>
|
<version>2.1.0.1</version>
|
||||||
<name>PlayerBalancer</name>
|
<name>PlayerBalancer</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -12,6 +12,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class SectionManager {
|
public class SectionManager {
|
||||||
private final PlayerBalancer plugin;
|
private final PlayerBalancer plugin;
|
||||||
@ -32,13 +33,7 @@ public class SectionManager {
|
|||||||
|
|
||||||
for (Stage stage : stages) {
|
for (Stage stage : stages) {
|
||||||
plugin.getLogger().info("Executing stage \"" + stage.title + "\"");
|
plugin.getLogger().info("Executing stage \"" + stage.title + "\"");
|
||||||
if (stage instanceof SectionStage) {
|
stage.execute();
|
||||||
props.getSectionProps().forEach((name, props) -> {
|
|
||||||
((SectionStage) stage).execute(name, props, sections.get(name));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
((GlobalStage) stage).execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long ending = System.currentTimeMillis() - starting;
|
long ending = System.currentTimeMillis() - starting;
|
||||||
@ -127,7 +122,7 @@ public class SectionManager {
|
|||||||
sections.put(sectionName, object);
|
sections.put(sectionName, object);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new GlobalStage("Processing principal section") {
|
new Stage("Processing principal section") {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
principal = sections.get(props.getPrincipalSectionName());
|
principal = sections.get(props.getPrincipalSectionName());
|
||||||
@ -200,7 +195,7 @@ public class SectionManager {
|
|||||||
new SectionStage("Resolving servers") {
|
new SectionStage("Resolving servers") {
|
||||||
@Override
|
@Override
|
||||||
public void execute(String sectionName, SectionProps sectionProps, ServerSection section) throws RuntimeException {
|
public void execute(String sectionName, SectionProps sectionProps, ServerSection section) throws RuntimeException {
|
||||||
section.setServers(calculateServers(section));
|
section.getServers().addAll(calculateServers(section));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new SectionStage("Section server processing") {
|
new SectionStage("Section server processing") {
|
||||||
@ -322,26 +317,26 @@ public class SectionManager {
|
|||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Stage {
|
private abstract class Stage {
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
private Stage(String title) {
|
private Stage(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void execute() throws RuntimeException;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class GlobalStage extends Stage {
|
private abstract class SectionStage extends Stage {
|
||||||
private GlobalStage(String title) {
|
private SectionStage(String title) {
|
||||||
super(title);
|
super(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void execute(
|
@Override
|
||||||
) throws RuntimeException;
|
public void execute() throws RuntimeException {
|
||||||
}
|
props.getSectionProps().forEach((name, props) -> {
|
||||||
|
execute(name, props, sections.get(name));
|
||||||
private static abstract class SectionStage extends Stage {
|
});
|
||||||
private SectionStage(String title) {
|
|
||||||
super(title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void execute(
|
public abstract void execute(
|
||||||
|
@ -98,18 +98,10 @@ public class ServerSection {
|
|||||||
this.command = command;
|
this.command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addServer(ServerInfo server) {
|
|
||||||
servers.add(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<ServerInfo> getServers() {
|
public Set<ServerInfo> getServers() {
|
||||||
return servers;
|
return servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServers(Set<ServerInfo> servers) {
|
|
||||||
this.servers = servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# LobbyBalancer Configuration (https://www.spigotmc.org/resources/10788/)
|
# PlayerBalancer Configuration (https://www.spigotmc.org/resources/10788/)
|
||||||
# Read the comments, they are a very important part of the configuration
|
# Read the comments, they are a very important part of the configuration
|
||||||
# To get support send me a private message with a description of the problem and the config file
|
# To get support send me a private message with a description of the problem and the config file
|
||||||
# To easily paste the config file (and other relevant files) use the command /balancer paste
|
# To easily paste the config file (and other relevant files) use the command /balancer paste
|
||||||
|
@ -1,29 +1,8 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class GeneralTest {
|
public class GeneralTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() {
|
||||||
//Nothing to test
|
//Test
|
||||||
}
|
|
||||||
|
|
||||||
public String checkVersion() {
|
|
||||||
try {
|
|
||||||
final HttpURLConnection con = (HttpURLConnection)new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
|
||||||
con.setDoOutput(true);
|
|
||||||
con.setRequestMethod("POST");
|
|
||||||
con.getOutputStream().write("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=10788".getBytes("UTF-8"));
|
|
||||||
final String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
|
||||||
if (version.length() <= 7) {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ignored) {}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user