Commit Graph

18 Commits

Author SHA1 Message Date
032b20f659 Server: remove premature optimization of findEntity() 2018-08-25 18:37:18 +01:00
eb0276d459 Apply nullable and void typehints to events namespace 2018-06-11 13:49:16 +01:00
faa88a55e4 EntityDamageEvent: break API
The general purpose of this is to split up base damage from modifiers.

- Added methods getBaseDamage(), setBaseDamage(), getOriginalBaseDamage(), getModifiers(), getOriginalModifiers()
- setDamage() renamed to setModifier() and type is now mandatory
- getDamage() renamed to getModifier() and type is now mandatory
- getOriginalDamage() renamed to getOriginalModifier() and type is now mandatory
- Removed MODIFIER_BASE constant
- Constructors now accept: float baseDamage, float[] modifiers instead of just float[] modifiers
2018-05-22 19:05:25 +01:00
49fbbea7bf Implemented event handler inheritance, allow registering handlers for any valid event (#1792)
* Event handlers always handle subclass events. public static $handlerList no longer required.
* Removed $handlerList declarations
* HandlerList cleanup: Removed HandlerList->handlers and related bake methods
* Removed obsolete Event->getHandlers()
* EventPriority: Added fromString()
* PluginManager: throw exceptions on registering handlers with invalid priorities

This allows specifying a handler of `EntityDamageEvent` which will handle any instanceof it (as per current behaviour), AND also now allows specifying a handler specifically for `EntityDamageByEntityEvent`, which only handles `EntityDamageEvent`.

This was not previously possible due to limitations in the way handlers were registered.

Abstract events may not be handled unless they declare the `@allowHandle` PhpDoc tag.
2018-03-20 17:05:09 +00:00
fd52022065 Refactor of health int -> float and fixed armor being useless when
computed damage reduction is less than 1
2017-08-30 11:03:07 +01:00
6b5c0af161 Separation of effect handling from Entity, fixes #886 2017-08-07 16:03:54 +01:00
846be84324 Fixed all file headers 2017-06-16 16:18:16 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
8a7259aa73 Merge #826: use getEffectLevel() instead of getAmplifier() + 1
Closes #412
2017-05-05 19:01:04 +08:00
92193fd27b Use entity IDs in EntityDamageBy*EntityEvents, fixed memory leaks related to PvP/PvE/PvM (#418) 2017-03-13 10:30:31 +00:00
58ff381557 PhpStorm automated formatting (#11)
* PhpStorm reformatting

* Tuned PhpStorm reformatting

* Improved ItemIds and BlockIds formatting

* Tuned more PhpStorm reformatting

* Improved string concatenation
2016-10-03 19:05:48 +08:00
d5ba2a72a5 Added strength, weakness, resistance effects, fixed entity area 2015-03-29 14:49:47 +02:00
7d406066a7 Added outdated event static properties 2015-01-11 19:37:21 +01:00
96122d3be7 Allow $base in knockback() to be dynamic and getters/setters in EntityDamageByEntityEvent
This change is backwards-compatible.
2014-12-12 23:01:31 +08:00
350cee3d41 Added Event allocation pool, updated SPL with Class::onClassLoaded() 2014-10-28 10:47:40 +01:00
0f6dfd39b8 Made EntityDamageByEntityEvent call EntityDamageEvent handlers 2014-08-30 18:41:00 +02:00
db7222976e Code cleanup 2014-08-21 17:26:41 +02:00
65523972c2 Implemented health, events, damage, motion push 2014-07-06 23:10:11 +02:00