From 4de062176a5caffcdb10315339be688a201d73db Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 21 Jun 2021 16:52:39 +0200 Subject: [PATCH 1/3] Better Tablist footer --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 8 +++----- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index c0b12fd..c25be00 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -131,15 +131,13 @@ public class TablistManager extends BasicListener { } private String calcHeader(ProxiedPlayer player){ - int phase = (seconds % 16) / 4; + int phase = (seconds % 16) / 3; switch(phase){ case 0: - return Message.parse("TABLIST_PHASE_0", player, ProxyServer.getInstance().getPlayers().size()); + return Message.parse("TABLIST_PHASE_0", player); 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); } @@ -161,7 +159,7 @@ public class TablistManager extends BasicListener { try { ServerInfo currentServer = player.getServer().getInfo(); setHeader(calcHeader(player)); - setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms"); + setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); setSize(size, 20); int i = 0; diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index a92b7c5..8cee5b1 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -475,10 +475,10 @@ POLL_ANWSER=§7{0} POLL_ANWSER_HOVER=§e{0} §ewählen #TablistManager -TABLIST_PHASE_0=§8Spieler online: §e{0} -TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de -TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord +TABLIST_PHASE_0=§8Teamspeak: §eSteam§8War.de +TABLIST_PHASE_1=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de +TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} TABLIST_BAU=Bau #EventStarter From 66899e8df17a7ebafef1ff7cecf386ee0a7d834a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 22 Jun 2021 12:21:50 +0200 Subject: [PATCH 2/3] Update Tablist slim Mode! --- .../bungeecore/listeners/TablistManager.java | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index c25be00..6f6fe4f 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.stream.Collectors; public class TablistManager extends BasicListener { @@ -81,24 +82,19 @@ public class TablistManager extends BasicListener { private synchronized void updateCustomTablist(){ //Calculate server-player-map playerMap.clear(); - for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ + for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { Server pserver = player.getServer(); - if(pserver == null) //Happens temporarily + if (pserver == null) //Happens temporarily continue; ServerInfo server = pserver.getInfo(); String serverName = server.getName(); Subserver subserver = Subserver.getSubserver(server); - List players; - if(subserver != null && subserver.getType() == Servertype.BAUSERVER){ - players = playerMap.getOrDefault("Bau", new ArrayList<>()); - players.add(player); - playerMap.putIfAbsent("Bau", players); - }else{ - players = playerMap.getOrDefault(serverName, new ArrayList<>()); - players.add(player); - playerMap.putIfAbsent(serverName, players); + if (subserver != null && subserver.getType() == Servertype.BAUSERVER) { + playerMap.computeIfAbsent("Bau", s -> new ArrayList<>()).add(player); + } else { + playerMap.computeIfAbsent(serverName, s -> new ArrayList<>()).add(player); } } playerMap.forEach((server, players) -> players.sort((proxiedPlayer, t1) -> proxiedPlayer.getName().compareToIgnoreCase(t1.getName()))); @@ -155,13 +151,17 @@ public class TablistManager extends BasicListener { } private void refresh(){ + ServerInfo currentServer = player.getServer().getInfo(); + setHeader(calcHeader(player)); + setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); + setSize(size, 20); + + if (size >= 5) { + refreshSlim(currentServer); + return; + } try { - ServerInfo currentServer = player.getServer().getInfo(); - setHeader(calcHeader(player)); - setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); - setSize(size, 20); - int i = 0; for (String server : playerMap.navigableKeySet()) { if (i > 0){ @@ -189,6 +189,54 @@ public class TablistManager extends BasicListener { } } + private void refreshSlim(ServerInfo currentServer) { + try { + int i = 0; + boolean spacer = true; + for (String server : playerMap.navigableKeySet()) { + if (i > 0 && spacer) { + setSlot(i%20, i/20, darkGray, "", 1000); + i++; + } + spacer = true; + List players = playerMap.get(server) + .stream() + .filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member) + .collect(Collectors.toList()); + if (server.equals("Bau")) { + Subserver subserver = Subserver.getSubserver(player); + if (subserver != null && subserver.getType() == Servertype.BAUSERVER) { + players = playerMap.get(server); + } + server = Message.parse("TABLIST_BAU", player); + } + int increment = playerMap.get(server).size() - players.size(); + if (players.isEmpty()) { + server += " §7(" + increment + ")"; + spacer = false; + } else if (increment != 0) { + server += " §7(+" + increment + ")"; + } + + setSlot(i%20, i/20, gray, "§7§l" + server, 1000); + i++; + for (ProxiedPlayer p : players){ + boolean sameServer = currentServer == p.getServer().getInfo(); + setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p, sameServer), (sameServer ? 1 : 500)); + i++; + } + } + + while (i < size*20){ + setSlot(i%20, i/20, darkGray, "", 1000); + i++; + } + }catch(IndexOutOfBoundsException | NullPointerException e){ + //Ignore IndexOutOfBoundsException + //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting + } + } + private String getTablistName(ProxiedPlayer p, boolean sameServer) { Subserver server = Subserver.getSubserver(p); if(server != null){ From 8705e19aec7f04a1ead6706e37907173afcb0074 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Jun 2021 17:41:05 +0200 Subject: [PATCH 3/3] Update Tablist slim Mode! --- src/de/steamwar/bungeecore/listeners/TablistManager.java | 7 ++++--- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 6f6fe4f..6a1d965 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -130,9 +130,9 @@ public class TablistManager extends BasicListener { int phase = (seconds % 16) / 3; switch(phase){ case 0: - return Message.parse("TABLIST_PHASE_0", player); - case 1: return Message.parse("TABLIST_PHASE_1", player); + case 1: + return Message.parse("TABLIST_PHASE_2", player); case 2: default: return Message.parse("TABLIST_PHASE_DEFAULT", player); @@ -153,7 +153,8 @@ public class TablistManager extends BasicListener { private void refresh(){ ServerInfo currentServer = player.getServer().getInfo(); setHeader(calcHeader(player)); - setFooter(Message.parse("TABLIST_FOOTER", player, currentServer.getName(), getPing(), ProxyServer.getInstance().getPlayers().size())); + // TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} + setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms §eSpieler§8: §7" + ProxyServer.getInstance().getPlayers().size()); setSize(size, 20); if (size >= 5) { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 8cee5b1..a92b7c5 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -475,10 +475,10 @@ POLL_ANWSER=§7{0} POLL_ANWSER_HOVER=§e{0} §ewählen #TablistManager -TABLIST_PHASE_0=§8Teamspeak: §eSteam§8War.de -TABLIST_PHASE_1=§8Discord: §8https://§eSteam§8War.de/discord +TABLIST_PHASE_0=§8Spieler online: §e{0} +TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de +TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de -TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} TABLIST_BAU=Bau #EventStarter