From 70a8d8e3ed0916cbc3f47b62f8d0c7f6aaf67f48 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 17:16:16 +0200 Subject: [PATCH 1/4] Add Team showcase in tablist --- src/de/steamwar/bungeecore/tablist/TablistPart.java | 12 +++++++++++- .../steamwar/bungeecore/tablist/TablistServer.java | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/TablistPart.java b/src/de/steamwar/bungeecore/tablist/TablistPart.java index 2388116..b140114 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistPart.java +++ b/src/de/steamwar/bungeecore/tablist/TablistPart.java @@ -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); } diff --git a/src/de/steamwar/bungeecore/tablist/TablistServer.java b/src/de/steamwar/bungeecore/tablist/TablistServer.java index 0a95a48..3e47f26 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistServer.java +++ b/src/de/steamwar/bungeecore/tablist/TablistServer.java @@ -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; @@ -73,7 +75,13 @@ public class TablistServer implements TablistPart { items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY)); } - items.addAll(players); + 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).getTeam() != team) return item; + return new Item(p, true); + }).forEach(items::add); } private void addPlayers(String prefix, List teamPlayers, Collection onlinePlayers){ -- 2.39.2 From f2a8cb064e399d66cee35c9da9efb43fabab2846 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 17:27:19 +0200 Subject: [PATCH 2/4] Add Team showcase in tablist --- .../steamwar/bungeecore/tablist/TablistBuild.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/TablistBuild.java b/src/de/steamwar/bungeecore/tablist/TablistBuild.java index dcb8f67..58e7ff4 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistBuild.java +++ b/src/de/steamwar/bungeecore/tablist/TablistBuild.java @@ -21,7 +21,9 @@ 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; @@ -62,8 +64,15 @@ 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)); + 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).getTeam() != team) return item; + return new Item(p, true); + }).forEach(((server == info) ? direct : tablist)::add); } } } -- 2.39.2 From fe4280f9e3ce2f9a5fa475d38e2dceaf6043225e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 17:30:02 +0200 Subject: [PATCH 3/4] Add Team showcase in tablist --- src/de/steamwar/bungeecore/tablist/TablistBuild.java | 2 +- src/de/steamwar/bungeecore/tablist/TablistServer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/TablistBuild.java b/src/de/steamwar/bungeecore/tablist/TablistBuild.java index 58e7ff4..db469f2 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistBuild.java +++ b/src/de/steamwar/bungeecore/tablist/TablistBuild.java @@ -70,7 +70,7 @@ public class TablistBuild implements TablistPart { .map(item -> { ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid()); if (p == null) return item; - if (SteamwarUser.get(p).getTeam() != team) return item; + if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item; return new Item(p, true); }).forEach(((server == info) ? direct : tablist)::add); } diff --git a/src/de/steamwar/bungeecore/tablist/TablistServer.java b/src/de/steamwar/bungeecore/tablist/TablistServer.java index 3e47f26..59a56f2 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistServer.java +++ b/src/de/steamwar/bungeecore/tablist/TablistServer.java @@ -79,7 +79,7 @@ public class TablistServer implements TablistPart { players.stream().map(item -> { ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid()); if (p == null) return item; - if (SteamwarUser.get(p).getTeam() != team) return item; + if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item; return new Item(p, true); }).forEach(items::add); } -- 2.39.2 From 79bd9598c727169a82cc5e756fb9dab550495ae4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 17:42:55 +0200 Subject: [PATCH 4/4] Add Team showcase in tablist --- .../bungeecore/tablist/TablistBuild.java | 12 ++---------- .../bungeecore/tablist/TablistServer.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/de/steamwar/bungeecore/tablist/TablistBuild.java b/src/de/steamwar/bungeecore/tablist/TablistBuild.java index db469f2..15039fe 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistBuild.java +++ b/src/de/steamwar/bungeecore/tablist/TablistBuild.java @@ -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); } } } diff --git a/src/de/steamwar/bungeecore/tablist/TablistServer.java b/src/de/steamwar/bungeecore/tablist/TablistServer.java index 59a56f2..2a63645 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistServer.java +++ b/src/de/steamwar/bungeecore/tablist/TablistServer.java @@ -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 teamPlayers, Collection 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 teamify(List 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); + }); + } } -- 2.39.2