From cd8706b67f192a014d6a64402d9a72a7528d7a38 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 19 Jan 2024 20:21:52 +0100 Subject: [PATCH] Fix Uniqueness issues --- src/de/steamwar/bungeecore/Arenaserver.java | 2 +- src/de/steamwar/bungeecore/Bauserver.java | 2 +- src/de/steamwar/bungeecore/Builderserver.java | 2 +- src/de/steamwar/bungeecore/Subserver.java | 14 +++++--------- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/de/steamwar/bungeecore/Arenaserver.java b/src/de/steamwar/bungeecore/Arenaserver.java index cd2a5fd..8c1a734 100644 --- a/src/de/steamwar/bungeecore/Arenaserver.java +++ b/src/de/steamwar/bungeecore/Arenaserver.java @@ -10,7 +10,7 @@ public class Arenaserver extends Subserver { private final boolean allowMerge; public Arenaserver(String serverName, String mode, String map, boolean allowMerge, int port, ProcessBuilder processBuilder, Runnable shutdownCallback) { - super(Servertype.ARENA, serverName, port, processBuilder, shutdownCallback); + super(Servertype.ARENA, serverName, port, processBuilder, shutdownCallback, null); this.mode = mode; this.map = map; this.allowMerge = allowMerge; diff --git a/src/de/steamwar/bungeecore/Bauserver.java b/src/de/steamwar/bungeecore/Bauserver.java index 5fe0881..9fff3d9 100644 --- a/src/de/steamwar/bungeecore/Bauserver.java +++ b/src/de/steamwar/bungeecore/Bauserver.java @@ -38,7 +38,7 @@ public class Bauserver extends Subserver { private final UUID owner; public Bauserver(String serverName, UUID owner, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){ - super(Servertype.BAUSERVER, serverName, port, processBuilder, shutdownCallback); + super(Servertype.BAUSERVER, serverName, port, processBuilder, shutdownCallback, null); this.owner = owner; } diff --git a/src/de/steamwar/bungeecore/Builderserver.java b/src/de/steamwar/bungeecore/Builderserver.java index 2968d6b..fd3e8f7 100644 --- a/src/de/steamwar/bungeecore/Builderserver.java +++ b/src/de/steamwar/bungeecore/Builderserver.java @@ -37,7 +37,7 @@ public class Builderserver extends Subserver { private final String map; public Builderserver(String serverName, String map, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){ - super(Servertype.BUILDER, serverName, port, processBuilder, shutdownCallback); + super(Servertype.BUILDER, serverName, port, processBuilder, shutdownCallback, null); this.map = map; } diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index 9abee32..37ef123 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -47,7 +47,7 @@ public class Subserver { @Getter private static final List serverList = new LinkedList<>(); - private static final Map infoToServer = new HashMap<>(); + private static final Map infoToServer = new HashMap<>(); public static Subserver getSubserver(ProxiedPlayer p) { synchronized (serverList) { @@ -61,7 +61,7 @@ public class Subserver { public static Subserver getSubserver(ServerInfo server) { synchronized (serverList) { - return infoToServer.get(server); + return infoToServer.get(server.getName()); } } @@ -90,11 +90,7 @@ public class Subserver { @Getter private final Map tablistNames = new HashMap<>(); - public Subserver(Servertype type, String serverName, int port, ProcessBuilder processBuilder, Runnable shutdownCallback){ - this(type, serverName, port, processBuilder, shutdownCallback, null); - } - - public Subserver(Servertype type, String serverName, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer failureCallback) { + protected Subserver(Servertype type, String serverName, int port, ProcessBuilder processBuilder, Runnable shutdownCallback, Consumer failureCallback) { this.started = false; this.serverName = serverName; this.type = type; @@ -188,13 +184,13 @@ public class Subserver { servers.put(serverName, server); synchronized (serverList) { serverList.add(this); - infoToServer.put(server, this); + infoToServer.put(serverName, this); } } protected void unregister() { synchronized (serverList){ - infoToServer.remove(server); + infoToServer.remove(serverName); serverList.remove(this); } servers.remove(serverName);