3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Ensure Forward doesn't broadcast to the current server

Fixes #641
Dieser Commit ist enthalten in:
Andrew Steinborn 2022-02-07 23:43:40 -05:00
Ursprung 596d4758ba
Commit b2800087d8

Datei anzeigen

@ -19,9 +19,11 @@ package com.velocitypowered.proxy.connection.backend;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import com.velocitypowered.api.util.UuidUtils; import com.velocitypowered.api.util.UuidUtils;
import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnection;
@ -30,6 +32,7 @@ import com.velocitypowered.proxy.protocol.packet.PluginMessage;
import com.velocitypowered.proxy.protocol.util.ByteBufDataInput; import com.velocitypowered.proxy.protocol.util.ByteBufDataInput;
import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput; import com.velocitypowered.proxy.protocol.util.ByteBufDataOutput;
import com.velocitypowered.proxy.server.VelocityRegisteredServer; import com.velocitypowered.proxy.server.VelocityRegisteredServer;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@ -264,12 +267,16 @@ public class BungeeCordMessageResponder {
private void processForwardToServer(ByteBufDataInput in) { private void processForwardToServer(ByteBufDataInput in) {
String target = in.readUTF(); String target = in.readUTF();
ByteBuf toForward = in.unwrap().copy(); ByteBuf toForward = in.unwrap().copy();
final ServerInfo currentUserServer = player.getCurrentServer()
.map(ServerConnection::getServerInfo).orElse(null);
if (target.equals("ALL")) { if (target.equals("ALL")) {
try { try {
for (RegisteredServer rs : proxy.getAllServers()) { for (RegisteredServer rs : proxy.getAllServers()) {
if (!rs.getServerInfo().equals(currentUserServer)) {
((VelocityRegisteredServer) rs).sendPluginMessage(LEGACY_CHANNEL, ((VelocityRegisteredServer) rs).sendPluginMessage(LEGACY_CHANNEL,
toForward.retainedSlice()); toForward.retainedSlice());
} }
}
} finally { } finally {
toForward.release(); toForward.release();
} }