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(Player): introduce PlayerPacketHandlerChangeEvent #6194

Open
wants to merge 1 commit into
base: minor-next
Choose a base branch
from

Conversation

cooldogedev
Copy link
Contributor

@cooldogedev cooldogedev commented Dec 9, 2023

Introduction

Relevant issues

Changes

API changes

Behavioural changes

NetworkSession->setHandler(PacketHandler) now fires PlayerPacketHandlerChangeEvent

Backwards compatibility

Follow-up

Tests

@dktapps
Copy link
Member

dktapps commented Dec 14, 2023

What's the use case?

return $this->handler;
}

public function setHandler(?PacketHandler $handler) : void{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this. This opens lots of options to break things.

use pocketmine\network\mcpe\handler\PacketHandler;
use pocketmine\network\mcpe\NetworkSession;

class PlayerPacketHandlerChangeEvent extends Event{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading to refer to this as "player" and to put it in this namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without creating a new namespace it has to be either event/player or event/server

@dktapps dktapps added Category: API Related to the plugin API Type: Enhancement Contributes features or other improvements to PocketMine-MP Status: Waiting on Author labels Dec 14, 2023
@cooldogedev
Copy link
Contributor Author

What's the use case?

Check out this example. This plugin overrides the default Login packet handler to support WaterdogPE's login extras. However, it currently listens for all incoming packets, making the override process less than optimal in terms of convenience.

@dktapps
Copy link
Member

dktapps commented Jan 4, 2024

WaterdogPE's design in general is less than optimal ...

@SenseiTarzan
Copy link
Contributor

WaterdogPE's design in general is less than optimal ...

I find this thing interesting because I have to do a hack to deactivate a handler because I have a synchronization system and it's me who manages the call that makes the setHandler(InGameHandler), WaterdogPE could make a new packets but they didn't and I find that a shame

@cooldogedev cooldogedev force-pushed the feat/packet-handler-change-event branch from 3b8e1f7 to bc3e9d6 Compare February 19, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Status: Waiting on Author Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants