Archiviert
1
0

Add Team showcase in tablist

Dieser Commit ist enthalten in:
yoyosource 2022-10-24 17:42:55 +02:00
Ursprung fe4280f9e3
Commit 79bd9598c7
2 geänderte Dateien mit 14 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -21,9 +21,7 @@ package de.steamwar.bungeecore.tablist;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -64,15 +62,9 @@ public class TablistBuild implements TablistPart {
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
}
int team = SteamwarUser.get(player).getTeam();
for (ServerInfo info : servers) {
players.get(info).stream()
.map(item -> {
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
if (p == null) return item;
if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item;
return new Item(p, true);
}).forEach(((server == info) ? direct : tablist)::add);
TablistServer.teamify(players.get(info), player)
.forEach(((server == info) ? direct : tablist)::add);
}
}
}

Datei anzeigen

@ -33,6 +33,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TablistServer implements TablistPart {
@ -75,13 +76,7 @@ public class TablistServer implements TablistPart {
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY));
}
int team = SteamwarUser.get(player).getTeam();
players.stream().map(item -> {
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
if (p == null) return item;
if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item;
return new Item(p, true);
}).forEach(items::add);
teamify(players, player).forEach(items::add);
}
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
@ -91,4 +86,14 @@ public class TablistServer implements TablistPart {
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player))));
}
public static Stream<Item> teamify(List<Item> players, ProxiedPlayer player) {
int team = SteamwarUser.get(player.getUniqueId()).getTeam();
return players.stream().map(item -> {
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
if (p == null) return item;
if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item;
return new Item(p, true);
});
}
}