Archiviert
1
0

Add TablistManager MultiLang

Dieser Commit ist enthalten in:
Chaoscaot 2021-01-19 17:39:51 +01:00
Ursprung 1b69057eea
Commit 6bd9cd6fdd
2 geänderte Dateien mit 32 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,7 @@ import codecrafter47.bungeetablistplus.api.bungee.BungeeTabListPlusAPI;
import codecrafter47.bungeetablistplus.api.bungee.Icon; import codecrafter47.bungeetablistplus.api.bungee.Icon;
import codecrafter47.bungeetablistplus.tablist.DefaultCustomTablist; import codecrafter47.bungeetablistplus.tablist.DefaultCustomTablist;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
@ -49,7 +50,6 @@ public class TablistManager extends BasicListener {
private Icon darkGray; private Icon darkGray;
private Icon gray; private Icon gray;
private String header;
private int size; private int size;
private TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>(); private TreeMap<String, List<ProxiedPlayer>> playerMap = new TreeMap<>();
@ -67,25 +67,25 @@ public class TablistManager extends BasicListener {
} }
} }
private void calcHeader(){ private String calcHeader(ProxiedPlayer player){
if(seconds % 4 == 0){ String header;
int phase = (seconds % 16) / 4; int phase = (seconds % 16) / 4;
switch(phase){ switch(phase){
case 0: case 0:
header = "§8Spieler online: §e" + ProxyServer.getInstance().getPlayers().size(); header = Message.parse("TABLIST_PHASE_0", player, ProxyServer.getInstance().getPlayers().size());
break; break;
case 1: case 1:
header = "§8Teamspeak: §eSteam§8War.de"; header = Message.parse("TABLIST_PHASE_1", player);
break; break;
case 2: case 2:
header = "§8Discord: §8https://discord.gg/J4NtQmM"; header = Message.parse("TABLIST_PHASE_2", player);
break; break;
case 3: case 3:
default: default:
header = "§8Website: https://§eSteam§8War.de"; header = Message.parse("TABLIST_PHASE_DEFAULT", player);
break; break;
}
} }
return header;
} }
private void calculateSize(){ private void calculateSize(){
@ -100,8 +100,6 @@ public class TablistManager extends BasicListener {
} }
private synchronized void updateCustomTablist(){ private synchronized void updateCustomTablist(){
calcHeader();
//Calculate server-player-map //Calculate server-player-map
playerMap.clear(); playerMap.clear();
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){ for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
@ -115,9 +113,9 @@ public class TablistManager extends BasicListener {
Subserver subserver = Subserver.getSubserver(server); Subserver subserver = Subserver.getSubserver(server);
List<ProxiedPlayer> players; List<ProxiedPlayer> players;
if(subserver != null && subserver.getType() == Servertype.BAUSERVER){ if(subserver != null && subserver.getType() == Servertype.BAUSERVER){
players = playerMap.getOrDefault("Bau", new ArrayList<>()); players = playerMap.getOrDefault("%bauserverplaceholder%", new ArrayList<>());
players.add(player); players.add(player);
playerMap.putIfAbsent("Bau", players); playerMap.putIfAbsent("%bauserverplaceholder%", players);
}else{ }else{
players = playerMap.getOrDefault(serverName, new ArrayList<>()); players = playerMap.getOrDefault(serverName, new ArrayList<>());
players.add(player); players.add(player);
@ -168,7 +166,7 @@ public class TablistManager extends BasicListener {
try { try {
ServerInfo currentServer = player.getServer().getInfo(); ServerInfo currentServer = player.getServer().getInfo();
setHeader(header); setHeader(calcHeader(player));
setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms"); setFooter("§e" + currentServer.getName() + " " + getPing() + "§8ms");
setSize(size, 20); setSize(size, 20);
@ -178,6 +176,8 @@ public class TablistManager extends BasicListener {
setSlot(i%20, i/20, darkGray, "", 1000); setSlot(i%20, i/20, darkGray, "", 1000);
i++; i++;
} }
if(server.equals("%bauserverplaceholder%"))
server = Message.parse("TABLIST_BAU", player);
setSlot(i%20, i/20, gray, "§7§l" + server, 1000); setSlot(i%20, i/20, gray, "§7§l" + server, 1000);
i++; i++;
for (ProxiedPlayer p : playerMap.get(server)){ for (ProxiedPlayer p : playerMap.get(server)){

Datei anzeigen

@ -450,3 +450,10 @@ POLL_HEADER2=§7Klicke die Antwort an, die dir gefällt!
POLL_QUESTION=§e{0} POLL_QUESTION=§e{0}
POLL_ANWSER=§7{0} POLL_ANWSER=§7{0}
POLL_ANWSER_HOVER=§e{0} §ewählen 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