From 18cb65a28b2b3d3d63960fe09de7f91ad26edb1f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 5 Feb 2021 07:54:39 +0100 Subject: [PATCH] Fix tablist Signed-off-by: Lixfel --- .../bungeecore/listeners/TablistManager.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index eb491b3..073529b 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -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> playerMap = new TreeMap<>(); + private final TreeMap> 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> server : playerMap.entrySet()) @@ -107,9 +93,9 @@ public class TablistManager extends BasicListener { Subserver subserver = Subserver.getSubserver(server); List 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 }