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

Confusion between registerEvent() and registerEvents()

Open Ifera opened this issue 5 years ago • 8 comments

Description

It has long been a problem especially to the people who are new in PocketMine field between registerEvent() and registerEvents().

That one addition of s makes it a completely different function from the other. The reason for that is the confusing/conflicting names given to both these methods.

Alternative methods:

Following changes could be made to solve this confusion.

  • registerEvents() should be changed to registerListener().
  • registerEvent() should be changed to registerHandler().

Ifera avatar Mar 03 '19 11:03 Ifera

I know that I struggled with this when I first started updating and writing plugins. I agree that this change would read better and make each function more transparent about what it does.

95CivicSi avatar Mar 04 '19 08:03 95CivicSi

Personally I was far more confused by onCommand() but that's a topic for a separate issue.

dktapps avatar Mar 04 '19 08:03 dktapps

Now, this is gonna break plugins :D

InspectorGadget avatar Mar 04 '19 10:03 InspectorGadget

It's only one change lol. Wait till 4.0 hit the bell lol

dries-c avatar Mar 04 '19 16:03 dries-c

I knew it. https://twitter.com/SOFe1970/status/1001841400416108544

SOF3 avatar Mar 04 '19 17:03 SOF3

bUkKiT hAs aN OuTstAnDinG aPi deSiGn

dktapps avatar Mar 08 '19 23:03 dktapps

better then rename it to registerEvent => registerEventHandler registerEvents => registerEventsListener

i think, it becomes more understandable than just "registerHandler" and "registerListener", idk. if we think about fact, that these functions are in «PluginManager»

Gewinum avatar Jul 07 '22 14:07 Gewinum

if we think about fact, that these functions are in «PluginManager»

yes, indeed

dktapps avatar Jul 07 '22 16:07 dktapps