From 6bd9cd6fddcfc11e2686c633ed7430f899f9230d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 19 Jan 2021 17:39:51 +0100 Subject: [PATCH] Add TablistManager MultiLang --- .../bungeecore/listeners/TablistManager.java | 48 +++++++++---------- .../steamwar/messages/BungeeCore.properties | 9 +++- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/TablistManager.java b/src/de/steamwar/bungeecore/listeners/TablistManager.java index 123ef94..a7dbc03 100644 --- a/src/de/steamwar/bungeecore/listeners/TablistManager.java +++ b/src/de/steamwar/bungeecore/listeners/TablistManager.java @@ -23,6 +23,7 @@ import codecrafter47.bungeetablistplus.api.bungee.BungeeTabListPlusAPI; import codecrafter47.bungeetablistplus.api.bungee.Icon; import codecrafter47.bungeetablistplus.tablist.DefaultCustomTablist; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.sql.SteamwarUser; @@ -49,7 +50,6 @@ public class TablistManager extends BasicListener { private Icon darkGray; private Icon gray; - private String header; private int size; private TreeMap> playerMap = new TreeMap<>(); @@ -67,25 +67,25 @@ public class TablistManager extends BasicListener { } } - private void calcHeader(){ - if(seconds % 4 == 0){ - int phase = (seconds % 16) / 4; - switch(phase){ - case 0: - header = "§8Spieler online: §e" + ProxyServer.getInstance().getPlayers().size(); - break; - case 1: - header = "§8Teamspeak: §eSteam§8War.de"; - break; - case 2: - header = "§8Discord: §8https://discord.gg/J4NtQmM"; - break; - case 3: - default: - header = "§8Website: https://§eSteam§8War.de"; - break; - } + private String calcHeader(ProxiedPlayer player){ + String header; + int phase = (seconds % 16) / 4; + switch(phase){ + case 0: + header = Message.parse("TABLIST_PHASE_0", player, ProxyServer.getInstance().getPlayers().size()); + break; + case 1: + header = Message.parse("TABLIST_PHASE_1", player); + break; + case 2: + header = Message.parse("TABLIST_PHASE_2", player); + break; + case 3: + default: + header = Message.parse("TABLIST_PHASE_DEFAULT", player); + break; } + return header; } private void calculateSize(){ @@ -100,8 +100,6 @@ public class TablistManager extends BasicListener { } private synchronized void updateCustomTablist(){ - calcHeader(); - //Calculate server-player-map playerMap.clear(); for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ @@ -115,9 +113,9 @@ public class TablistManager extends BasicListener { Subserver subserver = Subserver.getSubserver(server); List players; if(subserver != null && subserver.getType() == Servertype.BAUSERVER){ - players = playerMap.getOrDefault("Bau", new ArrayList<>()); + players = playerMap.getOrDefault("%bauserverplaceholder%", new ArrayList<>()); players.add(player); - playerMap.putIfAbsent("Bau", players); + playerMap.putIfAbsent("%bauserverplaceholder%", players); }else{ players = playerMap.getOrDefault(serverName, new ArrayList<>()); players.add(player); @@ -168,7 +166,7 @@ public class TablistManager extends BasicListener { try { ServerInfo currentServer = player.getServer().getInfo(); - setHeader(header); + setHeader(calcHeader(player)); setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms"); setSize(size, 20); @@ -178,6 +176,8 @@ public class TablistManager extends BasicListener { setSlot(i%20, i/20, darkGray, "", 1000); i++; } + if(server.equals("%bauserverplaceholder%")) + server = Message.parse("TABLIST_BAU", player); setSlot(i%20, i/20, gray, "§7§l" + server, 1000); i++; for (ProxiedPlayer p : playerMap.get(server)){ diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index f9c6f7c..259253d 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -449,4 +449,11 @@ POLL_HEADER=§e§lUmfrage POLL_HEADER2=§7Klicke die Antwort an, die dir gefällt! POLL_QUESTION=§e{0} POLL_ANWSER=§7{0} -POLL_ANWSER_HOVER=§e{0} §ewählen \ No newline at end of file +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_DEFAULT=§8Website: https://§eSteam§8War.de +TABLIST_BAU=Bau \ No newline at end of file