geforkt von Mirrors/Velocity
Revert "Clean up ClientPlaySessionHandler#handle(PluginMessage)"
This reverts commit ac4359ad21
.
Suspected to be causing problems with Fabric and Forge
Dieser Commit ist enthalten in:
Ursprung
df82c0b566
Commit
e9cc390abd
@ -170,32 +170,41 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
public boolean handle(PluginMessage packet) {
|
public boolean handle(PluginMessage packet) {
|
||||||
VelocityServerConnection serverConn = player.getConnectedServer();
|
VelocityServerConnection serverConn = player.getConnectedServer();
|
||||||
MinecraftConnection backendConn = serverConn != null ? serverConn.getConnection() : null;
|
MinecraftConnection backendConn = serverConn != null ? serverConn.getConnection() : null;
|
||||||
if (serverConn == null || backendConn == null) {
|
if (serverConn != null && backendConn != null) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backendConn.getState() != StateRegistry.PLAY) {
|
if (backendConn.getState() != StateRegistry.PLAY) {
|
||||||
logger.warn("A plugin message was received while the backend server was not "
|
logger.warn("A plugin message was received while the backend server was not "
|
||||||
+ "ready. Channel: {}. Packet discarded.", packet.getChannel());
|
+ "ready. Channel: {}. Packet discarded.", packet.getChannel());
|
||||||
return true;
|
} else if (PluginMessageUtil.isRegister(packet)) {
|
||||||
}
|
player.getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
|
||||||
|
backendConn.write(packet.retain());
|
||||||
if (this.tryHandleVanillaPluginMessageChannel(packet, backendConn)) {
|
} else if (PluginMessageUtil.isUnregister(packet)) {
|
||||||
return true;
|
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
|
||||||
}
|
backendConn.write(packet.retain());
|
||||||
|
} else if (PluginMessageUtil.isMcBrand(packet)) {
|
||||||
|
backendConn.write(PluginMessageUtil
|
||||||
|
.rewriteMinecraftBrand(packet, server.getVersion(), player.getProtocolVersion()));
|
||||||
|
} else {
|
||||||
if (serverConn.getPhase() == BackendConnectionPhases.IN_TRANSITION) {
|
if (serverConn.getPhase() == BackendConnectionPhases.IN_TRANSITION) {
|
||||||
// We must bypass the currently-connected server when forwarding Forge packets.
|
// We must bypass the currently-connected server when forwarding Forge packets.
|
||||||
VelocityServerConnection inFlight = player.getConnectionInFlight();
|
VelocityServerConnection inFlight = player.getConnectionInFlight();
|
||||||
if (inFlight != null) {
|
if (inFlight != null) {
|
||||||
if (player.getPhase().handle(player, packet, inFlight)) {
|
player.getPhase().handle(player, packet, inFlight);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (!this.tryHandleForgeMessage(packet, serverConn)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!player.getPhase().handle(player, packet, serverConn)) {
|
||||||
|
if (!player.getPhase().consideredComplete() || !serverConn.getPhase()
|
||||||
|
.consideredComplete()) {
|
||||||
|
// The client is trying to send messages too early. This is primarily caused by mods,
|
||||||
|
// but further aggravated by Velocity. To work around these issues, we will queue any
|
||||||
|
// non-FML handshake messages to be sent once the FML handshake has completed or the
|
||||||
|
// JoinGame packet has been received by the proxy, whichever comes first.
|
||||||
|
//
|
||||||
|
// We also need to make sure to retain these packets so they can be flushed
|
||||||
|
// appropriately.
|
||||||
|
loginPluginMessages.add(packet.retain());
|
||||||
|
} else {
|
||||||
ChannelIdentifier id = server.getChannelRegistrar().getFromId(packet.getChannel());
|
ChannelIdentifier id = server.getChannelRegistrar().getFromId(packet.getChannel());
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
backendConn.write(packet.retain());
|
backendConn.write(packet.retain());
|
||||||
@ -209,6 +218,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
backendConn.write(message);
|
backendConn.write(message);
|
||||||
}, backendConn.eventLoop());
|
}, backendConn.eventLoop());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,44 +293,6 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean tryHandleVanillaPluginMessageChannel(PluginMessage packet,
|
|
||||||
MinecraftConnection backendConn) {
|
|
||||||
if (PluginMessageUtil.isRegister(packet)) {
|
|
||||||
player.getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
|
|
||||||
backendConn.write(packet.retain());
|
|
||||||
return true;
|
|
||||||
} else if (PluginMessageUtil.isUnregister(packet)) {
|
|
||||||
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
|
|
||||||
backendConn.write(packet.retain());
|
|
||||||
return true;
|
|
||||||
} else if (PluginMessageUtil.isMcBrand(packet)) {
|
|
||||||
backendConn.write(PluginMessageUtil.rewriteMinecraftBrand(packet, server.getVersion(),
|
|
||||||
player.getProtocolVersion()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean tryHandleForgeMessage(PluginMessage packet, VelocityServerConnection serverConn) {
|
|
||||||
if (player.getPhase().handle(player, packet, serverConn)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.getPhase().consideredComplete() || !serverConn.getPhase().consideredComplete()) {
|
|
||||||
// The client is trying to send messages too early. This is primarily caused by mods,
|
|
||||||
// but further aggravated by Velocity. To work around these issues, we will queue any
|
|
||||||
// non-FML handshake messages to be sent once the FML handshake has completed or the
|
|
||||||
// JoinGame packet has been received by the proxy, whichever comes first.
|
|
||||||
//
|
|
||||||
// We also need to make sure to retain these packets so they can be flushed
|
|
||||||
// appropriately.
|
|
||||||
loginPluginMessages.add(packet.retain());
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the {@code JoinGame} packet. This function is responsible for handling the client-side
|
* Handles the {@code JoinGame} packet. This function is responsible for handling the client-side
|
||||||
* switching servers in Velocity.
|
* switching servers in Velocity.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren