PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

Add a comment for PlayerCreationEvent::setBaseClass

Open PJZ9n opened this issue 4 years ago • 9 comments
trafficstars

Description

PlayerCreationEvent has a method set/getBaseClass(), probably not used by PM. I think we need to explain what it does when used. Alternatively, create a DeveloperDocs document.

Justification

Add a comment or document

Alternative methods

You see the code: https://github.com/pmmp/PocketMine-MP/blob/4102205ba6b9d4172efaa92a2d0d0035b46e8b08/src/pocketmine/event/player/PlayerCreationEvent.php

PJZ9n avatar Nov 18 '21 19:11 PJZ9n

Hello, what do you think about this issue?

PJZ9n avatar Jan 20 '22 08:01 PJZ9n

If we are to keep the event, yes, this should be documented properly. To be exact, every non-intuitive function should be documented. We just don't have the time to do that. Pull requests are welcome.

SOF3 avatar Jan 20 '22 10:01 SOF3

Yes, I tried to add documentation for this function in PR, but I couldn't figure out what the function was for. I searched where the function was used, but the value didn't seem to be used at all.

PJZ9n avatar Jan 20 '22 11:01 PJZ9n

It is used to allow multiple plugins to use PlayerCreationEvent.

If plugin A has class Foo extends Player, plugin B can do class Bar extends Player, and run their PlayerCreationEvent handler after plugin A. This allows featured of plugin A to remain while plugin B can add new features.

Nevertheless, it is very stupid to keep extending classes like that. PlayerCreationEvent must not be used unless absolutely necessary, and typically only appears in private plugins, in which case there shouldn't be two plugins anyway.

SOF3 avatar Jan 20 '22 11:01 SOF3

There's an argument to be made for deprecating this function (and even the whole event) entirely ...

dktapps avatar May 21 '22 19:05 dktapps

and even the whole event

Why delete? Many people use this to change the logic of PocketMine-MP or implement their own API.

For example. It is convenient for servers with mini-games to keep information about the game in which the player is located.

Or you can store information about the player's account directly in his object.

Isn't it convenient?

ghost avatar Jun 03 '22 14:06 ghost

and even the whole event

Why delete? Many people use this to change the logic of PocketMine-MP or implement their own API.

For example. It is convenient for servers with mini-games to keep information about the game in which the player is located.

Or you can store information about the player's account directly in his object.

Isn't it convenient?

this :clap: is :clap: not :clap: what :clap: PlayerCreationEvent :clap: was :clap: made :clap: for

if you want to store objects associated with a player, maintain your own array in the plugin. Alternatively, something like #4471 might be useful.

SOF3 avatar Jun 03 '22 14:06 SOF3

Why delete? Many people use this to change the logic of PocketMine-MP or implement their own API.

For example. It is convenient for servers with mini-games to keep information about the game in which the player is located.

Or you can store information about the player's account directly in his object.

Isn't it convenient?

You just made our case for removing it - people like yourself keep abusing it for things it wasn't intended for.

See also: #3473

dktapps avatar Jun 03 '22 15:06 dktapps

@SOF3 @dktapps

thanks

ghost avatar Jun 05 '22 13:06 ghost