Skip to content

Commit

Permalink
Update direct connection/compression disabler for newest BungeeCord
Browse files Browse the repository at this point in the history
Fixes #5348
  • Loading branch information
Camotoy committed Feb 16, 2025
1 parent 3e61726 commit ecc10d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import net.md_5.bungee.netty.LengthPrependerAndCompressor;
import net.md_5.bungee.protocol.packet.LoginSuccess;
import net.md_5.bungee.protocol.packet.SetCompression;

Expand All @@ -40,8 +41,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
// Fixes https://github.com/GeyserMC/Geyser/issues/4281
// The server may send a LoginDisconnect packet after compression is set.
if (!compressionDisabled) {
if (ctx.pipeline().get("compress") != null) {
ctx.pipeline().remove("compress");
LengthPrependerAndCompressor compressor = ctx.pipeline().get(LengthPrependerAndCompressor.class);
if (compressor.isCompress()) {
compressor.setCompress(false);
compressionDisabled = true;
}
if (ctx.pipeline().get("decompress") != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Excepti
throw new UnsupportedOperationException("Geyser does not currently support multiple listeners with injection! " +
"Please reach out to us on our Discord at https://discord.gg/GeyserMC so we can hear feedback on your setup.");
}

// TODO remove
try {
ProxyServer.class.getMethod("unsafe");
} catch (NoSuchMethodException e) {
throw new UnsupportedOperationException("You're using an outdated version of BungeeCord - please update. Thank you!");
}

ListenerInfo listenerInfo = proxy.getConfig().getListeners().stream().findFirst().orElseThrow(IllegalStateException::new);

Class<? extends ProxyServer> proxyClass = proxy.getClass();
Expand Down Expand Up @@ -138,7 +146,7 @@ protected void initChannel(@NonNull Channel ch) throws Exception {
if (channelInitializer == null) {
// Proxy has finished initializing; we can safely grab this variable without fear of plugins modifying it
// (Older versions of ViaVersion replace this to inject)
channelInitializer = PipelineUtils.SERVER_CHILD;
channelInitializer = proxy.unsafe().getFrontendChannelInitializer().getChannelInitializer();
}
initChannel.invoke(channelInitializer, ch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ public boolean isConnected() {
return false;
}

@Override
public boolean isTransferred() {
return false;
}

@Override
public CompletableFuture<byte[]> retrieveCookie(String s) {
throw new UnsupportedOperationException();
}

@Override
public CompletableFuture<byte[]> sendData(String s, byte[] bytes) {
throw new UnsupportedOperationException();
}

@Override
public Unsafe unsafe() {
throw new UnsupportedOperationException();
Expand Down

0 comments on commit ecc10d6

Please sign in to comment.