From 686ff8f5fb851168d0dcd5ff695db28dcb19f651 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 13 Jul 2019 20:41:11 +0200 Subject: [PATCH] Reworking players online and subsystem --- src/de/steamwar/bungeecore/Subserver.java | 36 ++--------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/de/steamwar/bungeecore/Subserver.java b/src/de/steamwar/bungeecore/Subserver.java index aa1e181..377b91f 100644 --- a/src/de/steamwar/bungeecore/Subserver.java +++ b/src/de/steamwar/bungeecore/Subserver.java @@ -3,9 +3,6 @@ package de.steamwar.bungeecore; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.ServerConnectedEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; import java.io.BufferedReader; import java.io.IOException; @@ -13,13 +10,12 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.InetSocketAddress; import java.util.ArrayList; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -public class Subserver implements Runnable, Listener { +public class Subserver implements Runnable { private static final List serverList = new LinkedList<>(); private static final Logger logger = ProxyServer.getInstance().getLogger(); @@ -43,7 +39,6 @@ public class Subserver implements Runnable, Listener { private boolean started; private final List cachedPlayers = new ArrayList<>(); - private final List players = new ArrayList<>(); public Subserver(Servertype type, String serverName, int port, String... command){ this.started = false; @@ -80,7 +75,6 @@ public class Subserver implements Runnable, Listener { cachedPlayers.add(p); }else{ p.connect(server); - players.add(p); } } @@ -102,7 +96,7 @@ public class Subserver implements Runnable, Listener { } private boolean onServer(ProxiedPlayer p){ - return cachedPlayers.contains(p) || players.contains(p); + return cachedPlayers.contains(p) || server.getPlayers().contains(p); } private void fatalError(){ @@ -110,14 +104,12 @@ public class Subserver implements Runnable, Listener { cached.sendMessage(Persistent.getPrefix() + "§cUnerwarteter Fehler beim Serverstart."); } for(ProxiedPlayer player : server.getPlayers()){ - player.connect(ProxyServer.getInstance().getServerInfo(Persistent.getLobbyServer())); player.sendMessage(Persistent.getPrefix() + "§cUnerwarteter Fehler im Server."); } } public void run(){ ProxyServer.getInstance().getServers().put(serverName, server); - ProxyServer.getInstance().getPluginManager().registerListener(Persistent.getInstance(), this); serverList.add(this); try(BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))){ @@ -151,30 +143,6 @@ public class Subserver implements Runnable, Listener { } finally { serverList.remove(this); ProxyServer.getInstance().getServers().remove(serverName); - ProxyServer.getInstance().getPluginManager().unregisterListener(this); - } - } - - @EventHandler - public void onServerSwitchEvent(ServerConnectedEvent e){ - ProxiedPlayer player = e.getPlayer(); - if(player.getServer() == null || player.getServer().getInfo() == null || player.getServer().getInfo().equals(server)) - return; - - Iterator it = cachedPlayers.iterator(); - while(it.hasNext()){ - if(it.next().equals(player)){ - it.remove(); - return; - } - } - - it = players.iterator(); - while(it.hasNext()){ - if(it.next().equals(player)){ - it.remove(); - return; - } } } }