geforkt von SteamWar/BungeeCore
Fix tablist
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
e1cd7b9c52
Commit
18cb65a28b
@ -41,6 +41,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TablistManager extends BasicListener {
|
||||
|
||||
@ -51,7 +52,7 @@ public class TablistManager extends BasicListener {
|
||||
private Icon gray;
|
||||
|
||||
private int size;
|
||||
private TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>();
|
||||
private final TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>();
|
||||
|
||||
public TablistManager(){
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateCustomTablist, 1, 1, TimeUnit.SECONDS);
|
||||
@ -67,21 +68,6 @@ public class TablistManager extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
private String calcHeader(ProxiedPlayer player){
|
||||
int phase = (seconds % 16) / 4;
|
||||
switch(phase){
|
||||
case 0:
|
||||
return Message.parse("TABLIST_PHASE_0", player, ProxyServer.getInstance().getPlayers().size());
|
||||
case 1:
|
||||
return Message.parse("TABLIST_PHASE_1", player);
|
||||
case 2:
|
||||
return Message.parse("TABLIST_PHASE_2", player);
|
||||
case 3:
|
||||
default:
|
||||
return Message.parse("TABLIST_PHASE_DEFAULT", player);
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateSize(){
|
||||
size = -1;
|
||||
for(Map.Entry<String, List<ProxiedPlayer>> server : playerMap.entrySet())
|
||||
@ -107,9 +93,9 @@ public class TablistManager extends BasicListener {
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
List<ProxiedPlayer> players;
|
||||
if(subserver != null && subserver.getType() == Servertype.BAUSERVER){
|
||||
players = playerMap.getOrDefault("%bauserverplaceholder%", new ArrayList<>());
|
||||
players = playerMap.getOrDefault("Bau", new ArrayList<>());
|
||||
players.add(player);
|
||||
playerMap.putIfAbsent("%bauserverplaceholder%", players);
|
||||
playerMap.putIfAbsent("Bau", players);
|
||||
}else{
|
||||
players = playerMap.getOrDefault(serverName, new ArrayList<>());
|
||||
players.add(player);
|
||||
@ -145,6 +131,21 @@ public class TablistManager extends BasicListener {
|
||||
BungeeTabListPlusAPI.setCustomTabList(player, this);
|
||||
}
|
||||
|
||||
private String calcHeader(ProxiedPlayer player){
|
||||
int phase = (seconds % 16) / 4;
|
||||
switch(phase){
|
||||
case 0:
|
||||
return Message.parse("TABLIST_PHASE_0", player, ProxyServer.getInstance().getPlayers().size());
|
||||
case 1:
|
||||
return Message.parse("TABLIST_PHASE_1", player);
|
||||
case 2:
|
||||
return Message.parse("TABLIST_PHASE_2", player);
|
||||
case 3:
|
||||
default:
|
||||
return Message.parse("TABLIST_PHASE_DEFAULT", player);
|
||||
}
|
||||
}
|
||||
|
||||
private String getPing(){
|
||||
int ping = player.getPing();
|
||||
if(ping < 50){
|
||||
@ -170,7 +171,7 @@ public class TablistManager extends BasicListener {
|
||||
setSlot(i%20, i/20, darkGray, "", 1000);
|
||||
i++;
|
||||
}
|
||||
if(server.equals("%bauserverplaceholder%"))
|
||||
if(server.equals("Bau"))
|
||||
server = Message.parse("TABLIST_BAU", player);
|
||||
setSlot(i%20, i/20, gray, "§7§l" + server, 1000);
|
||||
i++;
|
||||
@ -186,6 +187,7 @@ public class TablistManager extends BasicListener {
|
||||
i++;
|
||||
}
|
||||
}catch(IndexOutOfBoundsException | NullPointerException e){
|
||||
ProxyServer.getInstance().getLogger().log(Level.WARNING, "Whaaa", e);
|
||||
//Ignore IndexOutOfBoundsException
|
||||
//Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren