30 Commits

Author SHA1 Message Date
Dylan K. Taylor
49bdaee930
Move event handler inheritance test to PHPUnit using mock objects
this is dodgy and we shouldn't rely on it long term.

relates to #6524
2024-11-20 15:38:51 +00:00
Dylan K. Taylor
9bddcc72f7
Merge branch 'minor-next' into major-next 2023-04-11 22:51:50 +01:00
Dylan K. Taylor
1c0eed56f1
Added runtime test for event handler inheritance, to ensure I don't accidentally break it with optimisations 2023-04-11 13:52:37 +01:00
Dylan K. Taylor
aa9f8781ff
Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
f3c9b59856
Bump version for PM5 2022-06-01 19:54:32 +01:00
Dylan K. Taylor
6846f1e78a
Replace disallowed operators in tests/ 2022-01-20 16:48:36 +00:00
Dylan T
127b57048c
Allow plugins to use PSR-4 namespace mapping (#4188)
* Allow plugins to use PSR-4 namespace mapping
this is a reduced implementation which serves the 99% use case without being horribly breakable.

Plugins may now specify a `src-namespace-prefix`, which should be set to the namespace of the classes in `src`.
If the old system is used, `src-namespace-prefix` can be omitted, or set to an empty string.

Examples:
- If `src-namespace-prefix` is `dktapps\test`, `dktapps\test\Main` will be searched for in `src/Main.php`, instead of `src/dktapps/test/Main.php`.

* Migrate TesterPlugin to PSR-4
2021-04-23 19:34:46 +01:00
Dylan K. Taylor
73f913e279
Modernize TesterPlugin 2021-04-19 14:16:05 +01:00
Dylan K. Taylor
73a8c90bee Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	resources/vanilla
#	src/world/Explosion.php
#	tests/phpunit/item/ItemTest.php
#	tests/phpunit/world/format/io/region/RegionLoaderTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMainLoggerTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMemoryLeakTest.php
2020-11-01 14:21:47 +00:00
Dylan K. Taylor
340881d590 remove superfluous newline 2020-10-26 15:59:57 +00:00
Dylan K. Taylor
e2e960e43d tests: add missing function imports 2020-10-26 15:59:42 +00: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
Dylan K. Taylor
0aee39027e Merge branch 'stable' into master
# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/entity/Living.php
#	src/pocketmine/Player.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/block/Potato.php
#	src/pocketmine/block/Sugarcane.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/Chunk.php
#	src/pocketmine/level/format/io/leveldb/LevelDB.php
#	src/world/generator/GeneratorRegisterTask.php
#	tests/phpstan/configs/check-explicit-mixed-baseline.neon
#	tests/phpstan/configs/l7-baseline.neon
#	tests/phpstan/configs/l8-baseline.neon
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMainLoggerTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMemoryLeakTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskPublishProgressRaceTest.php
2020-09-04 01:43:52 +01:00
Dylan K. Taylor
b7578fef9c Fixup TesterPlugin to PHPStan standards 2020-08-28 21:17:21 +01:00
Dylan K. Taylor
da798817b5 Merge branch 'stable'
# Conflicts:
#	changelogs/3.14.md
#	resources/vanilla
#	src/VersionInfo.php
#	src/entity/Attribute.php
2020-07-08 11:46:02 +01:00
Dylan K. Taylor
303344783a CheckTestCompletionTask: use TaskHandler->cancel() 2020-07-08 10:57:20 +01:00
Dylan K. Taylor
65f82f5cdf Task::onRun() and Task::onCancel() now require :void return typehints 2020-05-17 13:58:01 +01:00
Dylan T
67666db827
Task: Remove currentTick parameter (#3498)
This parameter is not used for the vast majority of task use cases and just serves as extra useless boilerplate code, especially for closure-based tasks.
This use case can be replaced using Server->getTick() in the cases where it matters.
2020-05-16 15:28:45 +01:00
Dylan K. Taylor
e3dec95b75 Convert AsyncPool tests into PHPUnit tests 2020-05-11 11:34:50 +01:00
Dylan K. Taylor
752e398970 AsyncTask: TLS now supports storing multiple values (now requires a key/value pair) 2019-04-18 18:58:31 +01:00
Dylan K. Taylor
67a5f3f557 Register MainLogger as SPL global, remove hard MainLogger dependency from many areas, break a bunch of cyclic dependencies 2018-11-05 19:01:59 +00:00
Dylan K. Taylor
d583dc25c3 Merge branch 'release/3.3' 2018-10-10 13:45:31 +01:00
Dylan K. Taylor
2858db430e Fixed AsyncTask publishProgress() race condition on task exit
It's possible for a progress update to be lost due to the task finishing before the main thread found the progress update.
2018-10-10 13:41:15 +01:00
Dylan K. Taylor
6ac0c517f5 Improve and simplify AsyncTask thread-local storage
This is now self-maintaining and doesn't rely on the async pool to wipe its ass on task completion. Instead, the garbage collector will cause thread-local data to be automatically released when the async task is garbage-collected on the main thread.
2018-10-08 12:48:44 +01:00
Dylan K. Taylor
37190c9a65 Apply typehints to all AsyncTask methods
Since we're breaking API here anyway, no point in holding back on this.
2018-09-10 15:54:01 +01:00
Dylan K. Taylor
d62e00cc74 AsyncPool: Remove Server dependency (API breaks included)
This brings two plugin-breaking changes: AsyncTask->onCompletion() and AsyncTask->onProgressUpdate() no longer accept Server parameters.

This now allows for the functionality of AsyncPool and AsyncTask to be tested outside of a Server.
2018-09-10 15:48:59 +01:00
Dylan K. Taylor
b629738312 Merge branch 'release/3.2' 2018-08-19 14:06:34 +01:00
Dylan K. Taylor
21e7b5ea43 TesterPlugin: removed usage of deprecated ServerCommandEvent 2018-08-19 14:05:26 +01:00
Dylan K. Taylor
0cdf4d0c55 Spoon the TesterPlugin into the main repository
I am eating my own words this once, because having the tester plugin as a separate repository makes no sense - it is just added barriers to writing proper tests with no actual benefit. Since the tester plugin is specifically intended for CI, it doesn't make sense for it to be in its own module.
2018-08-19 13:58:13 +01:00