geforkt von SteamWar/BungeeCore
Update Tablist slim Mode!
Dieser Commit ist enthalten in:
Ursprung
0769057d8f
Commit
66899e8df1
@ -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<ProxiedPlayer> 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(){
|
||||
|
||||
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);
|
||||
|
||||
if (size >= 5) {
|
||||
refreshSlim(currentServer);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
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<ProxiedPlayer> 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){
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren