Compare commits

...

143 Commits

Author SHA1 Message Date
a048c9d260 Merge remote-tracking branch 'upstream/major-next' into feat/water-logging 2025-03-23 08:41:35 +01:00
a90e5a6aa2 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/14014323991
2025-03-23 01:42:16 +00:00
df5f87e309 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13913481960
2025-03-18 01:37:04 +00:00
510ef94698 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13878654456
2025-03-16 01:41:31 +00:00
d3f40b7b0c Merge branch 'minor-next' into major-next 2025-03-15 20:37:37 +00:00
dae3e2b336 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13868087288
2025-03-15 01:26:48 +00:00
f2fa5933ea Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13825107599
2025-03-13 01:36:48 +00:00
95a324755b Merge branch 'minor-next' into major-next 2025-03-10 01:31:34 +00:00
1d13054608 Merge branch 'minor-next' into major-next 2025-03-09 01:18:55 +00:00
ec140f7861 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13666455727
2025-03-05 01:27:21 +00:00
66f5bdcb94 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13610829991
2025-03-02 01:38:08 +00:00
5d24d8de0b Merge branch 'minor-next' into major-next 2025-02-26 17:32:14 +00:00
1ad08e2432 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13488997706
2025-02-24 01:26:36 +00:00
a43ebcf217 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13403469065
2025-02-19 01:24:13 +00:00
c637d852e2 Merge branch 'minor-next' into major-next 2025-02-18 01:26:08 +00:00
c58c64de85 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13360931724
2025-02-17 01:26:25 +00:00
694aa17cc9 Merge branch 'minor-next' into major-next 2025-02-16 23:18:56 +00:00
c9441e1078 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13276594014
2025-02-12 02:16:01 +00:00
b0ac8863c4 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13191240897
2025-02-07 01:23:45 +00:00
e9df0baffb Merge branch 'minor-next' of github.com:pmmp/PocketMine-MP into major-next 2025-02-05 01:37:00 +00:00
b3723b5b3e Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13104521333
2025-02-03 01:23:13 +00:00
b370b5458f Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13094301661
2025-02-02 01:26:09 +00:00
8af2d05ec0 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13001707314
2025-01-28 01:21:44 +00:00
4d186b52da Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12920308572
2025-01-23 01:22:04 +00:00
e6ff55823f Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12899221905
2025-01-22 01:23:50 +00:00
d556389b11 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12839491049
2025-01-18 01:19:33 +00:00
976fc63567 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12701510185
2025-01-10 01:26:17 +00:00
02ac512b4e Merge branch 'minor-next' into major-next 2025-01-08 15:25:12 +00:00
708784b0a2 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12643390650
2025-01-07 01:24:48 +00:00
3f7f11b812 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12615442245
2025-01-05 01:37:23 +00:00
984e995659 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12606221104
2025-01-04 01:22:34 +00:00
46604b26f2 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12510342531
2024-12-27 01:23:48 +00:00
6b2fb9c4f8 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12498201064
2024-12-26 01:23:26 +00:00
80b761627a Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12487960388
2024-12-25 01:23:10 +00:00
882d8c4ab9 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12475368381
2024-12-24 01:24:08 +00:00
1c35987ead Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12450134566
2024-12-22 01:37:17 +00:00
88ae00fc4d Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12440895736
2024-12-21 01:22:55 +00:00
47a1aa6470 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12423751811
2024-12-20 01:24:32 +00:00
3e69ee87e4 Remove deprecated stuff
except Permission subscriptions; turns out we still need those
perhaps they should be marked @internal
2024-12-19 00:14:18 +00:00
a2a2ec9d8b Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12364667325
2024-12-17 01:39:12 +00:00
3a0f15ef0d Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12344337356
2024-12-16 01:42:31 +00:00
7a2427ace2 Merge branch 'minor-next' of github.com:pmmp/PocketMine-MP into major-next 2024-12-14 02:40:03 +00:00
f82c8dd3d3 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12307996607
2024-12-13 01:40:43 +00:00
851bbd7384 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12268005529
2024-12-11 01:40:03 +00:00
1ee52b69b0 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12247725255
2024-12-10 01:41:10 +00:00
851f7a9d80 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12227347339
2024-12-09 01:42:26 +00:00
6d2329128a Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12191303914
2024-12-06 01:38:37 +00:00
07045dd424 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12184052098
2024-12-05 16:35:59 +00:00
c5b0df4578 Merge remote-tracking branch 'origin/minor-next' into major-next 2024-12-05 16:07:28 +00:00
5e9dbace90 Merge branch 'minor-next' into major-next 2024-12-05 10:13:24 +00:00
205aabe11f Fixed merge error 2024-12-04 15:27:09 +00:00
3091e1325f Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12151373979
2024-12-04 01:39:59 +00:00
779e80a961 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12131296321
2024-12-03 01:39:33 +00:00
007673cb96 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12111121061
2024-12-02 01:41:02 +00:00
0dae786a21 feat(Server): add a setter for maxPlayers (#6261) 2024-12-01 20:24:50 +00:00
02d181d0c8 Merge branch 'minor-next' into major-next 2024-12-01 15:02:36 +00:00
2fc6bbe84e Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12092463227
2024-11-30 01:35:08 +00:00
002383be89 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12077579940
2024-11-29 01:37:53 +00:00
00bdb6be73 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12060967026
2024-11-28 01:37:50 +00:00
c3c917bb05 Merge branch 'minor-next' into major-next 2024-11-27 17:56:45 +00:00
a078f653f4 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12042121495
2024-11-27 01:39:13 +00:00
ed33983792 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12022106146
2024-11-26 01:36:42 +00:00
15eaf67a0c Merge branch 'minor-next' into major-next 2024-11-25 14:36:25 +00:00
d72941c36c Update IceBomb.php 2024-11-24 23:56:44 +00:00
e51903d7ea Merge branch 'minor-next' into major-next 2024-11-24 23:51:07 +00:00
3e9a96b43a Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11990667732
2024-11-23 21:49:02 +00:00
9fce27eaa8 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11990103798
2024-11-23 20:14:24 +00:00
7208733d62 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11989715327
2024-11-23 19:10:14 +00:00
c61434d87b Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11964819241
2024-11-22 01:36:17 +00:00
dcc258706f Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11944832380
2024-11-21 01:27:14 +00:00
820e2d4a2f Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11924942897
2024-11-20 01:27:32 +00:00
0fb1415f7f Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11904511045
2024-11-19 01:36:12 +00:00
a6534ecbbb Fixed merge error 2024-11-17 01:55:46 +00:00
330bcd2423 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11874902000
2024-11-17 01:39:53 +00:00
e71b9e8dc6 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11866065217
2024-11-16 01:37:29 +00:00
9e2d91bae6 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11865975725
2024-11-16 01:26:32 +00:00
b6f55b78a9 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11862895039
2024-11-15 20:21:33 +00:00
ab5176baf9 Merge branch 'minor-next' into major-next 2024-11-14 23:16:44 +00:00
ef6fce4091 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11824307499
2024-11-13 19:21:19 +00:00
cc335889f3 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11802296296
2024-11-12 17:14:26 +00:00
80b7f6aba4 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11769186885
2024-11-10 22:56:09 +00:00
82c5a3160c Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11652590245
2024-11-03 15:33:37 +00:00
85de28d6c3 Merge branch 'minor-next' into major-next 2024-11-03 14:02:06 +00:00
1ef854f2d1 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/11392123557
2024-10-17 19:59:15 +00:00
082af9978c Merge branch 'minor-next' into major-next 2024-09-23 15:08:45 -05:00
e8620ef94d Restore travis.sh execute permission 2024-09-22 21:59:40 -05:00
83a91634c3 Merge branch 'minor-next' into sync-major-next 2024-09-22 21:44:31 -05:00
3c73bd22dd Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/10458521667
2024-08-19 18:03:25 +00:00
0e1824451b Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/10442250915
2024-08-18 16:50:43 +00:00
6c5ae634fd Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/10373700926
2024-08-13 16:37:46 +00:00
041944ed16 Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/10371827817
2024-08-13 14:36:02 +00:00
603527c6e8 Merge branch 'minor-next' of github.com:pmmp/PocketMine-MP into major-next 2024-08-13 13:39:00 +00:00
7164dd9f49 implement waterlogged flow 2024-08-10 22:16:16 +02:00
3ec3be6b20 base system 2024-08-10 21:00:38 +02:00
1ac08ea73b Remove enchant properties that no longer exists on PM6 (#6417) 2024-08-10 08:51:06 -05:00
c9e8d382c5 Merge branch 'minor-next' of github.com:pmmp/PocketMine-MP into major-next 2024-08-09 13:33:07 +01:00
12179aa03a Merge branch 'minor-next' into major-next 2024-05-06 15:42:49 +01:00
e781c64540 Merge branch 'minor-next' into major-next 2024-03-14 12:47:18 +00:00
644693ffee Merge branch 'minor-next' into major-next 2024-02-12 11:55:36 +00:00
6b66cbfb1c Merge branch 'minor-next' into major-next 2023-12-20 15:26:57 +00:00
4d337add7c Merge branch 'minor-next' into major-next 2023-12-14 14:03:09 +00:00
9d75c45bf5 Merge branch 'minor-next' into major-next 2023-11-09 18:06:06 +00:00
c7a537abbb Merge branch 'minor-next' into major-next 2023-11-01 18:03:04 +00:00
54694df48c Merge branch 'minor-next' into major-next 2023-11-01 16:39:55 +00:00
15aae721cd Merge branch 'minor-next' into major-next 2023-10-26 12:57:24 +01:00
d565be93a8 Merge branch 'minor-next' into major-next 2023-10-24 11:57:30 +01:00
e32a90be72 Make Player->getFirstPlayed() and Player->getLastPlayed() return DateTimeImmutable (#6042) 2023-10-17 16:26:21 +01:00
d4d7d02067 Merge branch 'minor-next' into major-next 2023-10-16 21:29:11 +01:00
a45e143e81 Merge branch 'minor-next' into major-next 2023-09-21 13:29:58 +01:00
05981d2669 Merge branch 'minor-next' into major-next 2023-09-20 19:15:08 +01:00
fa9bba470c RegistryTrait: use native parameter types for __callStatic() arguments (#5944) 2023-09-08 12:03:03 +01:00
361626d236 Merge branch 'minor-next' into major-next 2023-09-08 11:27:09 +01:00
16d8522245 Farewell EnumTrait, you served us well 2023-09-08 11:26:11 +01:00
a4f3476190 Merge branch 'minor-next' into major-next 2023-09-08 11:22:44 +01:00
e96e68d221 Merge branch 'minor-next' into major-next 2023-09-07 20:33:35 +01:00
f1a6d71cc1 Merge branch 'minor-next' into major-next 2023-09-07 20:30:58 +01:00
89f42c80d4 Strip out deprecated stuff 2023-09-07 20:26:04 +01:00
cd6b780d31 Merge branch 'minor-next' into major-next 2023-09-07 20:10:31 +01:00
ed61a68013 Entity: make getNetworkTypeId non-static (#6037)
This was static to permit ItemFactory to register spawn eggs for all known entity types in early PM4. However, nowadays we provide a callback to the spawn egg instead, and spawn eggs must be manually implemented, so this is no longer needed.

In addition, having this static forces everyone to make a new entity class for every unique type of entity, which isn't ideal.
2023-09-06 15:26:32 +01:00
4dc9d696d0 Merge branch 'minor-next' into major-next 2023-09-06 13:03:51 +01:00
258038c9a9 Merge branch 'minor-next' into major-next 2023-08-21 16:08:32 +01:00
5c915a3dfe Merge branch 'minor-next' into major-next 2023-08-18 12:33:54 +01:00
8c594fd126 Merge branch 'minor-next' into major-next 2023-08-15 17:41:50 +01:00
9fd6653f36 Remove deprecated APIs 2023-08-09 16:38:09 +01:00
32d67080e5 Merge branch 'minor-next' into major-next 2023-08-09 16:35:32 +01:00
ed9d057ca2 Merge branch 'minor-next' into major-next 2023-08-08 18:27:58 +01:00
5ec0e0f20b Merge branch 'minor-next' into major-next 2023-08-08 17:48:23 +01:00
cb251069dd PluginLoader: rename parameters 2023-08-07 16:39:54 +01:00
e0ad39b70a Remove ResourceProvider cruft
this had no obvious reason for existing, and with #5958 looming, this will become altogether useless anyway.
2023-08-07 16:14:01 +01:00
9997b614bc Merge branch 'minor-next' into major-next 2023-08-01 12:53:53 +01:00
89f8f421a6 Server: stop discriminating against folder plugins when generating crashdumps
in PM6, non-development plugins may appear in folder form.
2023-07-26 10:47:39 +01:00
c4ff6d7757 Merge branch 'minor-next' into major-next 2023-07-24 16:45:55 +01:00
3c0e7ae492 Merge branch 'minor-next' into major-next 2023-07-24 12:07:55 +01:00
b944205f60 Remove useless checks for plugins disabling other plugins (#5931) 2023-07-24 11:31:19 +01:00
2ab3393568 Unlink DevTools submodule and remove references
we don't need this as a submodule anymore, since it's not used in the core.
2023-07-20 11:29:06 +01:00
1e1b95e1b8 uh oh 2023-07-19 18:06:44 +01:00
62465fa676 Integrate FolderPluginLoader
the motivation for this is described in #5917

a new version of DevTools will be required, as the current version will cause the server to abort during startup with this change due to duplicated plugin loading.
2023-07-19 18:05:41 +01:00
aac5944396 Accept Translatable permission messages in Command (#5830) 2023-07-19 16:38:15 +01:00
74cfd687d7 CraftingManagerFromDataHelper: Fix parameter name typo (#5870)
due to named parameters, this change must target PM6
2023-07-19 11:05:52 +01:00
f2f30143b0 Merge branch 'minor-next' into major-next 2023-07-18 22:22:43 +01:00
d98adf127f Merge branch 'minor-next' into major-next 2023-07-17 16:13:28 +01:00
280bf60830 Merge branch 'minor-next' into major-next 2023-07-14 13:28:07 +01:00
1ffa945fbf Disallow plugins disabling other plugins (#5872) 2023-07-13 13:44:28 +01:00
121 changed files with 381 additions and 1984 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "tests/plugins/DevTools"]
path = tests/plugins/DevTools
url = https://github.com/pmmp/DevTools.git
[submodule "build/php"]
path = build/php
url = https://github.com/pmmp/php-build-scripts.git

View File

@ -5,7 +5,6 @@ $finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/build')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/tools')
->notPath('plugins/DevTools')
->notName('PocketMine.php');
return (new PhpCsFixer\Config)

View File

@ -78,7 +78,6 @@
"sort-packages": true
},
"scripts": {
"make-devtools": "@php -dphar.readonly=0 tests/plugins/DevTools/src/ConsoleScript.php --make ./ --relative tests/plugins/DevTools --out plugins/DevTools.phar",
"make-server": [
"@composer install --no-dev --classmap-authoritative --ignore-platform-reqs",
"@php -dphar.readonly=0 build/server-phar.php"

View File

@ -10,9 +10,7 @@ includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
rules:
- pocketmine\phpstan\rules\DeprecatedLegacyEnumAccessRule
- pocketmine\phpstan\rules\DisallowDynamicNewRule
- pocketmine\phpstan\rules\DisallowEnumComparisonRule
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
- pocketmine\phpstan\rules\ExplodeLimitRule
- pocketmine\phpstan\rules\UnsafeForeachArrayOfStringRule

View File

@ -123,13 +123,6 @@ class MemoryManager{
return $this->globalMemoryLimit;
}
/**
* @deprecated
*/
public function canUseChunkCache() : bool{
return !$this->lowMemory;
}
/**
* Returns the allowed chunk radius based on the current memory usage.
*/
@ -236,13 +229,4 @@ class MemoryManager{
}
}
}
/**
* Static memory dumper accessible from any thread.
* @deprecated
* @see MemoryDump
*/
public static function dumpMemory(mixed $startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger) : void{
MemoryDump::dumpMemory($startingObject, $outputFolder, $maxNesting, $maxStringSize, $logger);
}
}

View File

@ -80,6 +80,7 @@ use pocketmine\player\PlayerDataLoadException;
use pocketmine\player\PlayerDataProvider;
use pocketmine\player\PlayerDataSaveException;
use pocketmine\player\PlayerInfo;
use pocketmine\plugin\FolderPluginLoader;
use pocketmine\plugin\PharPluginLoader;
use pocketmine\plugin\PluginEnableOrder;
use pocketmine\plugin\PluginGraylist;
@ -346,6 +347,10 @@ class Server{
return $this->maxPlayers;
}
public function setMaxPlayers(int $maxPlayers) : void{
$this->maxPlayers = $maxPlayers;
}
/**
* Returns whether the server requires that players be authenticated to Xbox Live. If true, connecting players who
* are not logged into Xbox Live will be disconnected.
@ -1029,6 +1034,7 @@ class Server{
$this->pluginManager = new PluginManager($this, $this->configGroup->getPropertyBool(Yml::PLUGINS_LEGACY_DATA_DIR, true) ? null : Path::join($this->dataPath, "plugin_data"), $pluginGraylist);
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
$this->pluginManager->registerInterface(new ScriptPluginLoader());
$this->pluginManager->registerInterface(new FolderPluginLoader($this->autoloader));
$providerManager = new WorldProviderManager();
if(

View File

@ -29,6 +29,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Spawnable;
use pocketmine\block\tile\Tile;
use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\Waterloggable;
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataReader;
@ -384,7 +385,13 @@ class Block{
if($chunk === null){
throw new AssumptionFailedError("World::setBlock() should have loaded the chunk before calling this method");
}
$chunk->setBlockStateId($this->position->x & Chunk::COORD_MASK, $this->position->y, $this->position->z & Chunk::COORD_MASK, $this->getStateId());
$x = $this->position->x & Chunk::COORD_MASK;
$z = $this->position->z & Chunk::COORD_MASK;
$stateId = $this->getStateId();
$chunk->setBlockStateId($x, $this->position->y, $z, $stateId);
if($this instanceof Waterloggable){
$chunk->setWaterStateId($x, $this->position->y, $z, $this->getWaterState()?->getStateId());
}
$tileType = $this->idInfo->getTileClass();
$oldTile = $world->getTile($this->position);
@ -621,6 +628,9 @@ class Block{
final public function position(World $world, int $x, int $y, int $z) : void{
$this->position = new Position($x, $y, $z, $world);
$this->collisionBoxes = null;
if($this instanceof Waterloggable){
$this->getWaterState()?->position($world, $x, $y, $z);
}
}
/**

View File

@ -26,6 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\MinimumCostFlowCalculator;
use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\Waterloggable;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\event\block\BlockSpreadEvent;
@ -140,6 +141,9 @@ abstract class Liquid extends Transparent{
}
protected function getEffectiveFlowDecay(Block $block) : int{
if($block instanceof Waterloggable){
$block = $block->getWaterState() ?? $block;
}
if(!($block instanceof Liquid) || !$block->hasSameTypeId($this)){
return -1;
}
@ -177,6 +181,9 @@ abstract class Liquid extends Transparent{
$sideZ = $z + $dz;
$sideBlock = $world->getBlockAt($sideX, $sideY, $sideZ);
if($sideBlock instanceof Waterloggable){
$sideBlock = $sideBlock->getWaterState() ?? $sideBlock;
}
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
if($blockDecay < 0){
@ -288,14 +295,25 @@ abstract class Liquid extends Transparent{
}
if($falling !== $this->falling || (!$falling && $newDecay !== $this->decay)){
$actualBlock = $world->getBlockAt($x, $y, $z);
if(!$falling && $newDecay < 0){
$world->setBlockAt($x, $y, $z, VanillaBlocks::AIR());
if($actualBlock instanceof Waterloggable && $this instanceof Water){
$actualBlock->setWaterState(null);
$world->setBlockAt($x, $y, $z, $actualBlock);
}else{
$world->setBlockAt($x, $y, $z, VanillaBlocks::AIR());
}
return;
}
$this->falling = $falling;
$this->decay = $falling ? 0 : $newDecay;
$world->setBlockAt($x, $y, $z, $this); //local block update will cause an update to be scheduled
if($actualBlock instanceof Waterloggable && $this instanceof Water){
$actualBlock->setWaterState($this);
$world->setBlockAt($x, $y, $z, $actualBlock);
}else{
$world->setBlockAt($x, $y, $z, $this); //local block update will cause an update to be scheduled
}
}
}
@ -343,6 +361,9 @@ abstract class Liquid extends Transparent{
/** @phpstan-impure */
private function getSmallestFlowDecay(Block $block, int $decay) : int{
if($block instanceof Waterloggable){
$block = $block->getWaterState() ?? $block;
}
if(!($block instanceof Liquid) || !$block->hasSameTypeId($this)){
return $decay;
}
@ -370,6 +391,9 @@ abstract class Liquid extends Transparent{
}
protected function canFlowInto(Block $block) : bool{
if($block instanceof Waterloggable){
$block = $block->getWaterState() ?? $block;
}
return
$this->position->getWorld()->isInWorld($block->position->x, $block->position->y, $block->position->z) &&
$block->canBeFlowedInto() &&

View File

@ -26,6 +26,8 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\StairShape;
use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\Waterloggable;
use pocketmine\block\utils\WaterloggableTrait;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
@ -35,8 +37,11 @@ use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
class Stair extends Transparent{
class Stair extends Transparent implements Waterloggable{
use HorizontalFacingTrait;
use WaterloggableTrait {
WaterloggableTrait::readStateFromWorld as private readWaterStateFromWorld;
}
protected bool $upsideDown = false;
protected StairShape $shape = StairShape::STRAIGHT;
@ -48,6 +53,7 @@ class Stair extends Transparent{
public function readStateFromWorld() : Block{
parent::readStateFromWorld();
$this->readWaterStateFromWorld();
$this->collisionBoxes = null;
@ -131,7 +137,19 @@ class Stair extends Transparent{
$this->facing = $player->getHorizontalFacing();
}
$this->upsideDown = (($clickVector->y > 0.5 && $face !== Facing::UP) || $face === Facing::DOWN);
if($blockReplace instanceof Water && $blockReplace->isSource()){
$this->waterState = $blockReplace;
}
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
public function onBreak(Item $item, ?Player $player = null, array &$returnedItems = []) : bool{
$ret = parent::onBreak($item, $player, $returnedItems);
if($this->waterState !== null){
$this->position->getWorld()->setBlock($this->position, $this->waterState);
}
return $ret;
}
}

View File

@ -58,17 +58,10 @@ class SweetBerryBush extends Flowable{
return 0;
}
/**
* @deprecated
*/
protected function canBeSupportedBy(Block $block) : bool{
return $block->getTypeId() !== BlockTypeIds::FARMLAND && //bedrock-specific thing (bug?)
($block->hasTypeTag(BlockTypeTags::DIRT) || $block->hasTypeTag(BlockTypeTags::MUD));
}
private function canBeSupportedAt(Block $block) : bool{
$supportBlock = $block->getSide(Facing::DOWN);
return $this->canBeSupportedBy($supportBlock);
return $supportBlock->getTypeId() !== BlockTypeIds::FARMLAND && //bedrock-specific thing (bug?)
($supportBlock->hasTypeTag(BlockTypeTags::DIRT) || $supportBlock->hasTypeTag(BlockTypeTags::MUD));
}
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{

View File

@ -804,8 +804,8 @@ use function strtolower;
* @method static Water WATER()
* @method static WaterCauldron WATER_CAULDRON()
* @method static NetherVines WEEPING_VINES()
* @method static WeightedPressurePlateHeavy WEIGHTED_PRESSURE_PLATE_HEAVY()
* @method static WeightedPressurePlateLight WEIGHTED_PRESSURE_PLATE_LIGHT()
* @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_HEAVY()
* @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_LIGHT()
* @method static Wheat WHEAT()
* @method static Flower WHITE_TULIP()
* @method static WitherRose WITHER_ROSE()
@ -1201,14 +1201,14 @@ final class VanillaBlocks{
self::register("lily_pad", fn(BID $id) => new WaterLily($id, "Lily Pad", new Info(BreakInfo::instant())));
$weightedPressurePlateBreakInfo = new Info(BreakInfo::pickaxe(0.5));
self::register("weighted_pressure_plate_heavy", fn(BID $id) => new WeightedPressurePlateHeavy(
self::register("weighted_pressure_plate_heavy", fn(BID $id) => new WeightedPressurePlate(
$id,
"Weighted Pressure Plate Heavy",
$weightedPressurePlateBreakInfo,
deactivationDelayTicks: 10,
signalStrengthFactor: 0.1
));
self::register("weighted_pressure_plate_light", fn(BID $id) => new WeightedPressurePlateLight(
self::register("weighted_pressure_plate_light", fn(BID $id) => new WeightedPressurePlate(
$id,
"Weighted Pressure Plate Light",
$weightedPressurePlateBreakInfo,

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
/**
* @deprecated
*/
class WeightedPressurePlateLight extends WeightedPressurePlate{
}

View File

@ -35,20 +35,6 @@ abstract class Spawnable extends Tile{
/** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */
private ?CacheableNbt $spawnCompoundCache = null;
/**
* @deprecated
*/
public function isDirty() : bool{
return $this->spawnCompoundCache === null;
}
/**
* @deprecated
*/
public function setDirty(bool $dirty = true) : void{
$this->clearSpawnCompoundCache();
}
public function clearSpawnCompoundCache() : void{
$this->spawnCompoundCache = null;
}

View File

@ -23,54 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BannerPatternType BORDER()
* @method static BannerPatternType BRICKS()
* @method static BannerPatternType CIRCLE()
* @method static BannerPatternType CREEPER()
* @method static BannerPatternType CROSS()
* @method static BannerPatternType CURLY_BORDER()
* @method static BannerPatternType DIAGONAL_LEFT()
* @method static BannerPatternType DIAGONAL_RIGHT()
* @method static BannerPatternType DIAGONAL_UP_LEFT()
* @method static BannerPatternType DIAGONAL_UP_RIGHT()
* @method static BannerPatternType FLOWER()
* @method static BannerPatternType GRADIENT()
* @method static BannerPatternType GRADIENT_UP()
* @method static BannerPatternType HALF_HORIZONTAL()
* @method static BannerPatternType HALF_HORIZONTAL_BOTTOM()
* @method static BannerPatternType HALF_VERTICAL()
* @method static BannerPatternType HALF_VERTICAL_RIGHT()
* @method static BannerPatternType MOJANG()
* @method static BannerPatternType RHOMBUS()
* @method static BannerPatternType SKULL()
* @method static BannerPatternType SMALL_STRIPES()
* @method static BannerPatternType SQUARE_BOTTOM_LEFT()
* @method static BannerPatternType SQUARE_BOTTOM_RIGHT()
* @method static BannerPatternType SQUARE_TOP_LEFT()
* @method static BannerPatternType SQUARE_TOP_RIGHT()
* @method static BannerPatternType STRAIGHT_CROSS()
* @method static BannerPatternType STRIPE_BOTTOM()
* @method static BannerPatternType STRIPE_CENTER()
* @method static BannerPatternType STRIPE_DOWNLEFT()
* @method static BannerPatternType STRIPE_DOWNRIGHT()
* @method static BannerPatternType STRIPE_LEFT()
* @method static BannerPatternType STRIPE_MIDDLE()
* @method static BannerPatternType STRIPE_RIGHT()
* @method static BannerPatternType STRIPE_TOP()
* @method static BannerPatternType TRIANGLES_BOTTOM()
* @method static BannerPatternType TRIANGLES_TOP()
* @method static BannerPatternType TRIANGLE_BOTTOM()
* @method static BannerPatternType TRIANGLE_TOP()
*/
enum BannerPatternType{
use LegacyEnumShimTrait;
case BORDER;
case BRICKS;
case CIRCLE;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BellAttachmentType CEILING()
* @method static BellAttachmentType FLOOR()
* @method static BellAttachmentType ONE_WALL()
* @method static BellAttachmentType TWO_WALLS()
*/
enum BellAttachmentType{
use LegacyEnumShimTrait;
case CEILING;
case FLOOR;
case ONE_WALL;

View File

@ -24,19 +24,8 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\inventory\BrewingStandInventory;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BrewingStandSlot EAST()
* @method static BrewingStandSlot NORTHWEST()
* @method static BrewingStandSlot SOUTHWEST()
*/
enum BrewingStandSlot{
use LegacyEnumShimTrait;
case EAST;
case NORTHWEST;
case SOUTHWEST;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static CopperOxidation EXPOSED()
* @method static CopperOxidation NONE()
* @method static CopperOxidation OXIDIZED()
* @method static CopperOxidation WEATHERED()
*/
enum CopperOxidation : int{
use LegacyEnumShimTrait;
case NONE = 0;
case EXPOSED = 1;
case WEATHERED = 2;

View File

@ -23,21 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static CoralType BRAIN()
* @method static CoralType BUBBLE()
* @method static CoralType FIRE()
* @method static CoralType HORN()
* @method static CoralType TUBE()
*/
enum CoralType{
use LegacyEnumShimTrait;
case TUBE;
case BRAIN;
case BUBBLE;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static DirtType COARSE()
* @method static DirtType NORMAL()
* @method static DirtType ROOTED()
*/
enum DirtType{
use LegacyEnumShimTrait;
case NORMAL;
case COARSE;
case ROOTED;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static DripleafState FULL_TILT()
* @method static DripleafState PARTIAL_TILT()
* @method static DripleafState STABLE()
* @method static DripleafState UNSTABLE()
*/
enum DripleafState{
use LegacyEnumShimTrait;
case STABLE;
case UNSTABLE;
case PARTIAL_TILT;

View File

@ -24,35 +24,12 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\color\Color;
use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static DyeColor BLACK()
* @method static DyeColor BLUE()
* @method static DyeColor BROWN()
* @method static DyeColor CYAN()
* @method static DyeColor GRAY()
* @method static DyeColor GREEN()
* @method static DyeColor LIGHT_BLUE()
* @method static DyeColor LIGHT_GRAY()
* @method static DyeColor LIME()
* @method static DyeColor MAGENTA()
* @method static DyeColor ORANGE()
* @method static DyeColor PINK()
* @method static DyeColor PURPLE()
* @method static DyeColor RED()
* @method static DyeColor WHITE()
* @method static DyeColor YELLOW()
*
* @phpstan-type TMetadata array{0: string, 1: Color}
*/
enum DyeColor{
use LegacyEnumShimTrait;
case WHITE;
case ORANGE;
case MAGENTA;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static FroglightType OCHRE()
* @method static FroglightType PEARLESCENT()
* @method static FroglightType VERDANT()
*/
enum FroglightType{
use LegacyEnumShimTrait;
case OCHRE;
case PEARLESCENT;
case VERDANT;

View File

@ -23,26 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static LeavesType ACACIA()
* @method static LeavesType AZALEA()
* @method static LeavesType BIRCH()
* @method static LeavesType CHERRY()
* @method static LeavesType DARK_OAK()
* @method static LeavesType FLOWERING_AZALEA()
* @method static LeavesType JUNGLE()
* @method static LeavesType MANGROVE()
* @method static LeavesType OAK()
* @method static LeavesType SPRUCE()
*/
enum LeavesType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -24,24 +24,8 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\math\Facing;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static LeverFacing DOWN_AXIS_X()
* @method static LeverFacing DOWN_AXIS_Z()
* @method static LeverFacing EAST()
* @method static LeverFacing NORTH()
* @method static LeverFacing SOUTH()
* @method static LeverFacing UP_AXIS_X()
* @method static LeverFacing UP_AXIS_Z()
* @method static LeverFacing WEST()
*/
enum LeverFacing{
use LegacyEnumShimTrait;
case UP_AXIS_X;
case UP_AXIS_Z;
case DOWN_AXIS_X;

View File

@ -23,23 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static MobHeadType CREEPER()
* @method static MobHeadType DRAGON()
* @method static MobHeadType PIGLIN()
* @method static MobHeadType PLAYER()
* @method static MobHeadType SKELETON()
* @method static MobHeadType WITHER_SKELETON()
* @method static MobHeadType ZOMBIE()
*/
enum MobHeadType{
use LegacyEnumShimTrait;
case SKELETON;
case WITHER_SKELETON;
case ZOMBIE;

View File

@ -23,27 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static MushroomBlockType ALL_CAP()
* @method static MushroomBlockType CAP_EAST()
* @method static MushroomBlockType CAP_MIDDLE()
* @method static MushroomBlockType CAP_NORTH()
* @method static MushroomBlockType CAP_NORTHEAST()
* @method static MushroomBlockType CAP_NORTHWEST()
* @method static MushroomBlockType CAP_SOUTH()
* @method static MushroomBlockType CAP_SOUTHEAST()
* @method static MushroomBlockType CAP_SOUTHWEST()
* @method static MushroomBlockType CAP_WEST()
* @method static MushroomBlockType PORES()
*/
enum MushroomBlockType{
use LegacyEnumShimTrait;
case PORES;
case CAP_NORTHWEST;
case CAP_NORTH;

View File

@ -26,34 +26,12 @@ namespace pocketmine\block\utils;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\lang\Translatable;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static RecordType DISK_11()
* @method static RecordType DISK_13()
* @method static RecordType DISK_5()
* @method static RecordType DISK_BLOCKS()
* @method static RecordType DISK_CAT()
* @method static RecordType DISK_CHIRP()
* @method static RecordType DISK_FAR()
* @method static RecordType DISK_MALL()
* @method static RecordType DISK_MELLOHI()
* @method static RecordType DISK_OTHERSIDE()
* @method static RecordType DISK_PIGSTEP()
* @method static RecordType DISK_STAL()
* @method static RecordType DISK_STRAD()
* @method static RecordType DISK_WAIT()
* @method static RecordType DISK_WARD()
*
* @phpstan-type TMetadata array{0: string, 1: LevelSoundEvent::*, 2: Translatable}
*/
enum RecordType{
use LegacyEnumShimTrait;
case DISK_13;
case DISK_5;
case DISK_CAT;

View File

@ -23,23 +23,9 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
use pocketmine\world\generator\object\TreeType;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SaplingType ACACIA()
* @method static SaplingType BIRCH()
* @method static SaplingType DARK_OAK()
* @method static SaplingType JUNGLE()
* @method static SaplingType OAK()
* @method static SaplingType SPRUCE()
*/
enum SaplingType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SlabType BOTTOM()
* @method static SlabType DOUBLE()
* @method static SlabType TOP()
*/
enum SlabType{
use LegacyEnumShimTrait;
case BOTTOM;
case TOP;
case DOUBLE;

View File

@ -23,21 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static StairShape INNER_LEFT()
* @method static StairShape INNER_RIGHT()
* @method static StairShape OUTER_LEFT()
* @method static StairShape OUTER_RIGHT()
* @method static StairShape STRAIGHT()
*/
enum StairShape{
use LegacyEnumShimTrait;
case STRAIGHT;
case INNER_LEFT;
case INNER_RIGHT;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SupportType CENTER()
* @method static SupportType EDGE()
* @method static SupportType FULL()
* @method static SupportType NONE()
*/
enum SupportType{
use LegacyEnumShimTrait;
case FULL;
case CENTER;
case EDGE;

View File

@ -23,18 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static WallConnectionType SHORT()
* @method static WallConnectionType TALL()
*/
enum WallConnectionType{
use LegacyEnumShimTrait;
case SHORT;
case TALL;
}

View File

@ -21,11 +21,12 @@
declare(strict_types=1);
namespace pocketmine\block;
namespace pocketmine\block\utils;
/**
* @deprecated
*/
class WeightedPressurePlateHeavy extends WeightedPressurePlate{
use pocketmine\block\Water;
interface Waterloggable{
public function getWaterState() : ?Water;
public function setWaterState(?Water $state) : Waterloggable;
}

View File

@ -21,20 +21,32 @@
declare(strict_types=1);
namespace pocketmine\scheduler;
namespace pocketmine\block\utils;
class PublishProgressRaceAsyncTask extends AsyncTask{
/** @var bool */
public static $success = false;
use pocketmine\block\Water;
public function onRun() : void{
$this->publishProgress("hello");
trait WaterloggableTrait{
protected ?Water $waterState = null;
public function getWaterState() : ?Water {
return $this->waterState;
}
public function onProgressUpdate($progress) : void{
if($progress === "hello"){
// thread local on main thread
self::$success = true;
}
public function setWaterState(?Water $state) : self{
$this->waterState = $state;
return $this;
}
public function readStateFromWorld() : void{
$this->waterState?->readStateFromWorld();
}
public function onNearbyBlockChange() : void{
$this->waterState?->onNearbyBlockChange();
}
public function onScheduledUpdate() : void{
$this->waterState?->onScheduledUpdate();
}
}

View File

@ -23,26 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static WoodType ACACIA()
* @method static WoodType BIRCH()
* @method static WoodType CHERRY()
* @method static WoodType CRIMSON()
* @method static WoodType DARK_OAK()
* @method static WoodType JUNGLE()
* @method static WoodType MANGROVE()
* @method static WoodType OAK()
* @method static WoodType SPRUCE()
* @method static WoodType WARPED()
*/
enum WoodType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -66,7 +66,7 @@ abstract class Command{
/** @var string[] */
private array $permission = [];
private ?string $permissionMessage = null;
private Translatable|string|null $permissionMessage = null;
/**
* @param string[] $aliases
@ -122,10 +122,11 @@ abstract class Command{
return true;
}
if($this->permissionMessage === null){
$target->sendMessage(KnownTranslationFactory::pocketmine_command_error_permission($this->name)->prefix(TextFormat::RED));
}elseif($this->permissionMessage !== ""){
$target->sendMessage(str_replace("<permission>", $permission ?? implode(";", $this->permission), $this->permissionMessage));
$message = $this->permissionMessage ?? KnownTranslationFactory::pocketmine_command_error_permission($this->name);
if($message instanceof Translatable){
$target->sendMessage($message->prefix(TextFormat::RED));
}elseif($message !== ""){
$target->sendMessage(str_replace("<permission>", $permission ?? implode(";", $this->permission), $message));
}
return false;
@ -198,7 +199,7 @@ abstract class Command{
return $this->activeAliases;
}
public function getPermissionMessage() : ?string{
public function getPermissionMessage() : Translatable|string|null{
return $this->permissionMessage;
}
@ -226,7 +227,7 @@ abstract class Command{
$this->description = $description;
}
public function setPermissionMessage(string $permissionMessage) : void{
public function setPermissionMessage(Translatable|string $permissionMessage) : void{
$this->permissionMessage = $permissionMessage;
}

View File

@ -152,10 +152,10 @@ final class CraftingManagerFromDataHelper{
* @return mixed[]
*
* @phpstan-template TData of object
* @phpstan-param class-string<TData> $modelCLass
* @phpstan-param class-string<TData> $modelClass
* @phpstan-return list<TData>
*/
public static function loadJsonArrayOfObjectsFile(string $filePath, string $modelCLass) : array{
public static function loadJsonArrayOfObjectsFile(string $filePath, string $modelClass) : array{
$recipes = json_decode(Filesystem::fileGetContents($filePath));
if(!is_array($recipes)){
throw new SavedDataLoadingException("$filePath root should be an array, got " . get_debug_type($recipes));
@ -166,7 +166,7 @@ final class CraftingManagerFromDataHelper{
$mapper->bExceptionOnUndefinedProperty = true;
$mapper->bExceptionOnMissingData = true;
return self::loadJsonObjectListIntoModel($mapper, $modelCLass, $recipes);
return self::loadJsonObjectListIntoModel($mapper, $modelClass, $recipes);
}
/**

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\crafting;
use pocketmine\utils\LegacyEnumShimTrait;
use pocketmine\world\sound\BlastFurnaceSound;
use pocketmine\world\sound\CampfireSound;
use pocketmine\world\sound\FurnaceSound;
@ -32,20 +31,9 @@ use pocketmine\world\sound\Sound;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static FurnaceType BLAST_FURNACE()
* @method static FurnaceType CAMPFIRE()
* @method static FurnaceType FURNACE()
* @method static FurnaceType SMOKER()
* @method static FurnaceType SOUL_CAMPFIRE()
*
* @phpstan-type TMetadata array{0: int, 1: Sound}
*/
enum FurnaceType{
use LegacyEnumShimTrait;
case FURNACE;
case BLAST_FURNACE;
case SMOKER;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\crafting;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static ShapelessRecipeType CARTOGRAPHY()
* @method static ShapelessRecipeType CRAFTING()
* @method static ShapelessRecipeType SMITHING()
* @method static ShapelessRecipeType STONECUTTER()
*/
enum ShapelessRecipeType{
use LegacyEnumShimTrait;
case CRAFTING;
case STONECUTTER;
case SMITHING;

View File

@ -166,8 +166,7 @@ use pocketmine\block\WallBanner;
use pocketmine\block\WallCoralFan;
use pocketmine\block\WallSign;
use pocketmine\block\Water;
use pocketmine\block\WeightedPressurePlateHeavy;
use pocketmine\block\WeightedPressurePlateLight;
use pocketmine\block\WeightedPressurePlate;
use pocketmine\block\Wheat;
use pocketmine\block\Wood;
use pocketmine\block\WoodenButton;
@ -1869,11 +1868,11 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
return Writer::create(Ids::WEEPING_VINES)
->writeInt(StateNames::WEEPING_VINES_AGE, $block->getAge());
});
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlateHeavy $block) : Writer{
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlate $block) : Writer{
return Writer::create(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE)
->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength());
});
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), function(WeightedPressurePlateLight $block) : Writer{
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), function(WeightedPressurePlate $block) : Writer{
return Writer::create(Ids::LIGHT_WEIGHTED_PRESSURE_PLATE)
->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength());
});

View File

@ -1,89 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\runtime;
/**
* Provides backwards-compatible shims for the old codegen'd enum describer methods.
* This is kept for plugin backwards compatibility, but these functions should not be used in new code.
* @deprecated
*/
trait LegacyRuntimeEnumDescriberTrait{
abstract protected function enum(\UnitEnum &$case) : void;
public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType &$value) : void{
$this->enum($value);
}
public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void{
$this->enum($value);
}
public function coralType(\pocketmine\block\utils\CoralType &$value) : void{
$this->enum($value);
}
public function dirtType(\pocketmine\block\utils\DirtType &$value) : void{
$this->enum($value);
}
public function dripleafState(\pocketmine\block\utils\DripleafState &$value) : void{
$this->enum($value);
}
public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void{
$this->enum($value);
}
public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void{
$this->enum($value);
}
public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void{
$this->enum($value);
}
public function medicineType(\pocketmine\item\MedicineType &$value) : void{
$this->enum($value);
}
public function mobHeadType(\pocketmine\block\utils\MobHeadType &$value) : void{
$this->enum($value);
}
public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void{
$this->enum($value);
}
public function potionType(\pocketmine\item\PotionType &$value) : void{
$this->enum($value);
}
public function slabType(\pocketmine\block\utils\SlabType &$value) : void{
$this->enum($value);
}
public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void{
$this->enum($value);
}
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\data\runtime;
use pocketmine\block\utils\BrewingStandSlot;
use pocketmine\block\utils\WallConnectionType;
use pocketmine\math\Facing;
@ -35,14 +34,9 @@ use pocketmine\math\Facing;
* You may use it as a type for parameters and return values, but it should not be implemented outside of this package.
* New methods may be added without warning.
*/
interface RuntimeDataDescriber extends RuntimeEnumDescriber{
interface RuntimeDataDescriber{
public function int(int $bits, int &$value) : void;
/**
* @deprecated Use {@link RuntimeDataDescriber::boundedIntAuto()} instead.
*/
public function boundedInt(int $bits, int $min, int $max, int &$value) : void;
/**
* Same as boundedInt() but automatically calculates the required number of bits from the range.
* The range bounds must be constant.
@ -77,14 +71,6 @@ interface RuntimeDataDescriber extends RuntimeEnumDescriber{
*/
public function wallConnections(array &$connections) : void;
/**
* @param BrewingStandSlot[] $slots
* @phpstan-param array<int, BrewingStandSlot> $slots
*
* @deprecated Use {@link enumSet()} instead.
*/
public function brewingStandSlots(array &$slots) : void;
public function railShape(int &$railShape) : void;
public function straightOnlyRailShape(int &$railShape) : void;

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\data\runtime;
use pocketmine\block\utils\BrewingStandSlot;
use pocketmine\block\utils\RailConnectionInfo;
use pocketmine\block\utils\WallConnectionType;
use pocketmine\math\Axis;
@ -35,8 +34,6 @@ use function log;
use function spl_object_id;
final class RuntimeDataReader implements RuntimeDataDescriber{
use LegacyRuntimeEnumDescriberTrait;
private int $offset = 0;
public function __construct(
@ -59,18 +56,6 @@ final class RuntimeDataReader implements RuntimeDataDescriber{
$value = $this->readInt($bits);
}
/**
* @deprecated Use {@link self::boundedIntAuto()} instead.
*/
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
$offset = $this->offset;
$this->boundedIntAuto($min, $max, $value);
$actualBits = $this->offset - $offset;
if($this->offset !== $offset + $bits){
throw new \InvalidArgumentException("Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
}
}
private function readBoundedIntAuto(int $min, int $max) : int{
$bits = ((int) log($max - $min, 2)) + 1;
$result = $this->readInt($bits) + $min;
@ -192,16 +177,6 @@ final class RuntimeDataReader implements RuntimeDataDescriber{
$connections = $result;
}
/**
* @param BrewingStandSlot[] $slots
* @phpstan-param array<int, BrewingStandSlot> $slots
*
* @deprecated Use {@link enumSet()} instead.
*/
public function brewingStandSlots(array &$slots) : void{
$this->enumSet($slots, BrewingStandSlot::cases());
}
public function railShape(int &$railShape) : void{
$result = $this->readInt(4);
if(!isset(RailConnectionInfo::CONNECTIONS[$result]) && !isset(RailConnectionInfo::CURVE_CONNECTIONS[$result])){

View File

@ -23,14 +23,11 @@ declare(strict_types=1);
namespace pocketmine\data\runtime;
use pocketmine\block\utils\BrewingStandSlot;
use pocketmine\math\Facing;
use function count;
use function log;
final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
use LegacyRuntimeEnumDescriberTrait;
private int $bits = 0;
protected function addBits(int $bits) : void{
@ -45,18 +42,6 @@ final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
$this->addBits($bits);
}
/**
* @deprecated Use {@link self::boundedIntAuto()} instead.
*/
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
$currentBits = $this->bits;
$this->boundedIntAuto($min, $max, $value);
$actualBits = $this->bits - $currentBits;
if($actualBits !== $bits){
throw new \InvalidArgumentException("Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
}
}
public function boundedIntAuto(int $min, int $max, int &$value) : void{
$this->addBits(((int) log($max - $min, 2)) + 1);
}
@ -97,10 +82,6 @@ final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
$this->addBits(7);
}
public function brewingStandSlots(array &$slots) : void{
$this->addBits(count(BrewingStandSlot::cases()));
}
public function railShape(int &$railShape) : void{
$this->addBits(4);
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\data\runtime;
use pocketmine\block\utils\BrewingStandSlot;
use pocketmine\block\utils\WallConnectionType;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -32,8 +31,6 @@ use function log;
use function spl_object_id;
final class RuntimeDataWriter implements RuntimeDataDescriber{
use LegacyRuntimeEnumDescriberTrait;
private int $value = 0;
private int $offset = 0;
@ -57,18 +54,6 @@ final class RuntimeDataWriter implements RuntimeDataDescriber{
$this->writeInt($bits, $value);
}
/**
* @deprecated Use {@link self::boundedIntAuto()} instead.
*/
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
$offset = $this->offset;
$this->writeBoundedIntAuto($min, $max, $value);
$actualBits = $this->offset - $offset;
if($actualBits !== $bits){
throw new \InvalidArgumentException("Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
}
}
private function writeBoundedIntAuto(int $min, int $max, int $value) : void{
if($value < $min || $value > $max){
throw new \InvalidArgumentException("Value $value is outside the range $min - $max");
@ -170,16 +155,6 @@ final class RuntimeDataWriter implements RuntimeDataDescriber{
$this->writeBoundedIntAuto(0, (3 ** 4) - 1, $packed);
}
/**
* @param BrewingStandSlot[] $slots
* @phpstan-param array<int, BrewingStandSlot> $slots
*
* @deprecated Use {@link enumSet()} instead.
*/
public function brewingStandSlots(array &$slots) : void{
$this->enumSet($slots, BrewingStandSlot::cases());
}
public function railShape(int &$railShape) : void{
$this->int(4, $railShape);
}

View File

@ -1,61 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\runtime;
/**
* Provides backwards-compatible shims for the old codegen'd enum describer methods.
* This is kept for plugin backwards compatibility, but these functions should not be used in new code.
* @deprecated
*/
interface RuntimeEnumDescriber{
public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType &$value) : void;
public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void;
public function coralType(\pocketmine\block\utils\CoralType &$value) : void;
public function dirtType(\pocketmine\block\utils\DirtType &$value) : void;
public function dripleafState(\pocketmine\block\utils\DripleafState &$value) : void;
public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void;
public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void;
public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void;
public function medicineType(\pocketmine\item\MedicineType &$value) : void;
public function mobHeadType(\pocketmine\block\utils\MobHeadType &$value) : void;
public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void;
public function potionType(\pocketmine\item\PotionType &$value) : void;
public function slabType(\pocketmine\block\utils\SlabType &$value) : void;
public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void;
}

View File

@ -1485,7 +1485,7 @@ abstract class Entity{
return $this->hasSpawned;
}
abstract public static function getNetworkTypeId() : string;
abstract public function getNetworkTypeId() : string;
/**
* Called by spawnTo() to send whatever packets needed to spawn the entity to the client.
@ -1494,7 +1494,7 @@ abstract class Entity{
$player->getNetworkSession()->sendDataPacket(AddActorPacket::create(
$this->getId(), //TODO: actor unique ID
$this->getId(),
static::getNetworkTypeId(),
$this->getNetworkTypeId(),
$this->getOffsetPosition($this->location->asVector3()),
$this->getMotion(),
$this->location->pitch,

View File

@ -99,7 +99,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
private const TAG_SKIN_GEOMETRY_NAME = "GeometryName"; //TAG_String
private const TAG_SKIN_GEOMETRY_DATA = "GeometryData"; //TAG_ByteArray
public static function getNetworkTypeId() : string{ return EntityIds::PLAYER; }
public function getNetworkTypeId() : string{ return EntityIds::PLAYER; }
protected PlayerInventory $inventory;
protected PlayerOffHandInventory $offHandInventory;

View File

@ -38,7 +38,7 @@ use const M_PI;
class Squid extends WaterAnimal{
public static function getNetworkTypeId() : string{ return EntityIds::SQUID; }
public function getNetworkTypeId() : string{ return EntityIds::SQUID; }
public ?Vector3 $swimDirection = null;
public float $swimSpeed = 0.1;

View File

@ -40,7 +40,7 @@ class Villager extends Living implements Ageable{
private const TAG_PROFESSION = "Profession"; //TAG_Int
public static function getNetworkTypeId() : string{ return EntityIds::VILLAGER; }
public function getNetworkTypeId() : string{ return EntityIds::VILLAGER; }
private bool $baby = false;
private int $profession = self::PROFESSION_FARMER;

View File

@ -30,7 +30,7 @@ use function mt_rand;
class Zombie extends Living{
public static function getNetworkTypeId() : string{ return EntityIds::ZOMBIE; }
public function getNetworkTypeId() : string{ return EntityIds::ZOMBIE; }
protected function getInitialSizeInfo() : EntitySizeInfo{
return new EntitySizeInfo(1.8, 0.6); //TODO: eye height ??

View File

@ -47,7 +47,7 @@ class EndCrystal extends Entity implements Explosive{
private const TAG_BLOCKTARGET_Y = "BlockTargetY"; //TAG_Int
private const TAG_BLOCKTARGET_Z = "BlockTargetZ"; //TAG_Int
public static function getNetworkTypeId() : string{ return EntityIds::ENDER_CRYSTAL; }
public function getNetworkTypeId() : string{ return EntityIds::ENDER_CRYSTAL; }
protected bool $showBase = false;
protected ?Vector3 $beamTarget = null;

View File

@ -37,7 +37,7 @@ use function sqrt;
class ExperienceOrb extends Entity{
public static function getNetworkTypeId() : string{ return EntityIds::XP_ORB; }
public function getNetworkTypeId() : string{ return EntityIds::XP_ORB; }
public const TAG_VALUE_PC = "Value"; //short
public const TAG_VALUE_PE = "experience value"; //int (WTF?)

View File

@ -56,7 +56,7 @@ class FallingBlock extends Entity{
private const TAG_TILE = "Tile"; //TAG_Byte
private const TAG_DATA = "Data"; //TAG_Byte
public static function getNetworkTypeId() : string{ return EntityIds::FALLING_BLOCK; }
public function getNetworkTypeId() : string{ return EntityIds::FALLING_BLOCK; }
protected Block $block;

View File

@ -52,7 +52,7 @@ class ItemEntity extends Entity{
private const TAG_THROWER = "Thrower"; //TAG_String
public const TAG_ITEM = "Item"; //TAG_Compound
public static function getNetworkTypeId() : string{ return EntityIds::ITEM; }
public function getNetworkTypeId() : string{ return EntityIds::ITEM; }
public const MERGE_CHECK_PERIOD = 2; //0.1 seconds
public const DEFAULT_DESPAWN_DELAY = 6000; //5 minutes

View File

@ -49,7 +49,7 @@ class Painting extends Entity{
public const TAG_DIRECTION_BE = "Direction"; //TAG_Byte
public const TAG_MOTIVE = "Motive"; //TAG_String
public static function getNetworkTypeId() : string{ return EntityIds::PAINTING; }
public function getNetworkTypeId() : string{ return EntityIds::PAINTING; }
public const DATA_TO_FACING = [
0 => Facing::SOUTH,

View File

@ -43,7 +43,7 @@ class PrimedTNT extends Entity implements Explosive{
private const TAG_FUSE = "Fuse"; //TAG_Short
public static function getNetworkTypeId() : string{ return EntityIds::TNT; }
public function getNetworkTypeId() : string{ return EntityIds::TNT; }
protected int $fuse;
protected bool $worksUnderwater = false;

View File

@ -46,7 +46,7 @@ use function sqrt;
class Arrow extends Projectile{
public static function getNetworkTypeId() : string{ return EntityIds::ARROW; }
public function getNetworkTypeId() : string{ return EntityIds::ARROW; }
public const PICKUP_NONE = 0;
public const PICKUP_ANY = 1;

View File

@ -29,7 +29,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
use pocketmine\world\particle\ItemBreakParticle;
class Egg extends Throwable{
public static function getNetworkTypeId() : string{ return EntityIds::EGG; }
public function getNetworkTypeId() : string{ return EntityIds::EGG; }
//TODO: spawn chickens on collision

View File

@ -30,7 +30,7 @@ use pocketmine\world\particle\EndermanTeleportParticle;
use pocketmine\world\sound\EndermanTeleportSound;
class EnderPearl extends Throwable{
public static function getNetworkTypeId() : string{ return EntityIds::ENDER_PEARL; }
public function getNetworkTypeId() : string{ return EntityIds::ENDER_PEARL; }
protected function onHit(ProjectileHitEvent $event) : void{
$owner = $this->getOwningEntity();

View File

@ -30,7 +30,7 @@ use pocketmine\world\sound\PotionSplashSound;
use function mt_rand;
class ExperienceBottle extends Throwable{
public static function getNetworkTypeId() : string{ return EntityIds::XP_BOTTLE; }
public function getNetworkTypeId() : string{ return EntityIds::XP_BOTTLE; }
protected function getInitialGravity() : float{ return 0.07; }

View File

@ -36,7 +36,7 @@ use pocketmine\world\particle\ItemBreakParticle;
use pocketmine\world\sound\IceBombHitSound;
class IceBomb extends Throwable{
public static function getNetworkTypeId() : string{ return EntityIds::ICE_BOMB; }
public function getNetworkTypeId() : string{ return EntityIds::ICE_BOMB; }
public function getResultDamage() : int{
return -1;

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
use pocketmine\world\particle\SnowballPoofParticle;
class Snowball extends Throwable{
public static function getNetworkTypeId() : string{ return EntityIds::SNOWBALL; }
public function getNetworkTypeId() : string{ return EntityIds::SNOWBALL; }
protected function onHit(ProjectileHitEvent $event) : void{
$world = $this->getWorld();

View File

@ -52,7 +52,7 @@ class SplashPotion extends Throwable{
public const TAG_POTION_ID = "PotionId"; //TAG_Short
public static function getNetworkTypeId() : string{ return EntityIds::SPLASH_POTION; }
public function getNetworkTypeId() : string{ return EntityIds::SPLASH_POTION; }
protected bool $linger = false;
protected PotionType $potionType;

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\event\block;
use pocketmine\block\Block;
use pocketmine\block\utils\Waterloggable;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\event\Event;

View File

@ -110,7 +110,6 @@ class InventoryTransaction{
public function addAction(InventoryAction $action) : void{
if(!isset($this->actions[$hash = spl_object_id($action)])){
$this->actions[$hash] = $action;
$action->onAddToTransaction($this);
if($action instanceof SlotChangeAction && !isset($this->inventories[$inventoryId = spl_object_id($action->getInventory())])){
$this->inventories[$inventoryId] = $action->getInventory();
}

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\inventory\transaction\action;
use pocketmine\inventory\transaction\InventoryTransaction;
use pocketmine\inventory\transaction\TransactionValidationException;
use pocketmine\item\Item;
use pocketmine\player\Player;
@ -58,14 +57,6 @@ abstract class InventoryAction{
*/
abstract public function validate(Player $source) : void;
/**
* Called when the action is added to the specified InventoryTransaction.
* @deprecated
*/
public function onAddToTransaction(InventoryTransaction $transaction) : void{
}
/**
* Called by inventory transactions before any actions are processed. If this returns false, the transaction will
* be cancelled.

View File

@ -24,23 +24,8 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\utils\WoodType;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BoatType ACACIA()
* @method static BoatType BIRCH()
* @method static BoatType DARK_OAK()
* @method static BoatType JUNGLE()
* @method static BoatType MANGROVE()
* @method static BoatType OAK()
* @method static BoatType SPRUCE()
*/
enum BoatType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -26,10 +26,12 @@ namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\Liquid;
use pocketmine\block\utils\Waterloggable;
use pocketmine\block\VanillaBlocks;
use pocketmine\event\player\PlayerBucketFillEvent;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use function var_dump;
class Bucket extends Item{
@ -39,11 +41,15 @@ class Bucket extends Item{
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{
//TODO: move this to generic placement logic
if($blockClicked instanceof Liquid && $blockClicked->isSource()){
if($blockClicked instanceof Liquid && $blockClicked->isSource() || $blockClicked instanceof Waterloggable && $blockClicked->getWaterState() !== null){
$stack = clone $this;
$stack->pop();
$resultItem = match($blockClicked->getTypeId()){
$id = $blockClicked->getTypeId();
if($blockClicked instanceof Waterloggable){
$id = $blockClicked->getWaterState()->getTypeId();
}
$resultItem = match($id){
BlockTypeIds::LAVA => VanillaItems::LAVA_BUCKET(),
BlockTypeIds::WATER => VanillaItems::WATER_BUCKET(),
default => null
@ -55,8 +61,16 @@ class Bucket extends Item{
$ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem);
$ev->call();
if(!$ev->isCancelled()){
$player->getWorld()->setBlock($blockClicked->getPosition(), VanillaBlocks::AIR());
$player->getWorld()->addSound($blockClicked->getPosition()->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound());
if($blockClicked instanceof Waterloggable){
var_dump("Setting water state", $blockClicked->__toString());
$sound = $blockClicked->getWaterState()->getBucketFillSound();
$blockClicked->setWaterState(null);
$player->getWorld()->setBlock($blockClicked->getPosition(), $blockClicked);
}else{
$sound = $blockClicked->getBucketFillSound();
$player->getWorld()->setBlock($blockClicked->getPosition(), VanillaBlocks::AIR());
}
$player->getWorld()->addSound($blockClicked->getPosition()->add(0.5, 0.5, 0.5), $sound);
$this->pop();
$returnedItems[] = $ev->getItem();

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static ItemUseResult FAIL()
* @method static ItemUseResult NONE()
* @method static ItemUseResult SUCCESS()
*/
enum ItemUseResult{
use LegacyEnumShimTrait;
case NONE;
case FAIL;
case SUCCESS;

View File

@ -26,9 +26,12 @@ namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\Lava;
use pocketmine\block\Liquid;
use pocketmine\block\utils\Waterloggable;
use pocketmine\block\Water;
use pocketmine\event\player\PlayerBucketEmptyEvent;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use function var_dump;
class LiquidBucket extends Item{
private Liquid $liquid;
@ -55,7 +58,7 @@ class LiquidBucket extends Item{
}
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{
if(!$blockReplace->canBeReplaced()){
if(!$blockReplace->canBeReplaced() && !($blockReplace instanceof Waterloggable)){
return ItemUseResult::NONE;
}
@ -65,7 +68,14 @@ class LiquidBucket extends Item{
$ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, VanillaItems::BUCKET());
$ev->call();
if(!$ev->isCancelled()){
$player->getWorld()->setBlock($blockReplace->getPosition(), $resultBlock->getFlowingForm());
if($blockClicked instanceof Waterloggable && $resultBlock instanceof Water){
var_dump("Setting water state", $resultBlock->__toString());
$blockClicked->setWaterState($resultBlock);
$player->getWorld()->setBlock($blockClicked->getPosition(), $blockClicked);
$blockClicked->onNearbyBlockChange();
}else{
$player->getWorld()->setBlock($blockReplace->getPosition(), $resultBlock->getFlowingForm());
}
$player->getWorld()->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
$this->pop();

View File

@ -25,20 +25,8 @@ namespace pocketmine\item;
use pocketmine\entity\effect\Effect;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static MedicineType ANTIDOTE()
* @method static MedicineType ELIXIR()
* @method static MedicineType EYE_DROPS()
* @method static MedicineType TONIC()
*/
enum MedicineType{
use LegacyEnumShimTrait;
case ANTIDOTE;
case ELIXIR;
case EYE_DROPS;

View File

@ -25,62 +25,12 @@ namespace pocketmine\item;
use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static PotionType AWKWARD()
* @method static PotionType FIRE_RESISTANCE()
* @method static PotionType HARMING()
* @method static PotionType HEALING()
* @method static PotionType INVISIBILITY()
* @method static PotionType LEAPING()
* @method static PotionType LONG_FIRE_RESISTANCE()
* @method static PotionType LONG_INVISIBILITY()
* @method static PotionType LONG_LEAPING()
* @method static PotionType LONG_MUNDANE()
* @method static PotionType LONG_NIGHT_VISION()
* @method static PotionType LONG_POISON()
* @method static PotionType LONG_REGENERATION()
* @method static PotionType LONG_SLOWNESS()
* @method static PotionType LONG_SLOW_FALLING()
* @method static PotionType LONG_STRENGTH()
* @method static PotionType LONG_SWIFTNESS()
* @method static PotionType LONG_TURTLE_MASTER()
* @method static PotionType LONG_WATER_BREATHING()
* @method static PotionType LONG_WEAKNESS()
* @method static PotionType MUNDANE()
* @method static PotionType NIGHT_VISION()
* @method static PotionType POISON()
* @method static PotionType REGENERATION()
* @method static PotionType SLOWNESS()
* @method static PotionType SLOW_FALLING()
* @method static PotionType STRENGTH()
* @method static PotionType STRONG_HARMING()
* @method static PotionType STRONG_HEALING()
* @method static PotionType STRONG_LEAPING()
* @method static PotionType STRONG_POISON()
* @method static PotionType STRONG_REGENERATION()
* @method static PotionType STRONG_SLOWNESS()
* @method static PotionType STRONG_STRENGTH()
* @method static PotionType STRONG_SWIFTNESS()
* @method static PotionType STRONG_TURTLE_MASTER()
* @method static PotionType SWIFTNESS()
* @method static PotionType THICK()
* @method static PotionType TURTLE_MASTER()
* @method static PotionType WATER()
* @method static PotionType WATER_BREATHING()
* @method static PotionType WEAKNESS()
* @method static PotionType WITHER()
*
* @phpstan-type TMetadata array{0: string, 1: \Closure() : list<EffectInstance>}
*/
enum PotionType{
use LegacyEnumShimTrait;
case WATER;
case MUNDANE;
case LONG_MUNDANE;

View File

@ -25,26 +25,8 @@ namespace pocketmine\item;
use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SuspiciousStewType ALLIUM()
* @method static SuspiciousStewType AZURE_BLUET()
* @method static SuspiciousStewType BLUE_ORCHID()
* @method static SuspiciousStewType CORNFLOWER()
* @method static SuspiciousStewType DANDELION()
* @method static SuspiciousStewType LILY_OF_THE_VALLEY()
* @method static SuspiciousStewType OXEYE_DAISY()
* @method static SuspiciousStewType POPPY()
* @method static SuspiciousStewType TULIP()
* @method static SuspiciousStewType WITHER_ROSE()
*/
enum SuspiciousStewType{
use LegacyEnumShimTrait;
case POPPY;
case CORNFLOWER;
case TULIP;

View File

@ -23,24 +23,10 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static ToolTier DIAMOND()
* @method static ToolTier GOLD()
* @method static ToolTier IRON()
* @method static ToolTier NETHERITE()
* @method static ToolTier STONE()
* @method static ToolTier WOOD()
*
* @phpstan-type TMetadata array{0: int, 1: int, 2: int, 3: int, 4: int}
*/
enum ToolTier{
use LegacyEnumShimTrait;
case WOOD;
case GOLD;
case STONE;

View File

@ -44,15 +44,11 @@ class Enchantment{
/**
* @phpstan-param null|(\Closure(int $level) : int) $minEnchantingPower
*
* @param int $primaryItemFlags @deprecated
* @param int $secondaryItemFlags @deprecated
* @param int $enchantingPowerRange Value used to calculate the maximum enchanting power (minEnchantingPower + enchantingPowerRange)
*/
public function __construct(
private Translatable|string $name,
private int $rarity,
private int $primaryItemFlags,
private int $secondaryItemFlags,
private int $maxLevel,
?\Closure $minEnchantingPower = null,
private int $enchantingPowerRange = 50
@ -79,47 +75,6 @@ class Enchantment{
return $this->rarity;
}
/**
* Returns a bitset indicating what item types can have this item applied from an enchanting table.
*
* @deprecated
* @see AvailableEnchantmentRegistry::getPrimaryItemTags()
*/
public function getPrimaryItemFlags() : int{
return $this->primaryItemFlags;
}
/**
* Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from
* an anvil.
*
* @deprecated
* @see AvailableEnchantmentRegistry::getSecondaryItemTags()
*/
public function getSecondaryItemFlags() : int{
return $this->secondaryItemFlags;
}
/**
* Returns whether this enchantment can apply to the item type from an enchanting table.
*
* @deprecated
* @see AvailableEnchantmentRegistry
*/
public function hasPrimaryItemType(int $flag) : bool{
return ($this->primaryItemFlags & $flag) !== 0;
}
/**
* Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.
*
* @deprecated
* @see AvailableEnchantmentRegistry
*/
public function hasSecondaryItemType(int $flag) : bool{
return ($this->secondaryItemFlags & $flag) !== 0;
}
/**
* Returns the maximum level of this enchantment that can be found on an enchantment table.
*/

View File

@ -1,54 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item\enchantment;
/** @deprecated */
final class ItemFlags{
private function __construct(){
//NOOP
}
public const NONE = 0x0;
public const ALL = 0xffff;
public const ARMOR = self::HEAD | self::TORSO | self::LEGS | self::FEET;
public const HEAD = 0x1;
public const TORSO = 0x2;
public const LEGS = 0x4;
public const FEET = 0x8;
public const SWORD = 0x10;
public const BOW = 0x20;
public const TOOL = self::HOE | self::SHEARS | self::FLINT_AND_STEEL;
public const HOE = 0x40;
public const SHEARS = 0x80;
public const FLINT_AND_STEEL = 0x100;
public const DIG = self::AXE | self::PICKAXE | self::SHOVEL;
public const AXE = 0x200;
public const PICKAXE = 0x400;
public const SHOVEL = 0x800;
public const FISHING_ROD = 0x1000;
public const CARROT_STICK = 0x2000;
public const ELYTRA = 0x4000;
public const TRIDENT = 0x8000;
}

View File

@ -42,13 +42,11 @@ class ProtectionEnchantment extends Enchantment{
* @phpstan-param null|(\Closure(int $level) : int) $minEnchantingPower
* @phpstan-param list<int>|null $applicableDamageTypes
*
* @param int $primaryItemFlags @deprecated
* @param int $secondaryItemFlags @deprecated
* @param int[]|null $applicableDamageTypes EntityDamageEvent::CAUSE_* constants which this enchantment type applies to, or null if it applies to all types of damage.
* @param int $enchantingPowerRange Value used to calculate the maximum enchanting power (minEnchantingPower + enchantingPowerRange)
*/
public function __construct(Translatable|string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes, ?\Closure $minEnchantingPower = null, int $enchantingPowerRange = 50){
parent::__construct($name, $rarity, $primaryItemFlags, $secondaryItemFlags, $maxLevel, $minEnchantingPower, $enchantingPowerRange);
public function __construct(Translatable|string $name, int $rarity, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes, ?\Closure $minEnchantingPower = null, int $enchantingPowerRange = 50){
parent::__construct($name, $rarity, $maxLevel, $minEnchantingPower, $enchantingPowerRange);
$this->typeModifier = $typeModifier;
if($applicableDamageTypes !== null){

View File

@ -64,8 +64,6 @@ final class VanillaEnchantments{
self::register("PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_all(),
Rarity::COMMON,
0,
0,
4,
0.75,
null,
@ -75,8 +73,6 @@ final class VanillaEnchantments{
self::register("FIRE_PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_fire(),
Rarity::UNCOMMON,
0,
0,
4,
1.25,
[
@ -91,8 +87,6 @@ final class VanillaEnchantments{
self::register("FEATHER_FALLING", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_fall(),
Rarity::UNCOMMON,
0,
0,
4,
2.5,
[
@ -104,8 +98,6 @@ final class VanillaEnchantments{
self::register("BLAST_PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_explosion(),
Rarity::RARE,
0,
0,
4,
1.5,
[
@ -118,8 +110,6 @@ final class VanillaEnchantments{
self::register("PROJECTILE_PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_projectile(),
Rarity::UNCOMMON,
0,
0,
4,
1.5,
[
@ -131,8 +121,6 @@ final class VanillaEnchantments{
self::register("THORNS", new Enchantment(
KnownTranslationFactory::enchantment_thorns(),
Rarity::MYTHIC,
0,
0,
3,
fn(int $level) : int => 20 * ($level - 1) + 10,
50
@ -140,8 +128,6 @@ final class VanillaEnchantments{
self::register("RESPIRATION", new Enchantment(
KnownTranslationFactory::enchantment_oxygen(),
Rarity::RARE,
0,
0,
3,
fn(int $level) : int => 10 * $level,
30
@ -150,8 +136,6 @@ final class VanillaEnchantments{
self::register("FROST_WALKER", new Enchantment(
KnownTranslationFactory::enchantment_frostwalker(),
Rarity::RARE,
0,
0,
2,
fn(int $level) : int => 10 * $level,
15
@ -159,8 +143,6 @@ final class VanillaEnchantments{
self::register("AQUA_AFFINITY", new Enchantment(
KnownTranslationFactory::enchantment_waterWorker(),
Rarity::RARE,
0,
0,
1,
null,
40
@ -169,8 +151,6 @@ final class VanillaEnchantments{
self::register("SHARPNESS", new SharpnessEnchantment(
KnownTranslationFactory::enchantment_damage_all(),
Rarity::COMMON,
0,
0,
5,
fn(int $level) : int => 11 * ($level - 1) + 1,
20
@ -178,8 +158,6 @@ final class VanillaEnchantments{
self::register("KNOCKBACK", new KnockbackEnchantment(
KnownTranslationFactory::enchantment_knockback(),
Rarity::UNCOMMON,
0,
0,
2,
fn(int $level) : int => 20 * ($level - 1) + 5,
50
@ -187,8 +165,6 @@ final class VanillaEnchantments{
self::register("FIRE_ASPECT", new FireAspectEnchantment(
KnownTranslationFactory::enchantment_fire(),
Rarity::RARE,
0,
0,
2,
fn(int $level) : int => 20 * ($level - 1) + 10,
50
@ -198,8 +174,6 @@ final class VanillaEnchantments{
self::register("EFFICIENCY", new Enchantment(
KnownTranslationFactory::enchantment_digging(),
Rarity::COMMON,
0,
0,
5,
fn(int $level) : int => 10 * ($level - 1) + 1,
50
@ -207,8 +181,6 @@ final class VanillaEnchantments{
self::register("FORTUNE", new Enchantment(
KnownTranslationFactory::enchantment_lootBonusDigger(),
Rarity::RARE,
0,
0,
3,
fn(int $level) : int => 9 * ($level - 1) + 15,
50
@ -216,8 +188,6 @@ final class VanillaEnchantments{
self::register("SILK_TOUCH", new Enchantment(
KnownTranslationFactory::enchantment_untouching(),
Rarity::MYTHIC,
0,
0,
1,
fn(int $level) : int => 15,
50
@ -225,8 +195,6 @@ final class VanillaEnchantments{
self::register("UNBREAKING", new Enchantment(
KnownTranslationFactory::enchantment_durability(),
Rarity::UNCOMMON,
0,
0,
3,
fn(int $level) : int => 8 * ($level - 1) + 5,
50
@ -235,8 +203,6 @@ final class VanillaEnchantments{
self::register("POWER", new Enchantment(
KnownTranslationFactory::enchantment_arrowDamage(),
Rarity::COMMON,
0,
0,
5,
fn(int $level) : int => 10 * ($level - 1) + 1,
15
@ -244,8 +210,6 @@ final class VanillaEnchantments{
self::register("PUNCH", new Enchantment(
KnownTranslationFactory::enchantment_arrowKnockback(),
Rarity::RARE,
0,
0,
2,
fn(int $level) : int => 20 * ($level - 1) + 12,
25
@ -253,8 +217,6 @@ final class VanillaEnchantments{
self::register("FLAME", new Enchantment(
KnownTranslationFactory::enchantment_arrowFire(),
Rarity::RARE,
0,
0,
1,
fn(int $level) : int => 20,
30
@ -262,8 +224,6 @@ final class VanillaEnchantments{
self::register("INFINITY", new Enchantment(
KnownTranslationFactory::enchantment_arrowInfinite(),
Rarity::MYTHIC,
0,
0,
1,
fn(int $level) : int => 20,
30
@ -272,8 +232,6 @@ final class VanillaEnchantments{
self::register("MENDING", new Enchantment(
KnownTranslationFactory::enchantment_mending(),
Rarity::RARE,
0,
0,
1,
fn(int $level) : int => 25,
50
@ -282,8 +240,6 @@ final class VanillaEnchantments{
self::register("VANISHING", new Enchantment(
KnownTranslationFactory::enchantment_curse_vanishing(),
Rarity::MYTHIC,
0,
0,
1,
fn(int $level) : int => 25,
25
@ -292,8 +248,6 @@ final class VanillaEnchantments{
self::register("SWIFT_SNEAK", new Enchantment(
KnownTranslationFactory::enchantment_swift_sneak(),
Rarity::MYTHIC,
0,
0,
3,
fn(int $level) : int => 10 * $level,
5

View File

@ -25,24 +25,13 @@ namespace pocketmine\player;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\lang\Translatable;
use pocketmine\utils\LegacyEnumShimTrait;
use function mb_strtolower;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static GameMode ADVENTURE()
* @method static GameMode CREATIVE()
* @method static GameMode SPECTATOR()
* @method static GameMode SURVIVAL()
*
* @phpstan-type TMetadata array{0: string, 1: Translatable, 2: list<string>}
*/
enum GameMode{
use LegacyEnumShimTrait;
case SURVIVAL;
case CREATIVE;
case ADVENTURE;

View File

@ -23,13 +23,15 @@ declare(strict_types=1);
namespace pocketmine\player;
use DateTimeImmutable;
interface IPlayer{
public function getName() : string;
public function getFirstPlayed() : ?int;
public function getFirstPlayed() : ?DateTimeImmutable;
public function getLastPlayed() : ?int;
public function getLastPlayed() : ?DateTimeImmutable;
public function hasPlayedBefore() : bool;

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\player;
use DateTimeImmutable;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\LongTag;
@ -36,12 +37,12 @@ class OfflinePlayer implements IPlayer{
return $this->name;
}
public function getFirstPlayed() : ?int{
return ($this->namedtag !== null && ($firstPlayedTag = $this->namedtag->getTag(Player::TAG_FIRST_PLAYED)) instanceof LongTag) ? $firstPlayedTag->getValue() : null;
public function getFirstPlayed() : ?DateTimeImmutable{
return ($this->namedtag !== null && ($firstPlayedTag = $this->namedtag->getTag(Player::TAG_FIRST_PLAYED)) instanceof LongTag) ? new DateTimeImmutable('@' . $firstPlayedTag->getValue() / 1000) : null;
}
public function getLastPlayed() : ?int{
return ($this->namedtag !== null && ($lastPlayedTag = $this->namedtag->getTag(Player::TAG_LAST_PLAYED)) instanceof LongTag) ? $lastPlayedTag->getValue() : null;
public function getLastPlayed() : ?DateTimeImmutable{
return ($this->namedtag !== null && ($lastPlayedTag = $this->namedtag->getTag(Player::TAG_LAST_PLAYED)) instanceof LongTag) ? new DateTimeImmutable('@' . $lastPlayedTag->getValue() / 1000) : null;
}
public function hasPlayedBefore() : bool{

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\player;
use DateTimeImmutable;
use pocketmine\block\BaseSign;
use pocketmine\block\Bed;
use pocketmine\block\BlockTypeTags;
@ -232,8 +233,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
protected int $messageCounter = 2;
protected int $firstPlayed;
protected int $lastPlayed;
protected DateTimeImmutable $firstPlayed;
protected DateTimeImmutable $lastPlayed;
protected GameMode $gamemode;
/**
@ -383,8 +384,12 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
}
));
$this->firstPlayed = $nbt->getLong(self::TAG_FIRST_PLAYED, $now = (int) (microtime(true) * 1000));
$this->lastPlayed = $nbt->getLong(self::TAG_LAST_PLAYED, $now);
$now = (int) (microtime(true) * 1000);
$createDateTimeImmutable = static function(string $tag) use ($nbt, $now) : DateTimeImmutable{
return new DateTimeImmutable('@' . $nbt->getLong($tag, $now) / 1000);
};
$this->firstPlayed = $createDateTimeImmutable(self::TAG_FIRST_PLAYED);
$this->lastPlayed = $createDateTimeImmutable(self::TAG_LAST_PLAYED);
if(!$this->server->getForceGamemode() && ($gameModeTag = $nbt->getTag(self::TAG_GAME_MODE)) instanceof IntTag){
$this->internalSetGameMode(GameModeIdMap::getInstance()->fromId($gameModeTag->getValue()) ?? GameMode::SURVIVAL); //TODO: bad hack here to avoid crashes on corrupted data
@ -446,19 +451,19 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
/**
* TODO: not sure this should be nullable
*/
public function getFirstPlayed() : ?int{
public function getFirstPlayed() : ?DateTimeImmutable{
return $this->firstPlayed;
}
/**
* TODO: not sure this should be nullable
*/
public function getLastPlayed() : ?int{
public function getLastPlayed() : ?DateTimeImmutable{
return $this->lastPlayed;
}
public function hasPlayedBefore() : bool{
return $this->lastPlayed - $this->firstPlayed > 1; // microtime(true) - microtime(true) may have less than one millisecond difference
return ((int) $this->firstPlayed->diff($this->lastPlayed)->format('%s')) > 1;
}
/**
@ -2457,7 +2462,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
}
$nbt->setInt(self::TAG_GAME_MODE, GameModeIdMap::getInstance()->toId($this->gamemode));
$nbt->setLong(self::TAG_FIRST_PLAYED, $this->firstPlayed);
$nbt->setLong(self::TAG_FIRST_PLAYED, (int) $this->firstPlayed->format('Uv'));
$nbt->setLong(self::TAG_LAST_PLAYED, (int) floor(microtime(true) * 1000));
return $nbt;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\player;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static UsedChunkStatus NEEDED()
* @method static UsedChunkStatus REQUESTED_GENERATION()
* @method static UsedChunkStatus REQUESTED_SENDING()
* @method static UsedChunkStatus SENT()
*/
enum UsedChunkStatus{
use LegacyEnumShimTrait;
case NEEDED;
case REQUESTED_GENERATION;
case REQUESTED_SENDING;

View File

@ -1,85 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\plugin;
use pocketmine\utils\AssumptionFailedError;
use function file_exists;
use function fopen;
use function is_dir;
use function rtrim;
use function str_replace;
use function strlen;
use function substr;
use const DIRECTORY_SEPARATOR;
/**
* Provides resources from the given plugin directory on disk. The path may be prefixed with a specific access protocol
* to enable special types of access.
*
* @deprecated
*/
class DiskResourceProvider implements ResourceProvider{
private string $file;
public function __construct(string $path){
$this->file = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $path), "/") . "/";
}
/**
* Gets an embedded resource on the plugin file.
* WARNING: You must close the resource given using fclose()
*
* @return null|resource Resource data, or null
*/
public function getResource(string $filename){
$filename = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $filename), "/");
if(file_exists($this->file . $filename)){
$resource = fopen($this->file . $filename, "rb");
if($resource === false) throw new AssumptionFailedError("fopen() should not fail on a file which exists");
return $resource;
}
return null;
}
/**
* Returns all the resources packaged with the plugin in the form ["path/in/resources" => SplFileInfo]
*
* @return \SplFileInfo[]
*/
public function getResources() : array{
$resources = [];
if(is_dir($this->file)){
/** @var \SplFileInfo $resource */
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->file)) as $resource){
if($resource->isFile()){
$path = str_replace(DIRECTORY_SEPARATOR, "/", substr((string) $resource, strlen($this->file)));
$resources[$path] = $resource;
}
}
}
return $resources;
}
}

View File

@ -0,0 +1,72 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\plugin;
use pocketmine\thread\ThreadSafeClassLoader;
use pocketmine\utils\Filesystem;
use Symfony\Component\Filesystem\Path;
use function file_exists;
use function is_dir;
class FolderPluginLoader implements PluginLoader{
public function __construct(
private readonly ThreadSafeClassLoader $loader
){}
public function canLoadPlugin(string $path) : bool{
return is_dir($path) && file_exists(Path::join($path, "plugin.yml")) && file_exists(Path::join($path, "src"));
}
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $path) : void{
$description = $this->getPluginDescription($path);
if($description !== null){
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
}
}
/**
* Gets the PluginDescription from the file
*/
public function getPluginDescription(string $path) : ?PluginDescription{
$pluginYmlPath = Path::join($path, "plugin.yml");
if(is_dir($path) && file_exists($pluginYmlPath)){
try{
$yaml = Filesystem::fileGetContents($pluginYmlPath);
}catch(\RuntimeException){
//TODO: this ought to be logged
return null;
}
return new PluginDescription($yaml);
}
return null;
}
public function getAccessProtocol() : string{
return "";
}
}

View File

@ -42,18 +42,18 @@ class PharPluginLoader implements PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void{
$description = $this->getPluginDescription($file);
public function loadPlugin(string $path) : void{
$description = $this->getPluginDescription($path);
if($description !== null){
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
}
}
/**
* Gets the PluginDescription from the file
*/
public function getPluginDescription(string $file) : ?PluginDescription{
$phar = new \Phar($file);
public function getPluginDescription(string $path) : ?PluginDescription{
$phar = new \Phar($path);
if(isset($phar["plugin.yml"])){
return new PluginDescription($phar["plugin.yml"]->getContent());
}

View File

@ -34,7 +34,7 @@ use pocketmine\Server;
*/
interface Plugin{
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file, ResourceProvider $resourceProvider);
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file, string $resourceFolder);
public function isEnabled() : bool;

View File

@ -37,18 +37,21 @@ use function copy;
use function count;
use function dirname;
use function file_exists;
use function fopen;
use function is_dir;
use function mkdir;
use function rtrim;
use function str_contains;
use function str_replace;
use function strlen;
use function strtolower;
use function substr;
use function trim;
use const DIRECTORY_SEPARATOR;
abstract class PluginBase implements Plugin, CommandExecutor{
private bool $isEnabled = false;
private string $resourceFolder;
private ?Config $config = null;
private string $configFile;
@ -61,12 +64,12 @@ abstract class PluginBase implements Plugin, CommandExecutor{
private PluginDescription $description,
private string $dataFolder,
private string $file,
private ResourceProvider $resourceProvider
private string $resourceFolder,
){
$this->dataFolder = rtrim($dataFolder, "/" . DIRECTORY_SEPARATOR) . "/";
//TODO: this is accessed externally via reflection, not unused
$this->file = rtrim($file, "/" . DIRECTORY_SEPARATOR) . "/";
$this->resourceFolder = Path::join($this->file, "resources") . "/";
$this->resourceFolder = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $resourceFolder), "/") . "/";
$this->configFile = Path::join($this->dataFolder, "config.yml");
@ -227,19 +230,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
return Path::join($this->getResourceFolder(), $filename);
}
/**
* @deprecated Prefer using standard PHP functions with {@link PluginBase::getResourcePath()}, like
* file_get_contents() or fopen().
*
* Gets an embedded resource on the plugin file.
* WARNING: You must close the resource given using fclose()
*
* @return null|resource Resource data, or null
*/
public function getResource(string $filename){
return $this->resourceProvider->getResource($filename);
}
/**
* Saves an embedded resource to its relative location in the data folder
*/
@ -271,7 +261,18 @@ abstract class PluginBase implements Plugin, CommandExecutor{
* @return \SplFileInfo[]
*/
public function getResources() : array{
return $this->resourceProvider->getResources();
$resources = [];
if(is_dir($this->resourceFolder)){
/** @var \SplFileInfo $resource */
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resourceFolder)) as $resource){
if($resource->isFile()){
$path = str_replace(DIRECTORY_SEPARATOR, "/", substr((string) $resource, strlen($this->resourceFolder)));
$resources[$path] = $resource;
}
}
}
return $resources;
}
public function getConfig() : Config{

View File

@ -23,19 +23,9 @@ declare(strict_types=1);
namespace pocketmine\plugin;
use pocketmine\utils\LegacyEnumShimTrait;
use function mb_strtolower;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static PluginEnableOrder POSTWORLD()
* @method static PluginEnableOrder STARTUP()
*/
enum PluginEnableOrder{
use LegacyEnumShimTrait;
case STARTUP;
case POSTWORLD;

View File

@ -36,13 +36,13 @@ interface PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void;
public function loadPlugin(string $path) : void;
/**
* Gets the PluginDescription from the file
* @throws PluginDescriptionParseException
*/
public function getPluginDescription(string $file) : ?PluginDescription;
public function getPluginDescription(string $path) : ?PluginDescription;
/**
* Returns the protocol prefix used to access files in this plugin, e.g. file://, phar://

View File

@ -220,7 +220,7 @@ class PluginManager{
* @var Plugin $plugin
* @see Plugin::__construct()
*/
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed, new DiskResourceProvider($prefixed . "/resources/"));
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed, $prefixed . "/resources/");
$this->plugins[$plugin->getDescription()->getName()] = $plugin;
return $plugin;
@ -493,12 +493,10 @@ class PluginManager{
return true; //TODO: maybe this should be an error?
}
/** @internal */
public function disablePlugins() : void{
while(count($this->enabledPlugins) > 0){
foreach($this->enabledPlugins as $plugin){
if(!$plugin->isEnabled()){
continue; //in case a plugin disabled another plugin
}
$name = $plugin->getDescription()->getName();
if(isset($this->pluginDependents[$name]) && count($this->pluginDependents[$name]) > 0){
$this->server->getLogger()->debug("Deferring disable of plugin $name due to dependent plugins still enabled: " . implode(", ", array_keys($this->pluginDependents[$name])));
@ -510,7 +508,7 @@ class PluginManager{
}
}
public function disablePlugin(Plugin $plugin) : void{
private function disablePlugin(Plugin $plugin) : void{
if($plugin->isEnabled()){
$this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_disable($plugin->getDescription()->getFullName())));
(new PluginDisableEvent($plugin))->call();
@ -533,22 +531,11 @@ class PluginManager{
}
public function tickSchedulers(int $currentTick) : void{
foreach(Utils::promoteKeys($this->enabledPlugins) as $pluginName => $p){
if(isset($this->enabledPlugins[$pluginName])){
//the plugin may have been disabled as a result of updating other plugins' schedulers, and therefore
//removed from enabledPlugins; however, foreach will still see it due to copy-on-write
$p->getScheduler()->mainThreadHeartbeat($currentTick);
}
foreach($this->enabledPlugins as $p){
$p->getScheduler()->mainThreadHeartbeat($currentTick);
}
}
public function clearPlugins() : void{
$this->disablePlugins();
$this->plugins = [];
$this->enabledPlugins = [];
$this->fileAssociations = [];
}
/**
* Returns whether the given ReflectionMethod could be used as an event handler. Used to filter methods on Listeners
* when registering.

View File

@ -1,44 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\plugin;
/**
* @deprecated
*/
interface ResourceProvider{
/**
* Gets an embedded resource on the plugin file.
* WARNING: You must close the resource given using fclose()
*
* @return null|resource Resource data, or null
*/
public function getResource(string $filename);
/**
* Returns all the resources packaged with the plugin in the form ["path/in/resources" => SplFileInfo]
*
* @return \SplFileInfo[]
*/
public function getResources() : array;
}

View File

@ -46,15 +46,15 @@ class ScriptPluginLoader implements PluginLoader{
/**
* Loads the plugin contained in $file
*/
public function loadPlugin(string $file) : void{
include_once $file;
public function loadPlugin(string $path) : void{
include_once $path;
}
/**
* Gets the PluginDescription from the file
*/
public function getPluginDescription(string $file) : ?PluginDescription{
$content = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
public function getPluginDescription(string $path) : ?PluginDescription{
$content = @file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if($content === false){
return null;
}

View File

@ -266,22 +266,11 @@ class AsyncPool{
$this->checkCrashedWorker($worker, $task);
throw new AssumptionFailedError("checkCrashedWorker() should have thrown an exception, making this unreachable");
}else{
/*
* It's possible for a task to submit a progress update and then finish before the progress
* update is detected by the parent thread, so here we consume any missed updates.
*
* When this happens, it's possible for a progress update to arrive between the previous
* checkProgressUpdates() call and the next isGarbage() call, causing progress updates to be
* lost. Thus, it's necessary to do one last check here to make sure all progress updates have
* been consumed before completing.
*/
$this->checkTaskProgressUpdates($task);
Timings::getAsyncTaskCompletionTimings($task)->time(function() use ($task) : void{
$task->onCompletion();
});
}
}else{
$this->checkTaskProgressUpdates($task);
$more = true;
break; //current task is still running, skip to next worker
}
@ -329,10 +318,4 @@ class AsyncPool{
}
$this->workers = [];
}
private function checkTaskProgressUpdates(AsyncTask $task) : void{
Timings::getAsyncTaskProgressUpdateTimings($task)->time(function() use ($task) : void{
$task->checkProgressUpdates();
});
}
}

View File

@ -25,12 +25,9 @@ namespace pocketmine\scheduler;
use pmmp\thread\Runnable;
use pmmp\thread\ThreadSafe;
use pmmp\thread\ThreadSafeArray;
use pocketmine\thread\NonThreadSafeValue;
use pocketmine\timings\Timings;
use function array_key_exists;
use function igbinary_serialize;
use function igbinary_unserialize;
use function is_null;
use function is_scalar;
use function spl_object_id;
@ -68,12 +65,6 @@ abstract class AsyncTask extends Runnable{
*/
private static array $threadLocalStorage = [];
/**
* @phpstan-var ThreadSafeArray<int, string>|null
* @deprecated
*/
private ?ThreadSafeArray $progressUpdates = null;
private ThreadSafe|string|int|bool|null|float $result = null;
private bool $submitted = false;
@ -96,13 +87,6 @@ abstract class AsyncTask extends Runnable{
AsyncWorker::maybeCollectCycles();
}
/**
* @deprecated
*/
public function isCrashed() : bool{
return $this->isTerminated();
}
/**
* Returns whether this task has finished executing, whether successfully or not. This differs from isRunning()
* because it is not true prior to task execution.
@ -129,20 +113,6 @@ abstract class AsyncTask extends Runnable{
$this->result = is_scalar($result) || is_null($result) || $result instanceof ThreadSafe ? $result : new NonThreadSafeValue($result);
}
/**
* @deprecated
*/
public function cancelRun() : void{
//NOOP
}
/**
* @deprecated
*/
public function hasCancelledRun() : bool{
return false;
}
public function setSubmitted() : void{
$this->submitted = true;
}
@ -164,56 +134,6 @@ abstract class AsyncTask extends Runnable{
}
/**
* @deprecated
*
* Call this method from {@link AsyncTask::onRun} (AsyncTask execution thread) to schedule a call to
* {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
*
* @param mixed $progress A value that can be safely serialize()'ed.
*/
public function publishProgress(mixed $progress) : void{
$progressUpdates = $this->progressUpdates;
if($progressUpdates === null){
$progressUpdates = $this->progressUpdates = new ThreadSafeArray();
}
$progressUpdates[] = igbinary_serialize($progress) ?? throw new \InvalidArgumentException("Progress must be serializable");
}
/**
* @deprecated
* @internal Only call from AsyncPool.php on the main thread
*/
public function checkProgressUpdates() : void{
$progressUpdates = $this->progressUpdates;
if($progressUpdates !== null){
while(($progress = $progressUpdates->shift()) !== null){
$this->onProgressUpdate(igbinary_unserialize($progress));
}
}
}
/**
* @deprecated
*
* Called from the main thread after {@link AsyncTask::publishProgress} is called.
* All {@link AsyncTask::publishProgress} calls should result in {@link AsyncTask::onProgressUpdate} calls before
* {@link AsyncTask::onCompletion} is called.
*
* @param mixed $progress The parameter passed to {@link AsyncTask#publishProgress}. It is serialize()'ed
* and then unserialize()'ed, as if it has been cloned.
*/
public function onProgressUpdate($progress) : void{
}
/**
* @deprecated No longer used
*/
public function onError() : void{
}
/**
* Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it
* was stored on**. Data stored using this method will **not** be serialized.

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\scheduler;
use pmmp\thread\Thread as NativeThread;
use pocketmine\GarbageCollectorManager;
use pocketmine\snooze\SleeperHandlerEntry;
use pocketmine\snooze\SleeperNotifier;
@ -34,9 +33,6 @@ use pocketmine\utils\AssumptionFailedError;
use function ini_set;
class AsyncWorker extends Worker{
/** @var mixed[] */
private static array $store = [];
private static ?SleeperNotifier $notifier = null;
private static ?GarbageCollectorManager $cycleGcManager = null;
@ -88,46 +84,4 @@ class AsyncWorker extends Worker{
public function getAsyncWorkerId() : int{
return $this->id;
}
/**
* Saves mixed data into the worker's thread-local object store. This can be used to store objects which you
* want to use on this worker thread from multiple AsyncTasks.
*
* @deprecated Use static class properties instead.
*/
public function saveToThreadStore(string $identifier, mixed $value) : void{
if(NativeThread::getCurrentThread() !== $this){
throw new \LogicException("Thread-local data can only be stored in the thread context");
}
self::$store[$identifier] = $value;
}
/**
* Retrieves mixed data from the worker's thread-local object store.
*
* Note that the thread-local object store could be cleared and your data might not exist, so your code should
* account for the possibility that what you're trying to retrieve might not exist.
*
* Objects stored in this storage may ONLY be retrieved while the task is running.
*
* @deprecated Use static class properties instead.
*/
public function getFromThreadStore(string $identifier) : mixed{
if(NativeThread::getCurrentThread() !== $this){
throw new \LogicException("Thread-local data can only be fetched in the thread context");
}
return self::$store[$identifier] ?? null;
}
/**
* Removes previously-stored mixed data from the worker's thread-local object store.
*
* @deprecated Use static class properties instead.
*/
public function removeFromThreadStore(string $identifier) : void{
if(NativeThread::getCurrentThread() !== $this){
throw new \LogicException("Thread-local data can only be removed in the thread context");
}
unset(self::$store[$identifier]);
}
}

View File

@ -37,8 +37,6 @@ use function str_starts_with;
abstract class Timings{
public const GROUP_MINECRAFT = "Minecraft";
/** @deprecated No longer used */
public const GROUP_BREAKDOWN = "Minecraft - Breakdown";
private static bool $initialized = false;
@ -119,17 +117,9 @@ abstract class Timings{
/** @var TimingsHandler[][] */
private static array $eventHandlers = [];
private static TimingsHandler $asyncTaskProgressUpdateParent;
private static TimingsHandler $asyncTaskCompletionParent;
private static TimingsHandler $asyncTaskErrorParent;
/** @var TimingsHandler[] */
private static array $asyncTaskProgressUpdate = [];
/** @var TimingsHandler[] */
private static array $asyncTaskCompletion = [];
/** @var TimingsHandler[] */
private static array $asyncTaskError = [];
public static TimingsHandler $asyncTaskWorkers;
/** @var TimingsHandler[] */
@ -190,9 +180,7 @@ abstract class Timings{
self::$schedulerSync = new TimingsHandler("Scheduler - Sync Tasks");
self::$schedulerAsync = new TimingsHandler("Scheduler - Async Tasks");
self::$asyncTaskProgressUpdateParent = new TimingsHandler("Async Tasks - Progress Updates", self::$schedulerAsync);
self::$asyncTaskCompletionParent = new TimingsHandler("Async Tasks - Completion Handlers", self::$schedulerAsync);
self::$asyncTaskErrorParent = new TimingsHandler("Async Tasks - Error Handlers", self::$schedulerAsync);
self::$asyncTaskWorkers = new TimingsHandler("Async Task Workers");
@ -324,20 +312,6 @@ abstract class Timings{
return self::$eventHandlers[$event][$handlerName];
}
public static function getAsyncTaskProgressUpdateTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
$taskClass = $task::class;
if(!isset(self::$asyncTaskProgressUpdate[$taskClass])){
self::init();
self::$asyncTaskProgressUpdate[$taskClass] = new TimingsHandler(
"AsyncTask - " . self::shortenCoreClassName($taskClass, "pocketmine\\") . " - Progress Updates",
self::$asyncTaskProgressUpdateParent,
$group
);
}
return self::$asyncTaskProgressUpdate[$taskClass];
}
public static function getAsyncTaskCompletionTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
$taskClass = $task::class;
if(!isset(self::$asyncTaskCompletion[$taskClass])){
@ -352,23 +326,6 @@ abstract class Timings{
return self::$asyncTaskCompletion[$taskClass];
}
/**
* @deprecated No longer used
*/
public static function getAsyncTaskErrorTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
$taskClass = $task::class;
if(!isset(self::$asyncTaskError[$taskClass])){
self::init();
self::$asyncTaskError[$taskClass] = new TimingsHandler(
"AsyncTask - " . self::shortenCoreClassName($taskClass, "pocketmine\\") . " - Error Handler",
self::$asyncTaskErrorParent,
$group
);
}
return self::$asyncTaskError[$taskClass];
}
public static function getAsyncTaskRunTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
$taskClass = $task::class;
if(!isset(self::$asyncTaskRun[$taskClass])){

View File

@ -139,19 +139,6 @@ class TimingsHandler{
return $result;
}
/**
* @deprecated This only collects timings from the main thread. Collecting timings from all threads is an async
* operation, so it can't be done synchronously.
*
* @return string[]
*/
public static function printTimings() : array{
$records = self::printCurrentThreadRecords();
$footer = self::printFooter();
return [...$records, ...$footer];
}
/**
* Collects timings asynchronously, allowing timings from multiple threads to be aggregated into a single report.
*

View File

@ -1,109 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\utils;
/**
* This trait allows a class to simulate a Java-style enum. Members are exposed as static methods and handled via
* __callStatic().
*
* Classes using this trait need to include \@method tags in their class docblock for every enum member.
* Alternatively, just put \@generate-registry-docblock in the docblock and run build/generate-registry-annotations.php
*
* @deprecated Use native PHP 8.1 enums instead. Use {@link LegacyEnumShimTrait} if you need to provide backwards
* compatible EnumTrait-like API for migrated enums.
*/
trait EnumTrait{
use RegistryTrait;
use NotCloneable;
use NotSerializable;
/**
* Registers the given object as an enum member.
*
* @throws \InvalidArgumentException
*/
protected static function register(self $member) : void{
self::_registryRegister($member->name(), $member);
}
protected static function registerAll(self ...$members) : void{
foreach($members as $member){
self::register($member);
}
}
/**
* Returns all members of the enum.
* This is overridden to change the return typehint.
*
* @return self[]
* @phpstan-return array<string, self>
*/
public static function getAll() : array{
//phpstan doesn't support generic traits yet :(
/** @var self[] $result */
$result = self::_registryGetAll();
return $result;
}
/** @var int|null */
private static $nextId = null;
/** @var string */
private $enumName;
/** @var int */
private $runtimeId;
/**
* @throws \InvalidArgumentException
*/
private function __construct(string $enumName){
self::verifyName($enumName);
$this->enumName = $enumName;
if(self::$nextId === null){
self::$nextId = Process::pid(); //this provides enough base entropy to prevent hardcoding
}
$this->runtimeId = self::$nextId++;
}
public function name() : string{
return $this->enumName;
}
/**
* Returns a runtime-only identifier for this enum member. This will be different with each run, so don't try to
* hardcode it.
* This can be useful for switches or array indexing.
*/
public function id() : int{
return $this->runtimeId;
}
/**
* Returns whether the two objects are equivalent.
*/
public function equals(self $other) : bool{
return $this->enumName === $other->enumName;
}
}

Some files were not shown because too many files have changed in this diff Show More