geforkt von SteamWar/BungeeCore
Add Team showcase in tablist
Dieser Commit ist enthalten in:
Ursprung
fe4280f9e3
Commit
79bd9598c7
@ -21,9 +21,7 @@ package de.steamwar.bungeecore.tablist;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Servertype;
|
import de.steamwar.bungeecore.Servertype;
|
||||||
import de.steamwar.bungeecore.Subserver;
|
import de.steamwar.bungeecore.Subserver;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.BungeeCord;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
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));
|
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
int team = SteamwarUser.get(player).getTeam();
|
|
||||||
for (ServerInfo info : servers) {
|
for (ServerInfo info : servers) {
|
||||||
players.get(info).stream()
|
TablistServer.teamify(players.get(info), player)
|
||||||
.map(item -> {
|
.forEach(((server == info) ? direct : tablist)::add);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class TablistServer implements TablistPart {
|
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));
|
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
int team = SteamwarUser.get(player).getTeam();
|
teamify(players, player).forEach(items::add);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
|
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())
|
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
|
||||||
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player))));
|
).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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren