140 Commits

Author SHA1 Message Date
Dylan K. Taylor
a4b65d6a3f
PlayerCreationEvent: verify that the class actually exists and is instantiable
this ensures that crashdumps blame the plugin instead of the core on bad classes, such as in this case: https://crash.pmmp.io/view/5331225
2021-10-21 20:37:45 +01:00
Matt
09715906c8
StructureGrowEvent: added API to get the player who caused the growth (#4445) 2021-10-09 22:51:46 +01:00
Dylan K. Taylor
f138004913
PlayerDeathEvent: fixed property type variance issue PHPStan complains about 2021-09-26 21:20:42 +01:00
Cosmic
710345d4b0
Implemented Farmland turns to dirt when jumped on. (#4434) 2021-09-06 12:55:52 +01:00
Colin
2139171a55
added BlockItemPickupEvent class (#4402) 2021-08-29 00:40:09 +01:00
Colin
4189fbdaef
Added StructureGrowEvent (#4354)
This event is currently fired for tree and bamboo growth. Its intended use is for any plant growth that affects multiple blocks at once.

TODO: We could explore using this for cacti and sugarcane?
2021-08-25 14:05:30 +01:00
marshall
6e68e99ec0
Added PlayerEntityInteractEvent (#4374) 2021-08-24 11:56:10 +01:00
Rush2929
eb9188c309
Replace InventoryPickup*Event with EntityItemPickupEvent (#4384)
The rationale here is that inventories don't actually pick items up - their holders do.
It's especially misleading to say that an inventory is picking up an item in creative mode when the picked-up item can't actually be added to the target inventory in the first place.

This change allows a range of new functionality, such as:
- Allowing survival players to pick items up even when their inventories are full, similarly to creative players
- Changing the destination inventory of collected items (e.g. items could be redirected to the offhand or ender chest inventory, while still allowing other plugins to understand what's happening)

As an added bonus, this obsoletes one more use case for Inventory->getHolder(), bringing us one step closer to removing the cyclic reference nightmare from inventories.

The choice of naming (EntityItemPickup, instead of EntityPickupItem) is to be consistent with other events, where the word order is SubjectObjectActionEvent.
2021-08-20 22:59:35 +01:00
Dylan K. Taylor
d488c25a1a
Rename AutoUpdater -> UpdateChecker 2021-08-20 19:54:08 +01:00
Dylan K. Taylor
789a669395
Rename TranslationContainer -> Translatable 2021-08-15 16:17:46 +01:00
Dylan K. Taylor
2ad5de379f
HandlerListManager::unregisterAll() accepts RegisteredListener
since all this function is doing is passing the object on to the HandlerList, it should accept RegisteredListener, like HandlerList::unregister().
2021-08-10 15:28:11 +01:00
Dylan K. Taylor
b4c0ddd155
Use native union types for TranslationContainer|string 2021-08-10 15:17:26 +01:00
Dylan K. Taylor
2293bd948d
Added KnownTranslationFactory and use it in as many places as possible
this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
2021-08-10 14:50:40 +01:00
Dylan K. Taylor
041d314190
HandlerListManager: apply class-string type for getListFor() parameter 2021-08-05 20:11:58 +01:00
Dylan K. Taylor
f3bd48e6cb
Updated some more hardcoded translation key usages missed by 94e16f416de31b79c93bdc2c6cf84b22d25ba63f 2021-06-30 14:02:55 +01:00
Dylan K. Taylor
69fa8e8db7
Added documentation to BlockFormEvent 2021-05-19 00:17:39 +01:00
Dylan K. Taylor
f8cfa191dd
Fixed confusing hierarchy of BlockGrow/Form/SpreadEvent, closes #2792 2021-05-19 00:17:38 +01:00
Dylan K. Taylor
6cb285d4a9
Added constants for the handler tag types 2021-05-06 18:40:14 +01:00
Dylan K. Taylor
3e1ac66abf
Merge branch 'stable' 2021-02-02 13:46:29 +00:00
SalmonDE
3fb4b30742
InventoryPickupItemEvent: rename item to itemEntity (#4007) 2021-01-20 21:09:59 +00:00
Dylan K. Taylor
c808095978 Chunks no longer contain their own coordinates 2020-12-03 21:59:30 +00:00
Dylan K. Taylor
5197707d32 Separated TimingsRecord from TimingsHandler (different lifetimes)
this fixes #3906.
TimingsHandler will now be automatically destroyed when there are no TimingsRecord referencing it and its owner has no references left to it.
TimingsRecord will be automatically destroyed at the end of the timings session (if active).

This fixes records from temporary timers being lost after the timings handlers are removed, while also fixing TimingsHandlers piling up regardless of whether timings are running or not.
This opens the doors to have more volatile timers, such as per-player/per-session timers, which are destroyed on player quit, but which won't result in the timings disappearing from the final timings result.
2020-12-03 15:45:49 +00:00
Dylan K. Taylor
97a4d80854 PlayerDataSaveEvent: provide online player if possible, otherwise don't load offline data from disk for no reason (we already have it, that's the whole point of the event ...) 2020-11-28 21:43:23 +00:00
Dylan K. Taylor
dd200ca8cd Rewrite message broadcasting system to not depend on PermissionManager subscriptions
relying on permission subscriptions for this was unreliable (a permissible is not always subscribed to a permission even when it does have it), and also difficult to control (for example there have been various bugs in the past where a Player ended up subscribed to broadcast permissions when it didn't expect to be, thanks to permission recalculation happening too early).
In addition, we might in the future want to have broadcast receivers which are not permissibles (i.e. a more general interface than CommandSender (why does a broadcast receiver need to also be a command sender, anyway?)), which the permission system wouldn't be suitable for.
2020-11-28 19:28:47 +00:00
Dylan K. Taylor
4439781124 Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/event/player/PlayerCreationEvent.php
2020-11-28 16:16:15 +00:00
Dylan K. Taylor
e9038336e3 EventPriority: hardcode name -> value mapping instead of using constant()
this would have caught fire if additional non-priority constants were added, or if the constants were renamed.
2020-10-23 20:14:37 +01:00
Dylan K. Taylor
d38791e27d Listener: Drop support for @softDepend annotation
literally nobody uses this. I don't think anyone even knows it exists.
It's also an obstacle to separating event handler registration from PluginManager.
2020-10-16 21:10:57 +01:00
Dylan K. Taylor
44e446b621 Merge remote-tracking branch 'origin/stable' into master
# Conflicts:
#	build/php
#	composer.lock
#	phpstan.neon.dist
#	resources/vanilla
#	src/pocketmine/Server.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/lang/locale
#	src/utils/Timezone.php
#	tests/phpstan/bootstrap.php
#	tests/phpstan/configs/custom-leveldb.neon
2020-10-13 17:51:49 +01:00
Dylan K. Taylor
d3a3a41d2b Revert back to separated floor/wall sign
the conditionally useless properties are problematic.
2020-10-04 17:52:23 +01:00
Tayyab R
6734dcc79f
Introduce PlayerDisplayNameChangeEvent (listen only) (#3847) 2020-10-01 22:23:02 +01:00
Dylan K. Taylor
7b02cc3efd Implemented #3836: Replace setCancelled() in events with cancel() and uncancel()
The motivation for this is to prevent passing a dynamic argument to cancellation, which in almost all cases is a bug in user code. This same mistake also appears in a few places in the PM core (as seen in this commit), but in those cases the mistakes were mostly harmless since they were taking place before the event was actually called.
closes #3836
2020-09-26 14:31:56 +01:00
SOFe
9d0ac297bb
Improved documentation for CancellableTrait 2020-09-10 16:49:20 +08:00
Dylan K. Taylor
fb4b92d1f4 HandlerListManager: fixed missing null type flag 2020-09-06 16:12:54 +01:00
Dylan K. Taylor
e3dce1f8bd Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/event/player/PlayerChatEvent.php
2020-07-21 19:28:00 +01:00
Dylan K. Taylor
d9c3ec5f91 Merge branch 'stable'
# Conflicts:
#	resources/vanilla
2020-07-11 20:14:42 +01:00
Dylan K. Taylor
923ea46476 PlayerPreLoginEvent: implement Cancellable again 2020-07-11 17:47:53 +01:00
SOFe
81b38cda5d
Removed setCancelled from Cancellable (#3685)
* Removed `setCancelled` from `Cancellable`

Before anyone screams, THIS CHANGE WILL NOT AFFECT MOST PLUGINS
(although it allows future changes to break some).

This commit rewrites the documentation of `Cancellable`,
clarifying the concept of "cancelled" from the perspective of the event
framework.

This commit also removes the `setCancelled` method from `Cancellable`.
This does not affect plugins using the (originally standard)
`setCancelled` method on events directly, since the implementation on
classes was not removed. On the other hand, it no longer requires
`Cancellable` events to implement this method, allowing flexibility on
cancelation conditions, e.g. subclasses may require additional
parameters for cancellation without needing to use hacks to check that
the user cancelled the event in the correct way.
2020-07-11 17:42:15 +01:00
Dylan K. Taylor
d840e8c4d4 Merge commit 'a34f3261c'
# Conflicts:
#	resources/vanilla
#	src/event/entity/EntityExplodeEvent.php
#	src/pocketmine/event/block/SignChangeEvent.php
#	src/utils/Utils.php
2020-07-04 22:39:40 +01:00
Dylan K. Taylor
8673a4872e InventoryEvent: fix wrong return type on getViewers() 2020-06-29 21:55:21 +01:00
Dylan K. Taylor
7e331c590d Use static-analysis-friendly method for getting effects from EffectManager
fixes 5 phpstan level 8 errors
2020-06-27 13:09:05 +01:00
Dylan K. Taylor
1f90aa07aa Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/command/defaults/TeleportCommand.php
#	src/pocketmine/event/entity/EntityDespawnEvent.php
#	src/pocketmine/event/entity/EntityInventoryChangeEvent.php
#	src/pocketmine/event/entity/EntityLevelChangeEvent.php
#	src/pocketmine/event/entity/EntitySpawnEvent.php
#	tests/phpstan/configs/actual-problems.neon
2020-06-21 00:30:45 +01:00
Dylan K. Taylor
b3df5f4e95 CS: strip unneeded phpdoc 2020-06-18 20:01:49 +01:00
Dylan K. Taylor
d0c8d64b40 Merge commit '097c260db'
# Conflicts:
#	resources/vanilla
#	src/item/enchantment/Enchantment.php
#	src/plugin/PluginDescription.php
#	src/pocketmine/entity/Effect.php
#	src/pocketmine/item/ItemFactory.php
#	src/pocketmine/plugin/PluginManager.php
2020-06-14 19:28:05 +01:00
Dylan K. Taylor
b58c425189 Merge branch 'next-minor'
# Conflicts:
#	changelogs/3.12.md
#	resources/vanilla
#	src/VersionInfo.php
2020-06-03 13:11:30 +01:00
Dylan K. Taylor
c72937a4af Merge commit '5dadf1237'
# Conflicts:
#	resources/vanilla
2020-06-03 12:46:06 +01:00
Dylan K. Taylor
cc549630e5 HandlerListManager: fixed @param doc comment not referring to correct ReflectionClass
phpstan doesn't notice this because of the phpstan-param doc directly underneath.
2020-05-30 22:29:30 +01:00
Dylan K. Taylor
23ab6a283b Separate QueryInfo from QueryRegenerateEvent
this removes some useless and confusing APIs from query info.
2020-05-23 11:55:29 +01:00
Dylan K. Taylor
7b3c2a3703 Merge commit '3907a2b6ba58fa49022e3e7c8256731dfa2e0d00' 2020-03-14 13:32:35 +00:00
Dylan K. Taylor
4c51f1dda3 Scrap TextContainer, make TranslationContainer immutable
TextContainer provided zero real value as a base of TranslationContainer, given that it required its own logic to be handled wherever accepted. As such, it's no better than a simple string.
Removing it also allows fixing an ambiguity when embedding translations inside other translations, allowing it to be made immutable.
2020-02-08 13:38:27 +00:00
Dylan K. Taylor
85f3dca11b HandlerListManager: make resolveNearestHandleableParent() a little easier to follow
and also sidestep phpstan complaining about using loop vars outside of loop
2020-02-07 22:07:36 +00:00