Archiviert
1
0

Update TablistManager

Dieser Commit ist enthalten in:
yoyosource 2021-06-25 15:41:26 +02:00
Ursprung edbaddbee6
Commit 71c206e59c

Datei anzeigen

@ -174,17 +174,10 @@ public class TablistManager extends BasicListener {
server = Message.parse("TABLIST_BAU", player); 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)){ i = update(currentServer, playerMap.get(server), i);
boolean sameServer = currentServer == p.getServer().getInfo();
setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500));
i++;
}
} }
while (i < size*20){ finish(i);
setSlot(i%20, i/20, darkGray, "", 1000);
i++;
}
}catch(IndexOutOfBoundsException | NullPointerException e){ }catch(IndexOutOfBoundsException | NullPointerException e){
//Ignore IndexOutOfBoundsException //Ignore IndexOutOfBoundsException
//Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting
@ -223,23 +216,32 @@ public class TablistManager extends BasicListener {
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 : players){ i = update(currentServer, players, i);
boolean sameServer = currentServer == p.getServer().getInfo();
setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500));
i++;
}
} }
while (i < size*20){ finish(i);
setSlot(i%20, i/20, darkGray, "", 1000);
i++;
}
}catch(IndexOutOfBoundsException | NullPointerException e){ }catch(IndexOutOfBoundsException | NullPointerException e){
//Ignore IndexOutOfBoundsException //Ignore IndexOutOfBoundsException
//Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting //Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting
} }
} }
private int update(ServerInfo currentServer, List<ProxiedPlayer> players, int i) {
for (ProxiedPlayer p : players){
boolean sameServer = currentServer == p.getServer().getInfo();
setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500));
i++;
}
return i;
}
private void finish(int i) {
while (i < size*20){
setSlot(i%20, i/20, darkGray, "", 1000);
i++;
}
}
private Team getTeam(ProxiedPlayer p) { private Team getTeam(ProxiedPlayer p) {
Team team = Team.get(SteamwarUser.get(p).getTeam()); Team team = Team.get(SteamwarUser.get(p).getTeam());
return team.getTeamId() <= 0 ? null : team; return team.getTeamId() <= 0 ? null : team;