3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-23 23:00:35 +01:00

Only send FML/FML|MP plugin messages if the player has joined the server.

See #78
Dieser Commit ist enthalten in:
Daniel Naylor 2018-09-13 10:33:27 +01:00
Ursprung b24418bfee
Commit bcbf4cfd5f
3 geänderte Dateien mit 20 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -8,6 +8,8 @@ public class VelocityConstants {
public static final String VELOCITY_IP_FORWARDING_CHANNEL = "velocity:player_info";
public static final String FORGE_LEGACY_HANDSHAKE_CHANNEL = "FML|HS";
public static final String FORGE_LEGACY_CHANNEL = "FML";
public static final String FORGE_MULTIPART_LEGACY_CHANNEL = "FML|MP";
public static final byte[] FORGE_LEGACY_HANDSHAKE_RESET_DATA = new byte[] { -2, 0 };
}

Datei anzeigen

@ -127,6 +127,12 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
minecraftConnection.write(login);
}
public void writeIfJoined(PluginMessage message) {
if (hasCompletedJoin) {
minecraftConnection.write(message);
}
}
public MinecraftConnection getMinecraftConnection() {
return minecraftConnection;
}

Datei anzeigen

@ -4,6 +4,7 @@ import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.proxy.messages.ChannelSide;
import com.velocitypowered.api.proxy.messages.MessageHandler;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.VelocityConstants;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolConstants;
@ -275,8 +276,18 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
MessageHandler.ForwardStatus status = server.getChannelRegistrar().handlePluginMessage(player,
ChannelSide.FROM_CLIENT, packet);
if (status == MessageHandler.ForwardStatus.FORWARD) {
String channel = packet.getChannel();
// We're going to forward on the original packet.
player.getConnectedServer().getMinecraftConnection().write(packet);
//
// If we have Forge messages, we may need to drop them if the server switch has
// not completed yet.
if (channel.equals(VelocityConstants.FORGE_LEGACY_CHANNEL)
|| channel.equals(VelocityConstants.FORGE_MULTIPART_LEGACY_CHANNEL)) {
player.getConnectedServer().writeIfJoined(packet);
} else {
player.getConnectedServer().getMinecraftConnection().write(packet);
}
}
}