geforkt von SteamWar/BungeeCore
Merge pull request 'Update Tablist colors' (#503) from TpAndTablist into master
Reviewed-on: SteamWar/BungeeCore#503
Dieser Commit ist enthalten in:
Commit
1b3ed278c6
@ -21,6 +21,8 @@ package de.steamwar.bungeecore.tablist;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Storage;
|
import de.steamwar.bungeecore.Storage;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.UserPerm;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
@ -212,13 +214,24 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
|||||||
break;
|
break;
|
||||||
case ADD_PLAYER:
|
case ADD_PLAYER:
|
||||||
boolean playerNotOnTeamserver = !Storage.teamServers.containsValue(player.getServer().getInfo());
|
boolean playerNotOnTeamserver = !Storage.teamServers.containsValue(player.getServer().getInfo());
|
||||||
|
SteamwarUser viewee = SteamwarUser.get(player.getUniqueId());
|
||||||
for (PlayerListItem.Item item : list.getItems()) {
|
for (PlayerListItem.Item item : list.getItems()) {
|
||||||
item.setPing(1);
|
item.setPing(1);
|
||||||
if (playerNotOnTeamserver) {
|
if (playerNotOnTeamserver) {
|
||||||
item.setDisplayName(new TextComponent());
|
item.setDisplayName(new TextComponent());
|
||||||
item.setListed(false);
|
item.setListed(false);
|
||||||
} else if (item.getDisplayName() == null) {
|
} else if (item.getDisplayName() == null) {
|
||||||
item.setDisplayName(TextComponent.fromLegacy("§7" + item.getUsername()));
|
String color = "§f";
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(item.getUuid());
|
||||||
|
if (steamwarUser == null) {
|
||||||
|
color = "§7";
|
||||||
|
} else {
|
||||||
|
UserPerm.Prefix prefix = steamwarUser.prefix();
|
||||||
|
if (prefix != UserPerm.emptyPrefix || !TablistServer.hasTeamColor(viewee, item.getUuid())) {
|
||||||
|
color = prefix.getChatPrefix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setDisplayName(TextComponent.fromLegacy(color + item.getUsername()));
|
||||||
}
|
}
|
||||||
item.setPublicKey(null);
|
item.setPublicKey(null);
|
||||||
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
|
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
|
||||||
@ -264,6 +277,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean playerNotOnTeamserver = !Storage.teamServers.containsValue(player.getServer().getInfo());
|
boolean playerNotOnTeamserver = !Storage.teamServers.containsValue(player.getServer().getInfo());
|
||||||
|
SteamwarUser viewee = SteamwarUser.get(player.getUniqueId());
|
||||||
for(PlayerListItemUpdate.Action action : actions) {
|
for(PlayerListItemUpdate.Action action : actions) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ADD_PLAYER:
|
case ADD_PLAYER:
|
||||||
@ -273,7 +287,17 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
|||||||
item.setDisplayName(new TextComponent());
|
item.setDisplayName(new TextComponent());
|
||||||
item.setListed(false);
|
item.setListed(false);
|
||||||
} else if (item.getDisplayName() == null) {
|
} else if (item.getDisplayName() == null) {
|
||||||
item.setDisplayName(TextComponent.fromLegacy("§7" + item.getUsername()));
|
String color = "§f";
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(item.getUuid());
|
||||||
|
if (steamwarUser == null) {
|
||||||
|
color = "§7";
|
||||||
|
} else {
|
||||||
|
UserPerm.Prefix prefix = steamwarUser.prefix();
|
||||||
|
if (prefix != UserPerm.emptyPrefix || !TablistServer.hasTeamColor(viewee, item.getUuid())) {
|
||||||
|
color = prefix.getChatPrefix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setDisplayName(TextComponent.fromLegacy(color + item.getUsername()));
|
||||||
}
|
}
|
||||||
item.setPublicKey(null);
|
item.setPublicKey(null);
|
||||||
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
|
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
|
||||||
|
@ -22,6 +22,8 @@ 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.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
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;
|
||||||
@ -62,9 +64,15 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||||
for (ServerInfo info : servers) {
|
for (ServerInfo info : servers) {
|
||||||
TablistServer.teamify(players.get(info), player)
|
players.get(info).forEach(item -> {
|
||||||
.forEach(((server == info) ? direct : tablist)::add);
|
if (TablistServer.hasTeamColor(steamwarUser, item.getUuid())) {
|
||||||
|
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
|
||||||
|
item = new Item(p, true);
|
||||||
|
}
|
||||||
|
(server == info ? direct : tablist).add(item);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,20 +21,16 @@ 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.sql.SteamwarUser;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.common.FightInfoPacket;
|
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
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;
|
||||||
import net.md_5.bungee.protocol.Property;
|
import net.md_5.bungee.protocol.Property;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
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 {
|
||||||
|
|
||||||
@ -77,7 +73,14 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
teamify(players, player).forEach(items::add);
|
SteamwarUser steamwarUser = viewer.user();
|
||||||
|
for (Item item : players) {
|
||||||
|
if (hasTeamColor(steamwarUser, item.getUuid())) {
|
||||||
|
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
|
||||||
|
item = new Item(p, true);
|
||||||
|
}
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
|
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
|
||||||
@ -88,16 +91,12 @@ public class TablistServer implements TablistPart {
|
|||||||
).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) {
|
public static boolean hasTeamColor(SteamwarUser viewer, UUID viewee) {
|
||||||
int team = SteamwarUser.get(player.getUniqueId()).getTeam();
|
if (viewer.getTeam() == 0) return false;
|
||||||
if (team == 0) return players.stream();
|
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(viewee);
|
||||||
return players.stream().map(item -> {
|
if (p == null) return false;
|
||||||
ProxiedPlayer p = BungeeCord.getInstance().getPlayer(item.getUuid());
|
|
||||||
if (p == null) return item;
|
|
||||||
Subserver subserver = Subserver.getSubserver(p.getServer().getInfo());
|
Subserver subserver = Subserver.getSubserver(p.getServer().getInfo());
|
||||||
if (subserver != null && subserver.getType() == Servertype.ARENA) return item;
|
if (subserver != null && subserver.getType() == Servertype.ARENA) return false;
|
||||||
if (SteamwarUser.get(p.getUniqueId()).getTeam() != team) return item;
|
return SteamwarUser.get(p.getUniqueId()).getTeam() == viewer.getTeam();
|
||||||
return new Item(p, true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren