From 8acdd3cb7fdbfe4f79f60ae2744595c0d73f9fb8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 11 Sep 2021 17:12:41 +0200 Subject: [PATCH] Fix synchronisation issues --- src/de/steamwar/bungeecore/Subserver.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index cf3e9b8..6e324f3 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -46,16 +46,20 @@ public class Subserver implements Runnable { private static final Logger logger = ProxyServer.getInstance().getLogger(); public static Subserver getSubserver(ProxiedPlayer p){ - for(int i = serverList.size()-1; i >= 0; i--){ - if(serverList.get(i).onServer(p)) - return serverList.get(i); + synchronized (serverList) { + for(int i = serverList.size()-1; i >= 0; i--){ + if(serverList.get(i).onServer(p)) + return serverList.get(i); + } } return null; } public static Subserver getSubserver(ServerInfo server){ - for(Subserver s : serverList) - if(s.server == server) - return s; + synchronized (serverList) { + for(Subserver s : serverList) + if(s.server == server) + return s; + } return null; } public static List getServerList(){ @@ -179,7 +183,9 @@ public class Subserver implements Runnable { public void run(){ ProxyServer.getInstance().getServers().put(serverName, server); - serverList.add(this); + synchronized (serverList) { + serverList.add(this); + } try(BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))){ String line = "";