Reworking players online and subsystem
Dieser Commit ist enthalten in:
Ursprung
3786a1170a
Commit
686ff8f5fb
@ -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<Subserver> 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<ProxiedPlayer> cachedPlayers = new ArrayList<>();
|
||||
private final List<ProxiedPlayer> 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<ProxiedPlayer> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren