13
0
geforkt von Mirrors/Velocity

Merge pull request #83 from dualspiral/fix/fml-plugin-messages

Only send FML/FML|MP plugin messages if the player has joined the server
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-13 16:10:03 -04:00 committet von GitHub
Commit 656987db03
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
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;
@ -285,8 +286,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);
}
}
}