Skip to content

Commit 29099a4

Browse files
committed
Fix error when using regular and non dummy sections
1 parent 1cc05e4 commit 29099a4

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

balancer/src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,25 @@ public ServerSection getByPlayer(ProxiedPlayer player) {
235235
}
236236

237237
public void registerServer(ServerInfo server, ServerSection section) {
238-
//Checking for duplicated server on non dummy sections
239-
if (servers.containsKey(server) && !isDummy(section)) {
240-
ServerSection other = servers.get(server);
241-
throw new IllegalArgumentException(String.format(
242-
"The server \"%s\" is already in the section \"%s\"",
238+
if (!isDummy(section)) {
239+
// Checking for already we already added this server to other section
240+
// This can only happen if another non dummy section registers this server
241+
if (servers.containsKey(server)) {
242+
ServerSection other = servers.get(server);
243+
throw new IllegalArgumentException(String.format(
244+
"The server \"%s\" is already in the section \"%s\"",
245+
server.getName(),
246+
other.getName()
247+
));
248+
}
249+
250+
plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"",
243251
server.getName(),
244-
other.getName()
252+
section.getName()
245253
));
246-
}
247-
248-
plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"",
249-
server.getName(),
250-
section.getName()
251-
));
252254

253-
servers.put(server, section);
255+
servers.put(server, section);
256+
}
254257
}
255258

256259
public void calculateServers(ServerSection section) {

0 commit comments

Comments
 (0)