13
0
geforkt von Mirrors/Velocity

Forward other client-known plugin messages during the transition as well

Fixes #197
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-04-29 00:52:06 -04:00
Ursprung 8517d58673
Commit de51ea18cc
2 geänderte Dateien mit 19 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package com.velocitypowered.proxy.connection.backend;
import static com.velocitypowered.proxy.connection.backend.BackendConnectionPhases.IN_TRANSITION; import static com.velocitypowered.proxy.connection.backend.BackendConnectionPhases.IN_TRANSITION;
import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase.HELLO; import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeHandshakeBackendPhase.HELLO;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.event.player.ServerConnectedEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.VelocityServer;
@ -10,6 +11,7 @@ import com.velocitypowered.proxy.connection.ConnectionTypes;
import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
import com.velocitypowered.proxy.connection.client.InitialConnectSessionHandler;
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants; import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults; import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl; import com.velocitypowered.proxy.connection.util.ConnectionRequestResults.Impl;
@ -18,6 +20,7 @@ import com.velocitypowered.proxy.protocol.packet.JoinGame;
import com.velocitypowered.proxy.protocol.packet.KeepAlive; import com.velocitypowered.proxy.protocol.packet.KeepAlive;
import com.velocitypowered.proxy.protocol.packet.PluginMessage; import com.velocitypowered.proxy.protocol.packet.PluginMessage;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
@ -158,6 +161,19 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
.completeExceptionally(new IOException("Unexpectedly disconnected from remote server")); .completeExceptionally(new IOException("Unexpectedly disconnected from remote server"));
} }
private Collection<String> getClientKnownPluginChannels() {
MinecraftSessionHandler handler = serverConn.getPlayer().getMinecraftConnection()
.getSessionHandler();
if (handler instanceof InitialConnectSessionHandler) {
return ((InitialConnectSessionHandler) handler).getKnownChannels();
} else if (handler instanceof ClientPlaySessionHandler) {
return ((ClientPlaySessionHandler) handler).getKnownChannels();
} else {
return ImmutableList.of();
}
}
private boolean canForwardPluginMessage(PluginMessage message) { private boolean canForwardPluginMessage(PluginMessage message) {
MinecraftConnection mc = serverConn.getConnection(); MinecraftConnection mc = serverConn.getConnection();
if (mc == null) { if (mc == null) {
@ -172,6 +188,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
minecraftOrFmlMessage = message.getChannel().startsWith("minecraft:"); minecraftOrFmlMessage = message.getChannel().startsWith("minecraft:");
} }
return minecraftOrFmlMessage return minecraftOrFmlMessage
|| server.getChannelRegistrar().registered(message.getChannel()); || server.getChannelRegistrar().registered(message.getChannel())
|| getClientKnownPluginChannels().contains(message.getChannel());
} }
} }

Datei anzeigen

@ -63,7 +63,7 @@ public class InitialConnectSessionHandler implements MinecraftSessionHandler {
player.teardown(); player.teardown();
} }
Set<String> getKnownChannels() { public Set<String> getKnownChannels() {
return knownChannels; return knownChannels;
} }
} }