SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Add Team showcase in tablist' (#438) from TeamTablist into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #438
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-10-24 17:44:15 +02:00
Commit 67a7b60bdc
3 geänderte Dateien mit 28 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -62,8 +62,9 @@ public class TablistBuild implements TablistPart {
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
}
for(ServerInfo info : servers) {
(server == info ? direct : tablist).addAll(players.get(info));
for (ServerInfo info : servers) {
TablistServer.teamify(players.get(info), player)
.forEach(((server == info) ? direct : tablist)::add);
}
}
}

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bungeecore.tablist;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -51,8 +52,17 @@ interface TablistPart {
}
public Item(ProxiedPlayer player) {
this(player, false);
}
public Item(ProxiedPlayer player, boolean sameTeam) {
this.uuid = player.getUniqueId();
this.displayName = reformat(SteamwarUser.get(player.getUniqueId()).getUserGroup().getColorCode() + player.getName());
UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup();
if (userGroup == UserGroup.Member && sameTeam) {
this.displayName = reformat("§f" + player.getName());
} else {
this.displayName = reformat(userGroup.getColorCode() + player.getName());
}
this.properties = playerProperties(player);
}

Datei anzeigen

@ -19,9 +19,11 @@
package de.steamwar.bungeecore.tablist;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.Property;
@ -31,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 {
@ -73,7 +76,7 @@ public class TablistServer implements TablistPart {
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY));
}
items.addAll(players);
teamify(players, player).forEach(items::add);
}
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
@ -83,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);
});
}
}