Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible NoSuchElementException #3769

Closed

Conversation

Outfluencer
Copy link
Collaborator

No description provided.

@md-5
Copy link
Member

md-5 commented Jan 6, 2025

Why is setCompressionThreshold being called at an inappropriate time?

@Outfluencer
Copy link
Collaborator Author

Outfluencer commented Jan 6, 2025

I did a anti bot plugin thats changes the compression during login because vanilla clients can handle it, i just saw that i get an error if i join with bungee.

I know the check would'nt work on bungee, because it handles the packet itself anyways. i just found it random because i joined through the proxy

@md-5
Copy link
Member

md-5 commented Jan 7, 2025

I see. Suggest we simplify like follows:

    public void setCompressionThreshold(int compressionThreshold)
    {
        PacketCompressor compressor = ch.pipeline().get( PacketCompressor.class );
        PacketDecompressor decompressor = ch.pipeline().get( PacketDecompressor.class );
        if ( compressionThreshold >= 0 )
        {
            if ( compressor == null )
            {
                addBefore( PipelineUtils.PACKET_ENCODER, "compress", compressor = new PacketCompressor() );
            }
            compressor.setThreshold( compressionThreshold );

            if ( decompressor == null )
            {
                addBefore( PipelineUtils.PACKET_DECODER, "decompress", decompressor = new PacketDecompressor() );
            }
        } else
        {
            if ( compressor != null )
            {
                ch.pipeline().remove( "compress" );
            }
            if ( decompressor != null )
            {
                ch.pipeline().remove( "decompress" );
            }
        }

        // disable use of composite buffers if we use natives
        updateComposite();
    }

@Outfluencer
Copy link
Collaborator Author

Yes that looks good

@md-5 md-5 closed this Jan 7, 2025
JonnygamingTv added a commit to JonnygamingTv/BungeeCord that referenced this pull request Jan 12, 2025
SpigotMC#3769: Fix possible NoSuchElementException changing compression
LucazPlays pushed a commit to teamholy-network/HolyBungee that referenced this pull request Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants