SteamWar/BungeeCore
Archiviert
13
2

Fix 1.20.2+ Tablist order after server switch, Test fix commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Lixfel 2024-07-05 10:32:16 +02:00
Ursprung 7224428345
Commit e2024a481b
3 geänderte Dateien mit 16 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -74,7 +74,7 @@ public class ChatListener extends BasicListener {
public void logCommands(CommandExecuteEvent e) { public void logCommands(CommandExecuteEvent e) {
String command = e.getCommand(); String command = e.getCommand();
int space = command.indexOf(' '); int space = command.indexOf(' ');
if(e.getResult().isAllowed() && VelocityCore.getProxy().getCommandManager().hasCommand(space != -1 ? command.substring(0, space) : command)) { if(VelocityCore.getProxy().getCommandManager().hasCommand(space != -1 ? command.substring(0, space) : command)) {
CommandSource source = e.getCommandSource(); CommandSource source = e.getCommandSource();
String name; String name;
if(source instanceof Player player) if(source instanceof Player player)
@ -85,6 +85,9 @@ public class ChatListener extends BasicListener {
name = source.toString(); name = source.toString();
cmdLogger.log(Level.INFO, "%s -> executed command /%s".formatted(name, command)); cmdLogger.log(Level.INFO, "%s -> executed command /%s".formatted(name, command));
} else if (e.getCommandSource() instanceof Player player) {
player.spoofChatInput("/" + command);
e.setResult(CommandExecuteEvent.CommandResult.denied());
} }
} }

Datei anzeigen

@ -28,6 +28,7 @@ import com.velocitypowered.proxy.network.Connections;
import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket; import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket;
import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket; import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.UpdateTeamsPacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket; import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder; import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import de.steamwar.messages.Chatter; import de.steamwar.messages.Chatter;
@ -48,8 +49,8 @@ import java.util.stream.IntStream;
public class Tablist extends ChannelInboundHandlerAdapter { public class Tablist extends ChannelInboundHandlerAdapter {
private static final UUID[] swUuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new); private static final UUID[] swUuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new);
public static final String[] swNames = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new); private static final String[] swNames = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new);
public static final String TAB_TEAM = "zzzzzsw-tab"; public static final UpdateTeamsPacket createTeamPacket = new UpdateTeamsPacket("zzzzzsw-tab", UpdateTeamsPacket.Mode.CREATE, Component.empty(), Component.empty(), Component.empty(), UpdateTeamsPacket.NameTagVisibility.NEVER, UpdateTeamsPacket.CollisionRule.ALWAYS, 21, (byte)0x00, Arrays.stream(Tablist.swNames).toList());
private final Map<UUID, UpsertPlayerInfoPacket.Entry> directTabItems; private final Map<UUID, UpsertPlayerInfoPacket.Entry> directTabItems;
private final List<UpsertPlayerInfoPacket.Entry> current = new ArrayList<>(); private final List<UpsertPlayerInfoPacket.Entry> current = new ArrayList<>();
@ -139,8 +140,10 @@ public class Tablist extends ChannelInboundHandlerAdapter {
directTabItems.clear(); directTabItems.clear();
} }
if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) {
current.clear(); current.clear();
sendPacket(player, createTeamPacket);
}
} }
private void injection() { private void injection() {

Datei anzeigen

@ -25,16 +25,17 @@ import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.proxy.protocol.packet.UpdateTeamsPacket; import de.steamwar.network.packets.common.FightInfoPacket;
import de.steamwar.persistent.Servertype; import de.steamwar.persistent.Servertype;
import de.steamwar.persistent.Storage; import de.steamwar.persistent.Storage;
import de.steamwar.persistent.Subserver; import de.steamwar.persistent.Subserver;
import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.listeners.BasicListener; import de.steamwar.velocitycore.listeners.BasicListener;
import de.steamwar.network.packets.common.FightInfoPacket;
import net.kyori.adventure.text.Component;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class TablistManager extends BasicListener { public class TablistManager extends BasicListener {
@ -46,8 +47,6 @@ public class TablistManager extends BasicListener {
fightInfos.keySet().removeIf(serverInfo -> serverInfo.getPlayersConnected().isEmpty()); fightInfos.keySet().removeIf(serverInfo -> serverInfo.getPlayersConnected().isEmpty());
} }
private static final UpdateTeamsPacket createTeamPacket = new UpdateTeamsPacket(Tablist.TAB_TEAM, UpdateTeamsPacket.Mode.CREATE, Component.empty(), Component.empty(), Component.empty(), UpdateTeamsPacket.NameTagVisibility.NEVER, UpdateTeamsPacket.CollisionRule.ALWAYS, 21, (byte)0x00, Arrays.stream(Tablist.swNames).toList());
private final Map<Player, Tablist> tablists = new HashMap<>(); private final Map<Player, Tablist> tablists = new HashMap<>();
private int seconds = 0; private int seconds = 0;
@ -64,7 +63,7 @@ public class TablistManager extends BasicListener {
synchronized (tablists) { synchronized (tablists) {
tablists.put(event.getPlayer(), new Tablist(event.getPlayer())); tablists.put(event.getPlayer(), new Tablist(event.getPlayer()));
} }
Tablist.sendPacket(event.getPlayer(), createTeamPacket); Tablist.sendPacket(event.getPlayer(), Tablist.createTeamPacket);
} }
@Subscribe @Subscribe