geforkt von SteamWar/BungeeCore
Fixes, working
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
f2ed575f8c
Commit
616062354f
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.tablist;
|
package de.steamwar.bungeecore.tablist;
|
||||||
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import net.md_5.bungee.ServerConnection;
|
import net.md_5.bungee.ServerConnection;
|
||||||
@ -39,6 +40,7 @@ import java.util.*;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
@ChannelHandler.Sharable
|
||||||
public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
||||||
|
|
||||||
private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new);
|
private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new);
|
||||||
@ -76,12 +78,18 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
|||||||
// NPC handling
|
// NPC handling
|
||||||
List<String> addNpc = new ArrayList<>();
|
List<String> addNpc = new ArrayList<>();
|
||||||
List<String> removeNpc = new ArrayList<>();
|
List<String> removeNpc = new ArrayList<>();
|
||||||
|
List<PlayerListItem.Item> update = new ArrayList<>();
|
||||||
for (TablistPart.Item item : direct) {
|
for (TablistPart.Item item : direct) {
|
||||||
if(npcs.remove(item.getUuid()))
|
if(npcs.remove(item.getUuid()))
|
||||||
removeNpc.add(directlySent.get(item.getUuid()).getUsername());
|
removeNpc.add(directlySent.get(item.getUuid()).getUsername());
|
||||||
|
|
||||||
if(!directlySent.containsKey(item.getUuid()))
|
PlayerListItem.Item tabItem = directlySent.get(item.getUuid());
|
||||||
|
if(tabItem == null) {
|
||||||
tablist.add(0, item);
|
tablist.add(0, item);
|
||||||
|
} else if(!tabItem.getDisplayName().equals(item.getDisplayName())) {
|
||||||
|
tabItem.setDisplayName(item.getDisplayName());
|
||||||
|
update.add(tabItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Set<UUID> nonNPCs = direct.stream().map(TablistPart.Item::getUuid).collect(Collectors.toSet());
|
Set<UUID> nonNPCs = direct.stream().map(TablistPart.Item::getUuid).collect(Collectors.toSet());
|
||||||
for(PlayerListItem.Item item : directlySent.values()) {
|
for(PlayerListItem.Item item : directlySent.values()) {
|
||||||
@ -94,7 +102,6 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
|
|||||||
// Main list handling
|
// Main list handling
|
||||||
int i = 0;
|
int i = 0;
|
||||||
List<PlayerListItem.Item> add = new ArrayList<>();
|
List<PlayerListItem.Item> add = new ArrayList<>();
|
||||||
List<PlayerListItem.Item> update = new ArrayList<>();
|
|
||||||
for (; i < tablist.size() && i < 80; i++) {
|
for (; i < tablist.size() && i < 80; i++) {
|
||||||
PlayerListItem.Item tabItem;
|
PlayerListItem.Item tabItem;
|
||||||
if(current.size() > i) {
|
if(current.size() > i) {
|
||||||
|
69
src/de/steamwar/bungeecore/tablist/TablistBuild.java
Normale Datei
69
src/de/steamwar/bungeecore/tablist/TablistBuild.java
Normale Datei
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.tablist;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Servertype;
|
||||||
|
import de.steamwar.bungeecore.Subserver;
|
||||||
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class TablistBuild implements TablistPart {
|
||||||
|
|
||||||
|
private final List<ServerInfo> servers = new ArrayList<>();
|
||||||
|
private final Map<ServerInfo, List<Item>> players = new HashMap<>();
|
||||||
|
|
||||||
|
public TablistBuild() {
|
||||||
|
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
|
||||||
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
|
if(server.getPlayers().isEmpty() || subserver == null || subserver.getType() != Servertype.BAUSERVER)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
servers.add(server);
|
||||||
|
players.put(server, server.getPlayers().stream().sorted(((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()))).map(Item::new).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
servers.sort((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String sortKey() {
|
||||||
|
return "Build";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
|
||||||
|
ServerInfo server = player.getServer().getInfo();
|
||||||
|
if(players.keySet().stream().anyMatch(info -> server != info)) {
|
||||||
|
tablist.add(new Item(null, "", TablistServer.GRAY));
|
||||||
|
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ServerInfo info : servers) {
|
||||||
|
(server == info ? direct : tablist).addAll(players.get(info));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -82,25 +82,19 @@ public class TablistManager extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTablist() {
|
private void updateTablist() {
|
||||||
List<TablistPart.Item> buildPlayers = new ArrayList<>();
|
|
||||||
List<TablistPart> subservers = new ArrayList<>();
|
List<TablistPart> subservers = new ArrayList<>();
|
||||||
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
|
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
|
||||||
if(server.getPlayers().isEmpty())
|
if(server.getPlayers().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(server);
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
if(subserver != null && subserver.getType() == Servertype.BAUSERVER)
|
if(fightInfos.containsKey(server))
|
||||||
server.getPlayers().forEach(player -> buildPlayers.add(new TablistPart.Item(player)));
|
|
||||||
else if(fightInfos.containsKey(server))
|
|
||||||
subservers.add(new TablistServer(server, fightInfos.get(server)));
|
subservers.add(new TablistServer(server, fightInfos.get(server)));
|
||||||
else
|
else if(subserver == null || subserver.getType() != Servertype.BAUSERVER)
|
||||||
subservers.add(new TablistServer(server));
|
subservers.add(new TablistServer(server));
|
||||||
}
|
}
|
||||||
|
subservers.add(new TablistBuild());
|
||||||
subservers.sort((s1, s2) -> s1.sortKey().compareToIgnoreCase(s2.sortKey()));
|
subservers.sort((s1, s2) -> s1.sortKey().compareToIgnoreCase(s2.sortKey()));
|
||||||
if(!buildPlayers.isEmpty()) {
|
|
||||||
buildPlayers.sort((p1, p2) -> p1.getDisplayName().compareToIgnoreCase(p2.getDisplayName()));
|
|
||||||
subservers.add(new TablistServer(null, "Build", viewer -> viewer.parseToLegacy("TABLIST_BAU"), buildPlayers));
|
|
||||||
}
|
|
||||||
TablistPart global = new TablistGroup(subservers);
|
TablistPart global = new TablistGroup(subservers);
|
||||||
|
|
||||||
synchronized (tablists) {
|
synchronized (tablists) {
|
||||||
|
@ -30,7 +30,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TablistServer implements TablistPart {
|
public class TablistServer implements TablistPart {
|
||||||
@ -39,16 +38,14 @@ public class TablistServer implements TablistPart {
|
|||||||
public static final Property[] LIGHT_GRAY = new Property[]{new Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU2MjU1OTM5NjIsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzc4Y2I3ZmMyMDhiMzM4NTUwNGE4MTQ0MjA0NDI4ZmRjZDYzMjRiZWIzMWNhMmNlODZjYzQyNGI5NjNkODVjIn19fQ==", "R/wZUZRC1dishRdM9a2SSxxW3oYa0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Ya0XSb/MxHbQpEUA791HxyqjaKLDu0wFX2r2a8ZTeVjzXpNzkg3+PkrA11o8h7lt86MTD1pi/rQqj/WRuoqf2LP+ypbssKV+LU15cYez2cj3QQVcJDXgWEnfSLNuBv6NG8BDUpUAjTWldvu99NCJHUoD0jNMHxY/fu4k5vCgOjaBaKgkjVk2bmUhegusmtMwco+3pYx+y8+gUW8ptx5SnePG+dOwTqLyBFiOt2AQ+gSvbU/jP9aAXgxOwz/b1pMaBWtzVhFU865NHlIdSpIHg/sh3uNah3a7gTgtTvxPQv1OzM/KtqYKiamsrRzAQMzRcs4A7Tp0GakLuxEaz401IwvQ7UGVYLFzGUVLB2MyqtPgifiqQSQxZpiqj9sM5QadhsUw00nfX7mTdW46U0MtNIbby1rLrvgQKoj08zt6LJlhI3yjyawy4iZkgF4oc+PCNwZc93GIbVL9LJaGkXk3RVA+JpGwfMJrGVbL7hl8ibbAcUv7uCEWdkAgZCd6w75jEE4tlhDSPDD4rXbn+FeTZRg2n/PGKtnoTZRzbniiFaNoSAHDZSVRG39xvBDFvtmL3SPaKhzKaifiYrgNn453WtR3kymqdAtPf1GN9d1VltGZ/+vMPwqPJb6thcrlcU64UGHbg1olRkiyZHvY8=")};
|
||||||
|
|
||||||
private final ServerInfo server;
|
private final ServerInfo server;
|
||||||
private final String sortKey;
|
|
||||||
private final Function<ChatSender, String> title;
|
|
||||||
private final List<Item> players;
|
private final List<Item> players;
|
||||||
|
|
||||||
public TablistServer(ServerInfo server) {
|
public TablistServer(ServerInfo server) {
|
||||||
this(server, server.getName(), viewer -> server.getName(), server.getPlayers().stream().sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())).map(TablistPart.Item::new).collect(Collectors.toList()));
|
this(server, server.getPlayers().stream().sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())).map(TablistPart.Item::new).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TablistServer(ServerInfo server, FightInfoPacket info) {
|
public TablistServer(ServerInfo server, FightInfoPacket info) {
|
||||||
this(server, server.getName(), viewer -> server.getName(), new ArrayList<>());
|
this(server, new ArrayList<>());
|
||||||
|
|
||||||
Collection<ProxiedPlayer> onlinePlayers = server.getPlayers();
|
Collection<ProxiedPlayer> onlinePlayers = server.getPlayers();
|
||||||
addPlayers(info.getBlueName().substring(0, 2), info.getBluePlayers(), onlinePlayers);
|
addPlayers(info.getBlueName().substring(0, 2), info.getBluePlayers(), onlinePlayers);
|
||||||
@ -56,16 +53,14 @@ public class TablistServer implements TablistPart {
|
|||||||
addPlayers("§7", info.getSpectators(), onlinePlayers);
|
addPlayers("§7", info.getSpectators(), onlinePlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TablistServer(ServerInfo server, String sortKey, Function<ChatSender, String> title, List<Item> players) {
|
public TablistServer(ServerInfo server, List<Item> players) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.sortKey = sortKey;
|
|
||||||
this.title = title;
|
|
||||||
this.players = players;
|
this.players = players;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String sortKey() {
|
public String sortKey() {
|
||||||
return sortKey;
|
return server.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,9 +68,9 @@ public class TablistServer implements TablistPart {
|
|||||||
boolean onServer = player.getServer().getInfo() == server;
|
boolean onServer = player.getServer().getInfo() == server;
|
||||||
List<Item> items = onServer ? direct : tablist;
|
List<Item> items = onServer ? direct : tablist;
|
||||||
|
|
||||||
if(!onServer && title != null) {
|
if(!onServer) {
|
||||||
items.add(new Item(null, "", GRAY));
|
items.add(new Item(null, "", GRAY));
|
||||||
items.add(new Item(null, "§7" + title.apply(viewer), LIGHT_GRAY));
|
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
items.addAll(players);
|
items.addAll(players);
|
||||||
|
@ -552,7 +552,7 @@ TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de
|
|||||||
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
|
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
|
||||||
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
|
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
|
||||||
TABLIST_FOOTER=§e{0} {1}§8ms §ePlayers§8: §7{2}
|
TABLIST_FOOTER=§e{0} {1}§8ms §ePlayers§8: §7{2}
|
||||||
TABLIST_BAU=Build
|
TABLIST_BAU=§7§lBuild
|
||||||
LIST_COMMAND=§e{0}§8: §7{1}
|
LIST_COMMAND=§e{0}§8: §7{1}
|
||||||
|
|
||||||
#EventStarter
|
#EventStarter
|
||||||
|
@ -531,7 +531,7 @@ TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de
|
|||||||
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
|
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
|
||||||
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
|
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
|
||||||
TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2}
|
TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2}
|
||||||
TABLIST_BAU=Bau
|
TABLIST_BAU=§7§lBau
|
||||||
LIST_COMMAND=§e{0}§8: §7{1}
|
LIST_COMMAND=§e{0}§8: §7{1}
|
||||||
|
|
||||||
#EventStarter
|
#EventStarter
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren