217 Commits

Author SHA1 Message Date
Dylan K. Taylor
ebcd6a0bb2
CraftItemEvent: fixed inputs and outputs not being cloned 2023-08-08 18:29:49 +01:00
Dylan K. Taylor
46f24b165a
Rename PlayerMissedSwingEvent -> PlayerMissSwingEvent
all the other events are present tense, so it doesn't make sense for this one to be past tense.
2023-08-01 12:21:39 +01:00
Dylan K. Taylor
5ec3f4655f
EntityDamageByEntityEvent: added APIs to get and set vertical knockback limits
this was requested and PR'd as far back as 2020 (see #3782).
Since no issue was filed about this, it became forgotten until #5946.
However, #5946 overcomplicates the solution to the problem, and breaks BC without an obvious reason.
2023-07-28 12:52:15 +01:00
Dylan K. Taylor
c972e65741
EntityDamageByEntityEvent: document methods 2023-07-28 12:41:27 +01:00
Dylan K. Taylor
a45763328b
Added constants for default knockback force and vertical limit 2023-07-28 12:36:46 +01:00
ipad54
6086ef667c
Added handling for attack-air action (#5912) 2023-07-25 14:50:28 +01:00
Dylan K. Taylor
9d0d60afd1
BlockPlaceEvent: ensure that getPosition() is always correct
since BlockTransaction was designed to be World-agnostic, it can't position() any blocks, since Position requires a World.

This workaround is the best we can do for now; however, it would probably be wise to deprecate getTransaction() in favour of a dedicated getBlocks() method which takes care of this, as BlockPlaceEvent is currently quite obnoxious to use.
2023-06-21 15:36:48 +01:00
Dylan K. Taylor
40be564689
BlockSpreadEvent: document poorly-named constructor parameters 2023-06-03 17:08:02 +01:00
Dylan K. Taylor
0ed5e94a72
Merge branch 'minor-next' into major-next 2023-05-30 16:15:56 +01:00
BrandPVP
8245cfab0e
PlayerDeathEvent: add ability to set message displayed on the death screen (#5726) 2023-05-19 16:18:18 +01:00
Hugo_
d834266635
BlockGrowEvent: add player information for bonemeal usage (#5596)
this is in line with StructureGrowEvent, which also has a similar API.
2023-05-08 17:38:07 +01:00
Dylan K. Taylor
096daef0d0
World: added setDisplayName()
this is an obvious use case, and I'm not really sure why it wasn't supported sooner.
2023-05-01 16:29:07 +01:00
Dylan K. Taylor
a0346fb6d3
Merge branch 'minor-next' into major-next 2023-04-26 14:29:32 +01:00
Dylan K. Taylor
84a16ce69a
HandlerList: fixed crash on getting unused priority
these sub-arrays are no longer allocated if no handlers are registered.

fixes #5713
2023-04-21 16:19:15 +01:00
Dylan K. Taylor
c878bd8289
Merge remote-tracking branch 'origin/minor-next' into major-next 2023-04-20 00:18:19 +01:00
Dylan K. Taylor
4ba57f2b03
RegisteredListener: use try...finally to stop timings
While event handlers should not throw exceptions, we need to make sure the timings get stopped in the correct order, because the parent Event timer will be stopped due to using a finally block.
If this happens while the handler timing is still running, a second exception will occur, obscuring the real error.
2023-04-16 00:40:43 +01:00
Dylan K. Taylor
9bddcc72f7
Merge branch 'minor-next' into major-next 2023-04-11 22:51:50 +01:00
Dylan K. Taylor
3490e2b06a
Mark RegisteredListenerCache as internal 2023-04-11 22:33:44 +01:00
Dylan K. Taylor
a0dadc6e37
Merge branch 'minor-next' into major-next 2023-04-10 14:38:23 +01:00
Dylan K. Taylor
76ebedff6a
HandlerList: remove unnecessary variable 2023-04-07 22:58:30 +01:00
Dylan K. Taylor
3ea8d27a3b
HandlerList: improve listener list development to make way for #5678 2023-04-07 22:55:27 +01:00
Dylan K. Taylor
4724195791
Improved performance of event calls
This change significantly reduces the amount of work done by event handlers. Instead of traversing all of the priorities and event parent chain multiple times, we reduce event handlers down to a simple list, which doesn't require any logic to iterate over.
Previously, calling an event with lots of parents costed more than an event which directly descended from Event.
In addition, we had to do a lot of usually useless work to check all priorities, when in practice, only NORMAL will be used in almost all cases.

This change makes it more cost effective to implement the feature suggested by #5678; however, it will still require additional changes.
2023-04-05 23:02:44 +01:00
Dylan K. Taylor
f32a853bd4
HandlerList: remove useless isset 2023-04-05 21:37:08 +01:00
Dylan K. Taylor
982d05affd
Merge branch 'major-next' of github.com:pmmp/PocketMine-MP into major-next 2023-03-29 23:22:12 +01:00
Dylan K. Taylor
10f3145af2
Merge branch 'minor-next' into major-next 2023-03-29 23:22:02 +01:00
Dylan K. Taylor
b49a9ae81d
Added timings for calling events
this gives a somewhat better overview of events, particularly if many plugins are subscribed to the same costly event (e.g. PlayerMoveEvent).

In addition, it allows us to see the frequency that events are occurring.
2023-03-28 17:26:20 +01:00
IvanCraft623
bea878e9e9
Implement anvil fall damage (#5312) 2023-03-27 20:17:08 +01:00
Dylan K. Taylor
7cdab75b05
Merge branch 'minor-next' into major-next 2023-03-20 22:12:54 +00:00
João
2751e1ec02
replacing new Vector3(0, 0, 0) with Vector3::zero() (#5640) 2023-03-20 12:54:28 +00:00
Dylan K. Taylor
cf0e7b4213
Merge branch 'minor-next' into major-next 2023-03-16 15:04:27 +00:00
Dylan K. Taylor
ef45180b80
Rename DataPacketPreReceiveEvent -> DataPacketDecodeEvent
thank you @IvanCraft623 for the suggestion
2023-03-16 13:40:37 +00:00
Dylan K. Taylor
abd4ef01eb
Merge branch 'minor-next' into major-next 2023-03-15 23:02:41 +00:00
Armen Deroian
183d1f4038
Implement DataPacketPreReceiveEvent (#5559)
closes #5554

This is called just before the packet is decoded, allowing the event to be used to drop packets from clients without wasting CPU time decoding them. This can be particularly useful for mitigating denial-of-service attacks.
2023-03-15 22:47:19 +00:00
Dylan K. Taylor
2d56aa50b9
A bunch of mostly inseparable changes to PlayerPreLoginEvent
including support for separated disconnect reasons and disconnect screen messages (closes #4512)

While the refactoring of kick reason -> kick flag wasn't exactly in my agenda, I realized that these changes would become pretty confusing and inconsistent with other events if they weren't refactored.
Hopefully I don't have to break this API again for a while...
2023-02-13 11:32:32 +00:00
Dylan K. Taylor
5d0388e747
PlayerPreLoginEvent no longer implements Cancellable
please see #5516 for motivation on this, but I don't think anyone will be complaining - this behaviour made no sense and caused a lot of confusion for people who were trying to set custom ban messages.
2023-02-13 11:10:29 +00:00
Dylan K. Taylor
cbaff1caec
BlockPlaceEvent: use BlockTransaction, closes #1760
BlockPlaceEvent no longer extends BlockEvent, since it's now a multi-block event
getBlockReplaced() is removed
getTransaction() is added

to be honest, BlockPlaceEvent should be something like PlayerBlockPlaceEvent...
2023-01-24 15:49:42 +00:00
Dylan K. Taylor
375ec8e00c
Fix CS 2023-01-23 20:36:02 +00:00
Dylan K. Taylor
002f7d6826
PlayerDuplicateLoginEvent: remove dead code 2023-01-23 20:21:06 +00:00
Dylan K. Taylor
b8f6b66e42
First look at separating disconnect reason and disconnect screen messages (#4512) 2023-01-18 20:57:17 +00:00
Dylan K. Taylor
365cce9d0c
Merge branch 'next-minor' into next-major 2023-01-18 20:46:22 +00:00
Dylan K. Taylor
78aea5c34c
Merge branch 'stable' into next-minor 2023-01-18 20:46:10 +00:00
Dylan K. Taylor
d7f40f75d2
PlayerPreLoginEvent: fixed documentation errors 2023-01-18 20:45:49 +00:00
Dylan K. Taylor
b76265cd37
PlayerChatEvent: introduce new formatting API
this API is simultaneously more powerful and cleaner than the previous system.
The previous system relied on undocumented behaviour and was limited to non-localizable strings.

This enables custom servers to implement their own chat formats (e.g. containing localizable tags) which will be displayed in each player's own language (once per-player language has been properly implemented, anyway).
2023-01-13 17:20:08 +00:00
Dylan K. Taylor
7ac6bd79a9
Localized remaining disconnection screens (except one or two that should never actually happen) 2022-12-27 20:05:59 +00:00
Dylan K. Taylor
6b8b7311f0
Support localized disconnect screen messages for PlayerLoginEvent 2022-12-27 18:57:32 +00:00
Dylan K. Taylor
f173b91ca1
Introduce support for Translatable disconnection messages
this allows localizing disconnection screens (at least, once #4512 has been addressed) and the disconnect reasons shown on the console.

We already had disconnect messages implicitly localized in a few places, so this is just formalizing it.
This does break BC with any code that previously passed translation keys as the disconnect screen message, because they'll no longer be translated (only Translatables will be translatated now).
2022-12-27 18:36:07 +00:00
Dylan K. Taylor
f8cc015c51
Merge branch 'next-minor' into next-major 2022-12-23 16:58:59 +00:00
Dylan K. Taylor
17125ce0e3
Merge branch 'stable' into next-minor 2022-12-23 16:56:54 +00:00
Dylan K. Taylor
97ef209c5f
HandlerList: added missing class-string type for constructor 2022-12-19 16:26:36 +00:00
Dylan K. Taylor
3d75094874
Standardize explosion radius terminology
closes #5061
2022-12-15 22:43:36 +00:00