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

feat: packetlistener for handling Client/Server- bound packets #74

Merged
merged 3 commits into from
Jun 8, 2024

Conversation

Boy0000
Copy link
Contributor

@Boy0000 Boy0000 commented Jun 8, 2024

Registers a packet listener with for a given plugin with a given optional key
If no key is specified, use default with an index
might not need to track listener keys but

General idea is something like this

private fun registerPluginListeners() {
    interceptClientbound { packet ->
        when (packet) {
            is ClientboundAddEntityPacket -> {
                blocky.logger.e(packet.id.toString())
                packet
            }
            else -> packet
        }
    }
}

override fun onEnable() {
    
    
    commands {
        "plugin" {
            "reload" {
                executes {
                    PacketListener.unregisterListener(this)
                    registerPluginListeners()
                }
            }
        }
    }
}



override fun onDisable() {
    PacketListener.unregisterListener(this)
}

@Boy0000 Boy0000 requested a review from 0ffz as a code owner June 8, 2024 11:40
@Boy0000 Boy0000 merged commit 8d9ee2d into master Jun 8, 2024
1 check passed
@Boy0000 Boy0000 deleted the packet-listener branch June 8, 2024 18:52
Boy0000 added a commit that referenced this pull request Jun 9, 2024
* feat: packetlistener for modifying / cancelling / listening to Client/Server- bound packets

* refactor: use internal listener map over own , cleanup

* feat: pass player, nullable during handshake, & improve comments

(cherry picked from commit 8d9ee2d)
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.

None yet

1 participant