mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-12 20:35:11 +00:00
Compare commits
223 Commits
4.0.0-BETA
...
4.0.0-BETA
Author | SHA1 | Date | |
---|---|---|---|
428bd5ae91 | |||
19f448d074 | |||
1c18c731ef | |||
8a2ecfe1d4 | |||
089e62b44e | |||
32a34d2494 | |||
ee9f5e0044 | |||
88b7389080 | |||
f1cc168d26 | |||
fb5543a2ad | |||
a4eda9a8f5 | |||
eb75df6f8e | |||
c66790b6a6 | |||
d78801b9d5 | |||
d410db4302 | |||
a62ce64fdd | |||
5db3915aad | |||
eb40b741ae | |||
b3720b3f17 | |||
7effa03ba4 | |||
d0474ccd92 | |||
2b0768f720 | |||
dba148cfaa | |||
48f77abe7e | |||
bb05af103d | |||
0ef5c67b9b | |||
6d89265510 | |||
a7d8a598e1 | |||
51fbff204b | |||
1873457840 | |||
fca70efbb1 | |||
8f88393184 | |||
b9d9b69bbe | |||
1d99cd329a | |||
bd8cba1a7f | |||
24d4daec90 | |||
4178c81209 | |||
94f4ef5862 | |||
2e2515354c | |||
359d0835f3 | |||
d4cbde6f10 | |||
a5418a019d | |||
baba25953f | |||
d53347454b | |||
401e8d117b | |||
9835d75f65 | |||
b8519d1af4 | |||
f6e53f826b | |||
42ede30e77 | |||
04aedc6494 | |||
701a71a4ee | |||
e50072dc27 | |||
c77829f4ad | |||
c773e43eda | |||
c262c2e726 | |||
a4b65d6a3f | |||
986b4e0651 | |||
2971bf30a5 | |||
4f2bcb61d6 | |||
e2275cc8ec | |||
620874d902 | |||
44508a138f | |||
aa408c9a97 | |||
6d78a0b435 | |||
76b4b23d98 | |||
03fcd844eb | |||
fecc13f362 | |||
9646128d01 | |||
a788954551 | |||
dc07ac33d3 | |||
ec3986827c | |||
09c840b66a | |||
80b402e529 | |||
a3f8546ac4 | |||
46920818b5 | |||
69cb575789 | |||
fee6478cbe | |||
9c5cec77b1 | |||
f48b703533 | |||
70636f6eb4 | |||
c70b80c273 | |||
a794d24c81 | |||
8db5732b44 | |||
48f809d3fa | |||
0348236860 | |||
8c07748100 | |||
06e7338ff9 | |||
bdbfa70558 | |||
7a4af7a0bc | |||
34b1392598 | |||
321345fcc8 | |||
0ac9f4fe61 | |||
2db53775e0 | |||
8523f0fb0b | |||
b570324288 | |||
6284cd14c7 | |||
ce8af4e3bc | |||
b65e89b605 | |||
d3f74d6ce1 | |||
bbd925abc4 | |||
4bf6205a6c | |||
b5699679ef | |||
824a89edfe | |||
ead9aae23c | |||
aefa0afd7c | |||
ec2699ffee | |||
49c1e4c06e | |||
9b94a4661b | |||
62f11360ee | |||
a5833327f0 | |||
d73ea8efe4 | |||
835e18ce6e | |||
01c0602043 | |||
8fd475f87b | |||
34f54750c8 | |||
092aabeb97 | |||
89d7b7198f | |||
70deea0ef9 | |||
859cdfa5d2 | |||
fa93a8d78f | |||
7b6632941d | |||
e62794e4cf | |||
500c298aaf | |||
8ac16345a3 | |||
19a66a8d03 | |||
6d728e8d98 | |||
e1ee320c8d | |||
965a16d19d | |||
5bae458a91 | |||
2696698926 | |||
912e612743 | |||
fd2df637b6 | |||
aa53dc6709 | |||
c1f843a42c | |||
09715906c8 | |||
13068ba3a7 | |||
b54854529f | |||
974d08efd6 | |||
289553fa46 | |||
e38866c4ba | |||
58a95f8836 | |||
ccc881ee58 | |||
308d7c126a | |||
4910250a81 | |||
e0d2e24698 | |||
d5f02a0bf8 | |||
2a3a57c519 | |||
5115387feb | |||
dd0aaf59b5 | |||
a555f21b18 | |||
1be9b2f037 | |||
32fd9879e5 | |||
dc2e8e7e8f | |||
847e24fc41 | |||
9e6d740570 | |||
8e3772ceef | |||
e032b8fe20 | |||
90800a4124 | |||
4b00465e24 | |||
10b3596eef | |||
258c38f9cd | |||
d07517fe8b | |||
31a176286d | |||
1fafce6d6f | |||
5061bbbc25 | |||
a101d1cdf9 | |||
fec48003d9 | |||
e25c03eec1 | |||
7245d15abe | |||
13178a47a5 | |||
817ab88c70 | |||
fef8297907 | |||
dbeaf27cb7 | |||
2db79cf58d | |||
7d06b76aaf | |||
0ad663ff50 | |||
a27c14c00c | |||
5b26abcb0e | |||
f2d6059613 | |||
bb6ea8cbdc | |||
356a49d225 | |||
6332af3e59 | |||
fb570970a8 | |||
30e10c38b6 | |||
05dc675d5b | |||
d63b9d1648 | |||
f9e6fd44bc | |||
0108888450 | |||
dd0c2fed82 | |||
2566123e49 | |||
54174eefa0 | |||
f5266ec816 | |||
c6b2c63a9b | |||
f26f063164 | |||
81d5598e96 | |||
c7e9138994 | |||
88f799da2c | |||
8de30e8162 | |||
e6f6a036ef | |||
32f8b8163e | |||
5b818827db | |||
42bf9578ce | |||
aee4a00a50 | |||
2fdd8d039e | |||
349f37b15f | |||
afa3349c04 | |||
6a8280b1ba | |||
003c002208 | |||
d417b1e2f5 | |||
65e468e3c2 | |||
a11cf8c296 | |||
c931c52617 | |||
b3e8314b9f | |||
f138004913 | |||
8e2d06a880 | |||
eb80515e99 | |||
1cb540387c | |||
d455188d03 | |||
14fba36636 | |||
43ac3fbf3e | |||
352162a6e6 | |||
b3601c9390 | |||
817fec9e3d |
23
.github/workflows/main.yml
vendored
23
.github/workflows/main.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.9]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2 #needed for build.sh
|
||||
@ -37,7 +37,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.9]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -87,7 +87,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.9]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -139,7 +139,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.9]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -191,7 +191,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.9]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -238,11 +238,10 @@ jobs:
|
||||
- name: Regenerate KnownTranslation APIs
|
||||
run: php build/generate-known-translation-apis.php
|
||||
|
||||
- name: Run git diff
|
||||
run: git diff
|
||||
|
||||
- name: Fail job if changes were made
|
||||
run: git diff --quiet
|
||||
- name: Verify code is unchanged
|
||||
run: |
|
||||
git diff
|
||||
git diff --quiet
|
||||
|
||||
codestyle:
|
||||
name: Code Style checks
|
||||
@ -254,10 +253,10 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.9.0
|
||||
uses: shivammathur/setup-php@2.15.0
|
||||
with:
|
||||
php-version: 8.0
|
||||
tools: php-cs-fixer
|
||||
tools: php-cs-fixer:3.2
|
||||
|
||||
- name: Run PHP-CS-Fixer
|
||||
run: php-cs-fixer fix --dry-run --diff
|
||||
|
2
.github/workflows/update-php-versions.php
vendored
2
.github/workflows/update-php-versions.php
vendored
@ -22,8 +22,6 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
const VERSIONS = [
|
||||
"7.3",
|
||||
"7.4",
|
||||
"8.0"
|
||||
];
|
||||
|
||||
|
@ -61,6 +61,11 @@ return (new PhpCsFixer\Config)
|
||||
],
|
||||
'sort_algorithm' => 'alpha'
|
||||
],
|
||||
'phpdoc_line_span' => [
|
||||
'property' => 'single',
|
||||
'method' => null,
|
||||
'const' => null
|
||||
],
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_trim_consecutive_blank_line_separation' => true,
|
||||
'single_import_per_statement' => true,
|
||||
|
@ -2,13 +2,13 @@
|
||||
## Pre-requisites
|
||||
- A bash shell (git bash is sufficient for Windows)
|
||||
- [`git`](https://git-scm.com) available in your shell
|
||||
- PHP 7.4 or newer available in your shell
|
||||
- PHP 8.0 or newer available in your shell
|
||||
- [`composer`](https://getcomposer.org) available in your shell
|
||||
|
||||
## Custom PHP binaries
|
||||
Because PocketMine-MP requires several non-standard PHP extensions and configuration, PMMP provides scripts to build custom binaries for running PocketMine-MP, as well as prebuilt binaries.
|
||||
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-7.4-Aggregate)
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-8.0-Aggregate)
|
||||
- [Compile scripts](https://github.com/pmmp/php-build-scripts) are provided as a submodule in the path `build/php`
|
||||
|
||||
If you use a custom binary, you'll need to replace `composer` usages in this guide with `path/to/your/php path/to/your/composer.phar`.
|
||||
@ -34,7 +34,7 @@ There is a bug in PHP that might cause an error which looks like this:
|
||||
```
|
||||
Fatal error: Uncaught BadMethodCallException: unable to create temporary file in PocketMine-MP/build/server-phar.php:119
|
||||
```
|
||||
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 7.4.16 or 8.0.3.
|
||||
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 8.0.3.
|
||||
|
||||
## Running PocketMine-MP from source code
|
||||
Run `src/PocketMine.php` using your preferred PHP binary.
|
||||
|
@ -25,18 +25,26 @@ namespace pocketmine\build\make_release;
|
||||
|
||||
use pocketmine\utils\VersionString;
|
||||
use pocketmine\VersionInfo;
|
||||
use function count;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function dirname;
|
||||
use function fgets;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function fwrite;
|
||||
use function getopt;
|
||||
use function is_string;
|
||||
use function max;
|
||||
use function preg_replace;
|
||||
use function sleep;
|
||||
use function sprintf;
|
||||
use function str_pad;
|
||||
use function strlen;
|
||||
use function system;
|
||||
use const STDERR;
|
||||
use const STDIN;
|
||||
use const STDOUT;
|
||||
use const STR_PAD_LEFT;
|
||||
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
@ -60,22 +68,38 @@ function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev
|
||||
file_put_contents($versionInfoPath, $versionInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $argv
|
||||
* @phpstan-param list<string> $argv
|
||||
*/
|
||||
function main(array $argv) : void{
|
||||
if(count($argv) < 2){
|
||||
fwrite(STDERR, "Arguments: <channel> [release version] [next version]\n");
|
||||
exit(1);
|
||||
const ACCEPTED_OPTS = [
|
||||
"current" => "Version to insert and tag",
|
||||
"next" => "Version to put in the file after tagging",
|
||||
"channel" => "Release channel to post this build into"
|
||||
];
|
||||
|
||||
function main() : void{
|
||||
$filteredOpts = [];
|
||||
foreach(getopt("", ["current:", "next:", "channel:", "help"]) as $optName => $optValue){
|
||||
if($optName === "help"){
|
||||
fwrite(STDOUT, "Options:\n");
|
||||
|
||||
$maxLength = max(array_map(fn(string $str) => strlen($str), array_keys(ACCEPTED_OPTS)));
|
||||
foreach(ACCEPTED_OPTS as $acceptedName => $description){
|
||||
fwrite(STDOUT, str_pad("--$acceptedName", $maxLength + 4, " ", STR_PAD_LEFT) . ": $description\n");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
if(!is_string($optValue)){
|
||||
fwrite(STDERR, "--$optName expects exactly 1 value\n");
|
||||
exit(1);
|
||||
}
|
||||
$filteredOpts[$optName] = $optValue;
|
||||
}
|
||||
if(isset($argv[2])){
|
||||
$currentVer = new VersionString($argv[2]);
|
||||
|
||||
if(isset($filteredOpts["current"])){
|
||||
$currentVer = new VersionString($filteredOpts["current"]);
|
||||
}else{
|
||||
$currentVer = VersionInfo::VERSION();
|
||||
$currentVer = new VersionString(VersionInfo::BASE_VERSION);
|
||||
}
|
||||
if(isset($argv[3])){
|
||||
$nextVer = new VersionString($argv[3]);
|
||||
if(isset($filteredOpts["next"])){
|
||||
$nextVer = new VersionString($filteredOpts["next"]);
|
||||
}else{
|
||||
$nextVer = new VersionString(sprintf(
|
||||
"%u.%u.%u",
|
||||
@ -84,8 +108,10 @@ function main(array $argv) : void{
|
||||
$currentVer->getPatch() + 1
|
||||
));
|
||||
}
|
||||
$channel = $filteredOpts["channel"] ?? VersionInfo::BUILD_CHANNEL;
|
||||
|
||||
echo "About to tag version $currentVer. Next version will be $nextVer.\n";
|
||||
echo "$currentVer will be published on release channel \"$channel\".\n";
|
||||
echo "please add appropriate notes to the changelog and press enter...";
|
||||
fgets(STDIN);
|
||||
system('git add "' . dirname(__DIR__) . '/changelogs"');
|
||||
@ -95,10 +121,10 @@ function main(array $argv) : void{
|
||||
exit(1);
|
||||
}
|
||||
$versionInfoPath = dirname(__DIR__) . '/src/VersionInfo.php';
|
||||
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $argv[1]);
|
||||
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $channel);
|
||||
system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"');
|
||||
system('git tag ' . $currentVer->getBaseVersion());
|
||||
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true, "");
|
||||
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true, $channel);
|
||||
system('git add "' . $versionInfoPath . '"');
|
||||
system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"');
|
||||
echo "pushing changes in 5 seconds\n";
|
||||
@ -106,4 +132,4 @@ function main(array $argv) : void{
|
||||
system('git push origin HEAD ' . $currentVer->getBaseVersion());
|
||||
}
|
||||
|
||||
main($argv);
|
||||
main();
|
||||
|
Submodule build/php updated: ad9cd1fdb4...9a042c5593
14
changelogs/3.23.md
Normal file
14
changelogs/3.23.md
Normal file
@ -0,0 +1,14 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.30**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.23.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.30.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
# 3.23.1
|
||||
- Fixed broken build of 3.23.0.
|
12
changelogs/3.24.md
Normal file
12
changelogs/3.24.md
Normal file
@ -0,0 +1,12 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.30**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.24.0
|
||||
- PHP 8.0 is now required as a minimum.
|
||||
- Fixed stats reporting checking the wrong `pocketmine.yml` property.
|
||||
- Fixed `Projectile->move()` not respecting the given `dx`/`dy`/`dz` and using its own motion instead.
|
11
changelogs/3.25.md
Normal file
11
changelogs/3.25.md
Normal file
@ -0,0 +1,11 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.40**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.25.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.40.
|
||||
- Removed compatibility with earlier versions.
|
@ -329,6 +329,8 @@ However, if we add `src-namespace-prefix: pmmp\TesterPlugin` to the `plugin.yml`
|
||||
- The following methods have signature changes:
|
||||
- `Entity->entityBaseTick()` is now `protected`.
|
||||
- `Entity->move()` is now `protected`.
|
||||
- `Entity->setPosition()` is now `protected` (use `Entity->teleport()` instead).
|
||||
- `Entity->setPositionAndRotation()` is now `protected` (use `Entity->teleport()` instead).
|
||||
- `Living->knockBack()` now accepts `float, float, float` (the first two parameters have been removed).
|
||||
- `Living->getEffects()` now returns `EffectManager` instead of `Effect[]`.
|
||||
- The following classes have been added:
|
||||
@ -1145,7 +1147,7 @@ However, if we add `src-namespace-prefix: pmmp\TesterPlugin` to the `plugin.yml`
|
||||
|
||||
#### Particles
|
||||
- `DestroyBlockParticle` has been renamed to `BlockBreakParticle` for consistency.
|
||||
- `DustParticle->__construct()` now accepts a `pocketmine\utils\Color` object instead of `r, g, b, a`.
|
||||
- `DustParticle->__construct()` now accepts a `pocketmine\color\Color` object instead of `r, g, b, a`.
|
||||
- `pocketmine\world\particle\Particle` no longer extends `pocketmine\math\Vector3`, and has been converted to an interface.
|
||||
- Added the following `Particle` classes:
|
||||
- `DragonEggTeleportParticle`
|
||||
@ -1332,3 +1334,194 @@ Released 10th September 2021.
|
||||
- `Liquid->getMinAdjacentSourcesToFormSource()`: returns how many adjacent source blocks of the same liquid must be present in order for the current block to become a source itself
|
||||
- `Player->getPlayerInfo()`
|
||||
- `Liquid` minimum-cost flow calculation code has been extracted to `MinimumCostFlowCalculator`.
|
||||
|
||||
# 4.0.0-BETA4
|
||||
Released 6th October 2021.
|
||||
|
||||
## General
|
||||
- Improved performance of lighting calculation by avoiding copies of useless data from the main thread.
|
||||
- Resource pack loading now accepts `dependencies` and `capabilities` fields in the `manifest.json` (although it doesn't currently check them).
|
||||
- `/help` is now localized according to language set in `server.properties`.
|
||||
- Various messages related to world loading, generation and conversion are now localized according to the language set in `server.properties`.
|
||||
- Compasses now point to the correct (current) world's spawn point after teleporting players to a different world. Previously, they would continue to point to the spawn of the world that the player initially spawned in.
|
||||
- The `--bootstrap` CLI option has been removed.
|
||||
- RakLib 0.14.2 is now required. This fixes the following issues:
|
||||
- Fixed incorrect handling of sessions on client disconnect (leading to timeout debug messages).
|
||||
- Fixed transferring players often not working correctly.
|
||||
- Fixed disconnect screens sometimes not displaying.
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash when UPnP encounters an error.
|
||||
- Fixed server crash when clients sent items with bad NBT in inventory transactions.
|
||||
- Fixed server crash when loading a plugin with legacy nested permission structure (now the plugin will fail to load, but the server won't crash).
|
||||
- Fixed server crash when using `/give` with bad NBT on any item.
|
||||
- Fixed server crash when loading a plugin with improperly formatted API version (now the plugin will fail to load, but the server won't crash).
|
||||
- Fixed server crash when changing player gamemode during `PlayerLoginEvent`.
|
||||
- Incorrect structure of `commands` in plugin manifest is now detected earlier and handled more gracefully.
|
||||
- Fixed console reader subprocess lingering on server crash on Windows and screwing up the terminal.
|
||||
- Fixed `Player` object memory leak when kicking players during `PlayerLoginEvent` (this caused the `World` to report warnings about leaked entities on shutdown).
|
||||
- Fixed `Projectile->move()` ignoring the `dx`/`dy`/`dz` parameters given and using its own `motion` instead.
|
||||
- Fixed `BlockFactory->get()` erroneously accepting meta values of `16`.
|
||||
- Fixed `Block->isSameState()` false negatives for some types of slabs.
|
||||
- Fixed being unable to place slabs of the same type on top of each other to create double slabs.
|
||||
|
||||
## API changes
|
||||
- Plugin commands in `plugin.yml` must now declare `permission` for each command. Previously, the `permission` key was optional, causing anyone to be able to use the command.
|
||||
- This behaviour was removed because of the potential for security issues - a typo in `plugin.yml` could lead to dangerous functionality being exposed to everyone.
|
||||
- If you want to make a command that everyone can use, declare a permission with a `default` of `true` and assign it to the command.
|
||||
- Plugin permissions in `plugin.yml` must now declare `default` for each permission. Previously, the `default` key was optional, causing the permission to silently be denied to everyone (PM4) or granted to ops implicitly (PM3).
|
||||
|
||||
### Block
|
||||
- Added the following classes:
|
||||
- `pocketmine\block\utils\LeverFacing`
|
||||
- Added the following API methods:
|
||||
- `pocketmine\block\Lever->isActivated()`
|
||||
- `pocketmine\block\Lever->setActivated()`
|
||||
- `pocketmine\block\Lever->getFacing()`
|
||||
- `pocketmine\block\Lever->setFacing()`
|
||||
|
||||
### World
|
||||
- The following API methods have signature changes:
|
||||
- `Chunk->getSubChunks()` now returns `array<int, SubChunk>` instead of `SplFixedArray<SubChunk>`.
|
||||
- The following API methods have been removed:
|
||||
- `FastChunkSerializer::serialize()`
|
||||
- `FastChunkSerializer::deserialize()`
|
||||
- The following API methods have been added:
|
||||
- `FastChunkSerializer::serializeTerrain()`: serializes blocks and biomes only
|
||||
- `FastChunkSerializer::deserializeTerrain()`: deserializes the output of `serializeTerrain()`
|
||||
|
||||
### Utils
|
||||
- The following API methods have signature changes:
|
||||
- `Process::kill()` now requires an additional `bool $subprocesses` parameter.
|
||||
|
||||
# 4.0.0-BETA5
|
||||
Released 12th October 2021.
|
||||
|
||||
## General
|
||||
- Exception log format has been changed. Now, exception info is logged in one big block message. This saves space on the console and improves readability, as well as reducing the ability for bad `ThreadedLoggerAttachment`s to break exception output.
|
||||
- Log messages are now pushed to `server.log` before calling logger attachment, instead of after. This fixes messages not being written to disk when an error occurs in a logger attachment.
|
||||
- Improved startup performance when loading many plugins.
|
||||
- The `worlds` config in `pocketmine.yml` no longer supports attaching the generator settings to the `generator` key (use the `preset` key instead).
|
||||
- Using an unknown generator in `server.properties` or `pocketmine.yml` will now cause a failure to generate the world.
|
||||
- Using invalid/incorrect world generator options (presets) in `server.properties` or `pocketmine.yml` will now cause a failure to generate the world.
|
||||
- Generator options of existing worlds are now validated before loading them. If they are invalid, the server will fail to load them.
|
||||
- Several more log messages have been localized, including plugin loading errors.
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash when using `/give` to give an item by ID which doesn't exist in Minecraft.
|
||||
- Fixed server crash when boolean `server.properties` options were given an integer value (e.g. `0` or `1` instead of `false` or `true`).
|
||||
- Fixed stats reporting checking for a nonexistent `pocketmine.yml` setting.
|
||||
- Fixed use of commands without the proper permission sending a message `commands.generic.permission` instead of the proper message.
|
||||
- Fixed entities set on fire appearing to stay on fire, although not taking any damage.
|
||||
- Fixed a duplicate `MB` suffix on the `Memory freed` output of `/gc`.
|
||||
- Fixed the server attempting to generate a world if it failed to load.
|
||||
|
||||
## API
|
||||
### Block
|
||||
- The following API methods have been renamed:
|
||||
- `Block->getPositionOffset()` -> `Block->getModelPositionOffset()`.
|
||||
|
||||
### Event
|
||||
- `@handleCancelled` PhpDoc annotation can no longer be used on event handlers for non-cancellable events.
|
||||
- The following API methods have been added:
|
||||
- `StructureGrowEvent->getPlayer()`
|
||||
|
||||
### Inventory
|
||||
- The following API methods have been added:
|
||||
- `Inventory->getAddableItemQuantity()`
|
||||
|
||||
### Scheduler
|
||||
- `ClosureTask` now permits closures without an explicit return type (useful for arrow functions).
|
||||
|
||||
### Utils
|
||||
- The following API methods have been added:
|
||||
- `Config::parseProperties()`
|
||||
- `Config::writeProperties()`
|
||||
- `Config::parseList()`
|
||||
- `Config::writeList()`
|
||||
|
||||
### World
|
||||
- The following API methods have signature changes:
|
||||
- `GeneratorManager->registerGenerator()` now requires a `\Closure $presetValidator` parameter. This is used to check generator options of worlds and configs before attempting to use them.
|
||||
|
||||
# 4.0.0-BETA6
|
||||
Released 19th October 2021.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.40.
|
||||
- Removed support for earlier versions.
|
||||
- CTRL+C signal handling has been restored, and is now supported on Windows. Pressing CTRL+C while the server is running will behave as if the `/stop` command was invoked.
|
||||
- Added a script `tools/generate-permission-doc.php` to generate a Markdown file with a list of all permissions and their relationships. In the future, this will be used to maintain the official documentation, but plugin developers might find it useful for their own purposes too.
|
||||
- [`respect/validation`](https://packagist.org/packages/respect/validation) is no longer a core dependency.
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash when using `/give` to give an item with a too-large item ID, or `/clear` to clear an item that does not exist.
|
||||
- Now, `LegacyStringToItemParser` is used exclusively, and numeric IDs are no longer parsed.
|
||||
|
||||
## Gameplay
|
||||
- Picking up some items from a dropped stack of items is now supported. This fixes various bugs with being unable to pick up items with an almost-full inventory.
|
||||
|
||||
# 4.0.0-BETA7
|
||||
Released 28th October 2021.
|
||||
|
||||
## General
|
||||
- Phar plugins are now able to depend on folder plugins loaded by DevTools.
|
||||
- Now uses [`pocketmine/bedrock-protocol@58c53a259e819a076bf8fe875d2a012da7d19d65`](https://github.com/pmmp/BedrockProtocol/tree/58c53a259e819a076bf8fe875d2a012da7d19d65). This version features significant changes, including:
|
||||
- Standardisation of various field names (e.g. `eid` -> `actorRuntimeId`, `evid` -> `eventId`)
|
||||
- Rename of `entity` related fields to `actor` where appropriate (e.g. `entityRuntimeId` -> `actorRuntimeId`)
|
||||
- Block position `x`/`y`/`z` fields replaced by `BlockPosition`
|
||||
- Static `::create()` functions for all packets, which ensure that fields can't be forgotten
|
||||
|
||||
## Fixes
|
||||
- Fixed server crash when clients send itemstacks with unmappable dynamic item IDs.
|
||||
- Fixed server crash on invalid ItemStackRequest action types.
|
||||
- Fixed autosave bug that caused unmodified chunks to be saved at least once (during the first autosave after they were loaded).
|
||||
- Fixed `ConsoleReaderThread` returning strings with newlines still on the end.
|
||||
- Fixed changes made to adjacent chunks in `ChunkPopulateEvent` (e.g. setting blocks) sometimes getting overwritten.
|
||||
|
||||
## API
|
||||
### Event
|
||||
- `PlayerCreationEvent` now verifies that the player class set is instantiable - this ensures that plugins get properly blamed for breaking things.
|
||||
|
||||
### World
|
||||
- `World->generateChunkCallback()` has been specialized for use by `PopulationTask`. This allows fixing various inconsistencies involving `ChunkPopulateEvent` (e.g. modifications to adjacent chunks in `ChunkPopulationEvent` might be wiped out, if the population of the target chunk modified the adjacent chunk).
|
||||
- It now accepts `Chunk $centerChunk, array<int, Chunk> $adjacentChunks` (instead of `?Chunk $chunk`).
|
||||
- It's no longer expected to be used by plugins - plugins should be using `World->setChunk()` anyway.
|
||||
- `Chunk->getModificationCounter()` has been added. This is a number starting from `0` when the `Chunk` object is first created (unless overridden by the constructor). It's incremented every time blocks or biomes are changed in the chunk. It resets after the chunk is unloaded and reloaded.
|
||||
- The following API methods have changed signatures:
|
||||
- `Sound->encode()` no longer accepts `null` for the position.
|
||||
- `Chunk->__construct()`: removed `HeightArray $heightMap` parameter, added `bool $terrainPopulated` and `int $modificationCounter` parameters.
|
||||
|
||||
### Plugin
|
||||
- `PluginManager->loadPlugins()` now accepts paths to files as well as directories, in which case it will load only the plugin found in the target file.
|
||||
- The following API methods have been removed:
|
||||
- `PluginManager->loadPlugin()`: use `PluginManager->loadPlugins()` instead
|
||||
|
||||
# 4.0.0-BETA8
|
||||
Released 29th October 2021.
|
||||
|
||||
## General
|
||||
- Chunk packet caches are now cleared by the memory manager on low memory.
|
||||
- `Entity->spawnTo()` now has an additional sanity check for matching worlds (might expose a few new errors in plugins).
|
||||
- [`pocketmine/math` 0.4.0](https://github.com/pmmp/Math/releases/tag/0.4.0) is now used. Please see its release notes for changes.
|
||||
|
||||
## Fixes
|
||||
- Zlib raw check for LevelDB is now done directly on startup, avoiding crashes when later trying to load worlds.
|
||||
- Fixed tiles and entities getting deleted from adjacent chunks during chunk population.
|
||||
- Fixed players being unable to open their inventories more than once.
|
||||
- Fixed entities not getting updated when a nearby chunk is replaced (e.g. dropped items would float in midair if the ground was lower than before)
|
||||
|
||||
## API
|
||||
### World
|
||||
- `World::setChunk()` has the following changes:
|
||||
- `$deleteEntitiesAndTiles` parameter has been removed.
|
||||
- Entities are no longer deleted on chunk replacement.
|
||||
- Tiles are no longer deleted on chunk replacement, unless one of the following conditions is met:
|
||||
- the target block in the new chunk doesn't expect a tile
|
||||
- the target block in the new chunk expects a different type of tile (responsibility of the plugin developer to create the new tile)
|
||||
- there's already a tile in the target chunk which conflicts with the old one
|
||||
- `Location::__construct()` has the following changes:
|
||||
- `world` parameter is now 4th instead of last.
|
||||
- All parameters are now mandatory.
|
||||
- Reverted addition of chunk modification counters in previous beta.
|
||||
- `Chunk::DIRTY_FLAG_TERRAIN` has been renamed to `Chunk::DIRTY_FLAG_BLOCKS`.
|
||||
|
@ -34,7 +34,7 @@
|
||||
"adhocore/json-comment": "^1.1",
|
||||
"fgrosse/phpasn1": "^2.3",
|
||||
"netresearch/jsonmapper": "^4.0",
|
||||
"pocketmine/bedrock-protocol": "2.0.0+bedrock1.17.30",
|
||||
"pocketmine/bedrock-protocol": "dev-master",
|
||||
"pocketmine/binaryutils": "^0.2.1",
|
||||
"pocketmine/callback-validator": "^1.0.2",
|
||||
"pocketmine/classloader": "dev-master",
|
||||
@ -42,18 +42,17 @@
|
||||
"pocketmine/errorhandler": "^0.3.0",
|
||||
"pocketmine/log": "^0.3.0",
|
||||
"pocketmine/log-pthreads": "^0.2.0",
|
||||
"pocketmine/math": "^0.3.0",
|
||||
"pocketmine/math": "^0.4.0",
|
||||
"pocketmine/nbt": "^0.3.0",
|
||||
"pocketmine/raklib": "^0.14.0",
|
||||
"pocketmine/raklib": "^0.14.2",
|
||||
"pocketmine/raklib-ipc": "^0.1.0",
|
||||
"pocketmine/snooze": "^0.3.0",
|
||||
"pocketmine/spl": "dev-master",
|
||||
"ramsey/uuid": "^4.1",
|
||||
"respect/validation": "^2.0",
|
||||
"webmozart/path-util": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "0.12.98",
|
||||
"phpstan/phpstan": "0.12.99",
|
||||
"phpstan/phpstan-phpunit": "^0.12.6",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.2",
|
||||
"phpunit/phpunit": "^9.2"
|
||||
|
450
composer.lock
generated
450
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "bd5d7fc81a75739bfd2ef04b38220b84",
|
||||
"content-hash": "3f467dca67940d465ceafbe5774d6977",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -63,16 +63,16 @@
|
||||
},
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/brick/math.git",
|
||||
"reference": "dff976c2f3487d42c1db75a3b180e2b9f0e72ce0"
|
||||
"reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/brick/math/zipball/dff976c2f3487d42c1db75a3b180e2b9f0e72ce0",
|
||||
"reference": "dff976c2f3487d42c1db75a3b180e2b9f0e72ce0",
|
||||
"url": "https://api.github.com/repos/brick/math/zipball/ca57d18f028f84f777b2168cd1911b0dee2343ae",
|
||||
"reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -82,7 +82,7 @@
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.2",
|
||||
"phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0",
|
||||
"vimeo/psalm": "4.3.2"
|
||||
"vimeo/psalm": "4.9.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@ -107,15 +107,19 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/brick/math/issues",
|
||||
"source": "https://github.com/brick/math/tree/0.9.2"
|
||||
"source": "https://github.com/brick/math/tree/0.9.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/BenMorel",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/brick/math",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-20T22:51:39+00:00"
|
||||
"time": "2021-08-15T20:50:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fgrosse/phpasn1",
|
||||
@ -245,25 +249,25 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-protocol",
|
||||
"version": "2.0.0+bedrock1.17.30",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
||||
"reference": "faff7da904e68f69b1a9128956dac3122e87308a"
|
||||
"reference": "c8d891b4dff9817d5fcd373dfec0608b20be3b0a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/faff7da904e68f69b1a9128956dac3122e87308a",
|
||||
"reference": "faff7da904e68f69b1a9128956dac3122e87308a",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/c8d891b4dff9817d5fcd373dfec0608b20be3b0a",
|
||||
"reference": "c8d891b4dff9817d5fcd373dfec0608b20be3b0a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"netresearch/jsonmapper": "^4.0",
|
||||
"php": "^7.4 || ^8.0",
|
||||
"php": "^8.0",
|
||||
"pocketmine/binaryutils": "^0.2.0",
|
||||
"pocketmine/color": "^0.2.0",
|
||||
"pocketmine/math": "^0.3.0",
|
||||
"pocketmine/math": "^0.3.0 || ^0.4.0",
|
||||
"pocketmine/nbt": "^0.3.0",
|
||||
"ramsey/uuid": "^4.1"
|
||||
},
|
||||
@ -273,6 +277,7 @@
|
||||
"phpstan/phpstan-strict-rules": "^0.12.10",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@ -286,22 +291,22 @@
|
||||
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
|
||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/bedrock-1.17.30"
|
||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/master"
|
||||
},
|
||||
"time": "2021-09-21T23:25:51+00:00"
|
||||
"time": "2021-10-29T20:54:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/binaryutils",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BinaryUtils.git",
|
||||
"reference": "8cd078e2426f8100331f2d73bef10f481dad6cde"
|
||||
"reference": "f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/8cd078e2426f8100331f2d73bef10f481dad6cde",
|
||||
"reference": "8cd078e2426f8100331f2d73bef10f481dad6cde",
|
||||
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9",
|
||||
"reference": "f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -310,7 +315,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "0.12.85",
|
||||
"phpstan/phpstan": "0.12.99",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.4"
|
||||
},
|
||||
"type": "library",
|
||||
@ -326,9 +331,9 @@
|
||||
"description": "Classes and methods for conveniently handling binary data",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BinaryUtils/issues",
|
||||
"source": "https://github.com/pmmp/BinaryUtils/tree/0.2.1"
|
||||
"source": "https://github.com/pmmp/BinaryUtils/tree/0.2.2"
|
||||
},
|
||||
"time": "2021-05-30T19:42:57+00:00"
|
||||
"time": "2021-10-22T19:54:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/callback-validator",
|
||||
@ -588,26 +593,26 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/math",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/Math.git",
|
||||
"reference": "83ec067b12c066fc61d9fb129daf7e61ef3b1d63"
|
||||
"reference": "6d64e2555bd2e95ed024574f75d1cefc135c89fc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/83ec067b12c066fc61d9fb129daf7e61ef3b1d63",
|
||||
"reference": "83ec067b12c066fc61d9fb129daf7e61ef3b1d63",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/6d64e2555bd2e95ed024574f75d1cefc135c89fc",
|
||||
"reference": "6d64e2555bd2e95ed024574f75d1cefc135c89fc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"php": "^8.0",
|
||||
"php-64bit": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"irstea/phpunit-shim": "^8.5 || ^9.5",
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "0.12.90",
|
||||
"phpstan/phpstan": "0.12.99",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.4"
|
||||
},
|
||||
"type": "library",
|
||||
@ -623,9 +628,9 @@
|
||||
"description": "PHP library containing math related code used in PocketMine-MP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/Math/issues",
|
||||
"source": "https://github.com/pmmp/Math/tree/0.3.0"
|
||||
"source": "https://github.com/pmmp/Math/tree/0.4.0"
|
||||
},
|
||||
"time": "2021-07-14T18:39:31+00:00"
|
||||
"time": "2021-10-29T20:33:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/nbt",
|
||||
@ -671,16 +676,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/raklib",
|
||||
"version": "0.14.0",
|
||||
"version": "0.14.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/RakLib.git",
|
||||
"reference": "ed27bfd83f4de5ff32f71ec7611a66c4857a82ce"
|
||||
"reference": "e3a861187470e1facc6625040128f447ebbcbaec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/ed27bfd83f4de5ff32f71ec7611a66c4857a82ce",
|
||||
"reference": "ed27bfd83f4de5ff32f71ec7611a66c4857a82ce",
|
||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/e3a861187470e1facc6625040128f447ebbcbaec",
|
||||
"reference": "e3a861187470e1facc6625040128f447ebbcbaec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -708,9 +713,9 @@
|
||||
"description": "A RakNet server implementation written in PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/RakLib/issues",
|
||||
"source": "https://github.com/pmmp/RakLib/tree/0.14.0"
|
||||
"source": "https://github.com/pmmp/RakLib/tree/0.14.2"
|
||||
},
|
||||
"time": "2021-09-20T21:53:31+00:00"
|
||||
"time": "2021-10-04T20:39:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/raklib-ipc",
|
||||
@ -832,20 +837,21 @@
|
||||
},
|
||||
{
|
||||
"name": "ramsey/collection",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/collection.git",
|
||||
"reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1"
|
||||
"reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/collection/zipball/28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1",
|
||||
"reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1",
|
||||
"url": "https://api.github.com/repos/ramsey/collection/zipball/cccc74ee5e328031b15640b51056ee8d3bb66c0a",
|
||||
"reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8"
|
||||
"php": "^7.3 || ^8",
|
||||
"symfony/polyfill-php81": "^1.23"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/captainhook": "^5.3",
|
||||
@ -855,6 +861,7 @@
|
||||
"hamcrest/hamcrest-php": "^2",
|
||||
"jangregor/phpstan-prophecy": "^0.8",
|
||||
"mockery/mockery": "^1.3",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/extension-installer": "^1",
|
||||
"phpstan/phpstan": "^0.12.32",
|
||||
"phpstan/phpstan-mockery": "^0.12.5",
|
||||
@ -882,7 +889,7 @@
|
||||
"homepage": "https://benramsey.com"
|
||||
}
|
||||
],
|
||||
"description": "A PHP 7.2+ library for representing and manipulating collections.",
|
||||
"description": "A PHP library for representing and manipulating collections.",
|
||||
"keywords": [
|
||||
"array",
|
||||
"collection",
|
||||
@ -893,7 +900,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/collection/issues",
|
||||
"source": "https://github.com/ramsey/collection/tree/1.1.3"
|
||||
"source": "https://github.com/ramsey/collection/tree/1.2.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -905,28 +912,29 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-21T17:40:04+00:00"
|
||||
"time": "2021-10-10T03:01:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"version": "4.2.1",
|
||||
"version": "4.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/uuid.git",
|
||||
"reference": "fe665a03df4f056aa65af552a96e1976df8c8dae"
|
||||
"reference": "fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/fe665a03df4f056aa65af552a96e1976df8c8dae",
|
||||
"reference": "fe665a03df4f056aa65af552a96e1976df8c8dae",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df",
|
||||
"reference": "fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.8 || ^0.9",
|
||||
"ext-json": "*",
|
||||
"php": "^7.2 || ^8",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"ramsey/collection": "^1.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
"symfony/polyfill-ctype": "^1.8",
|
||||
"symfony/polyfill-php80": "^1.14"
|
||||
},
|
||||
"replace": {
|
||||
"rhumsaa/uuid": "self.version"
|
||||
@ -990,7 +998,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/uuid/issues",
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.2.1"
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.2.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1002,131 +1010,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-08-11T01:06:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "respect/stringifier",
|
||||
"version": "0.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Respect/Stringifier.git",
|
||||
"reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Respect/Stringifier/zipball/e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59",
|
||||
"reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.8",
|
||||
"malukenho/docheader": "^0.1.7",
|
||||
"phpunit/phpunit": "^6.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Respect\\Stringifier\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/stringify.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Respect/Stringifier Contributors",
|
||||
"homepage": "https://github.com/Respect/Stringifier/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Converts any value to a string",
|
||||
"homepage": "http://respect.github.io/Stringifier/",
|
||||
"keywords": [
|
||||
"respect",
|
||||
"stringifier",
|
||||
"stringify"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Respect/Stringifier/issues",
|
||||
"source": "https://github.com/Respect/Stringifier/tree/0.2.0"
|
||||
},
|
||||
"time": "2017-12-29T19:39:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "respect/validation",
|
||||
"version": "2.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Respect/Validation.git",
|
||||
"reference": "4c21a7ffc9a4915673cb2c2843963919e664e627"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Respect/Validation/zipball/4c21a7ffc9a4915673cb2c2843963919e664e627",
|
||||
"reference": "4c21a7ffc9a4915673cb2c2843963919e664e627",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"respect/stringifier": "^0.2.0",
|
||||
"symfony/polyfill-mbstring": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"egulias/email-validator": "^3.0",
|
||||
"malukenho/docheader": "^0.1",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"phpstan/phpstan": "^0.12",
|
||||
"phpstan/phpstan-deprecation-rules": "^0.12",
|
||||
"phpstan/phpstan-phpunit": "^0.12",
|
||||
"phpunit/phpunit": "^9.3",
|
||||
"psr/http-message": "^1.0",
|
||||
"respect/coding-standard": "^3.0",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"symfony/validator": "^3.0||^4.0",
|
||||
"zendframework/zend-validator": "^2.1"
|
||||
},
|
||||
"suggest": {
|
||||
"egulias/email-validator": "Strict (RFC compliant) email validation",
|
||||
"ext-bcmath": "Arbitrary Precision Mathematics",
|
||||
"ext-fileinfo": "File Information",
|
||||
"ext-mbstring": "Multibyte String Functions",
|
||||
"symfony/validator": "Use Symfony validator through Respect\\Validation",
|
||||
"zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Respect\\Validation\\": "library/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Respect/Validation Contributors",
|
||||
"homepage": "https://github.com/Respect/Validation/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "The most awesome validation engine ever created for PHP",
|
||||
"homepage": "http://respect.github.io/Validation/",
|
||||
"keywords": [
|
||||
"respect",
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Respect/Validation/issues",
|
||||
"source": "https://github.com/Respect/Validation/tree/2.2.3"
|
||||
},
|
||||
"time": "2021-03-19T14:12:45+00:00"
|
||||
"time": "2021-09-25T23:10:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
@ -1208,25 +1092,22 @@
|
||||
"time": "2021-02-19T12:13:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.23.0",
|
||||
"name": "symfony/polyfill-php80",
|
||||
"version": "v1.23.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1"
|
||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
||||
"reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1",
|
||||
"reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
|
||||
"reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
@ -1239,10 +1120,96 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||
"Symfony\\Polyfill\\Php80\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"classmap": [
|
||||
"Resources/stubs"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ion Bazan",
|
||||
"email": "ion.bazan@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-07-28T13:41:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php81",
|
||||
"version": "v1.23.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php81.git",
|
||||
"reference": "e66119f3de95efc359483f810c4c3e6436279436"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/e66119f3de95efc359483f810c4c3e6436279436",
|
||||
"reference": "e66119f3de95efc359483f810c4c3e6436279436",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "1.23-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/polyfill",
|
||||
"url": "https://github.com/symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php81\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"classmap": [
|
||||
"Resources/stubs"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -1259,17 +1226,16 @@
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"mbstring",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.0"
|
||||
"source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1285,7 +1251,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-05-27T09:27:20+00:00"
|
||||
"time": "2021-05-21T13:25:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
@ -1526,16 +1492,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v4.12.0",
|
||||
"version": "v4.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "6608f01670c3cc5079e18c1dab1104e002579143"
|
||||
"reference": "50953a2691a922aa1769461637869a0a2faa3f53"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143",
|
||||
"reference": "6608f01670c3cc5079e18c1dab1104e002579143",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53",
|
||||
"reference": "50953a2691a922aa1769461637869a0a2faa3f53",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1576,9 +1542,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0"
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.0"
|
||||
},
|
||||
"time": "2021-07-21T10:44:31+00:00"
|
||||
"time": "2021-09-20T12:20:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phar-io/manifest",
|
||||
@ -1746,16 +1712,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-docblock",
|
||||
"version": "5.2.2",
|
||||
"version": "5.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
||||
"reference": "069a785b2141f5bcf49f3e353548dc1cce6df556"
|
||||
"reference": "622548b623e81ca6d78b721c5e029f4ce664f170"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556",
|
||||
"reference": "069a785b2141f5bcf49f3e353548dc1cce6df556",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170",
|
||||
"reference": "622548b623e81ca6d78b721c5e029f4ce664f170",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1766,7 +1732,8 @@
|
||||
"webmozart/assert": "^1.9.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~1.3.2"
|
||||
"mockery/mockery": "~1.3.2",
|
||||
"psalm/phar": "^4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -1796,22 +1763,22 @@
|
||||
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
|
||||
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master"
|
||||
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
|
||||
},
|
||||
"time": "2020-09-03T19:13:55+00:00"
|
||||
"time": "2021-10-19T17:43:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/type-resolver",
|
||||
"version": "1.4.0",
|
||||
"version": "1.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
||||
"reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
|
||||
"reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
|
||||
"reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae",
|
||||
"reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1819,7 +1786,8 @@
|
||||
"phpdocumentor/reflection-common": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-tokenizer": "*"
|
||||
"ext-tokenizer": "*",
|
||||
"psalm/phar": "^4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -1845,39 +1813,39 @@
|
||||
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
||||
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
|
||||
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1"
|
||||
},
|
||||
"time": "2020-09-17T18:55:26+00:00"
|
||||
"time": "2021-10-02T14:08:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.13.0",
|
||||
"version": "1.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
|
||||
"reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
|
||||
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
|
||||
"reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.2",
|
||||
"php": "^7.2 || ~8.0, <8.1",
|
||||
"php": "^7.2 || ~8.0, <8.2",
|
||||
"phpdocumentor/reflection-docblock": "^5.2",
|
||||
"sebastian/comparator": "^3.0 || ^4.0",
|
||||
"sebastian/recursion-context": "^3.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^6.0",
|
||||
"phpspec/phpspec": "^6.0 || ^7.0",
|
||||
"phpunit/phpunit": "^8.0 || ^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.11.x-dev"
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -1912,22 +1880,22 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/phpspec/prophecy/issues",
|
||||
"source": "https://github.com/phpspec/prophecy/tree/1.13.0"
|
||||
"source": "https://github.com/phpspec/prophecy/tree/1.14.0"
|
||||
},
|
||||
"time": "2021-03-17T13:42:18+00:00"
|
||||
"time": "2021-09-10T09:02:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "0.12.98",
|
||||
"version": "0.12.99",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00"
|
||||
"reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/3bb7cc246c057405dd5e290c3ecc62ab51d57e00",
|
||||
"reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7",
|
||||
"reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1958,7 +1926,7 @@
|
||||
"description": "PHPStan - PHP Static Analysis Tool",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||
"source": "https://github.com/phpstan/phpstan/tree/0.12.98"
|
||||
"source": "https://github.com/phpstan/phpstan/tree/0.12.99"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1978,7 +1946,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-09-02T12:33:01+00:00"
|
||||
"time": "2021-09-12T20:09:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
@ -2086,23 +2054,23 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "9.2.6",
|
||||
"version": "9.2.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "f6293e1b30a2354e8428e004689671b83871edde"
|
||||
"reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
|
||||
"reference": "f6293e1b30a2354e8428e004689671b83871edde",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d4c798ed8d51506800b441f7a13ecb0f76f12218",
|
||||
"reference": "d4c798ed8d51506800b441f7a13ecb0f76f12218",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"nikic/php-parser": "^4.10.2",
|
||||
"nikic/php-parser": "^4.12.0",
|
||||
"php": ">=7.3",
|
||||
"phpunit/php-file-iterator": "^3.0.3",
|
||||
"phpunit/php-text-template": "^2.0.2",
|
||||
@ -2151,7 +2119,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2159,7 +2127,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-28T07:26:59+00:00"
|
||||
"time": "2021-09-17T05:39:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
@ -2404,16 +2372,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "9.5.9",
|
||||
"version": "9.5.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b"
|
||||
"reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b",
|
||||
"reference": "ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c814a05837f2edb0d1471d6e3f4ab3501ca3899a",
|
||||
"reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2429,7 +2397,7 @@
|
||||
"phar-io/version": "^3.0.2",
|
||||
"php": ">=7.3",
|
||||
"phpspec/prophecy": "^1.12.1",
|
||||
"phpunit/php-code-coverage": "^9.2.3",
|
||||
"phpunit/php-code-coverage": "^9.2.7",
|
||||
"phpunit/php-file-iterator": "^3.0.5",
|
||||
"phpunit/php-invoker": "^3.1.1",
|
||||
"phpunit/php-text-template": "^2.0.3",
|
||||
@ -2491,7 +2459,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.9"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.10"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2503,7 +2471,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-08-31T06:47:40+00:00"
|
||||
"time": "2021-09-25T07:38:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
@ -3358,7 +3326,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"abandoned": true,
|
||||
"time": "2020-09-28T06:45:17+00:00"
|
||||
},
|
||||
{
|
||||
@ -3524,6 +3491,7 @@
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"pocketmine/bedrock-protocol": 20,
|
||||
"pocketmine/classloader": 20,
|
||||
"pocketmine/spl": 20
|
||||
},
|
||||
|
@ -38,6 +38,9 @@ parameters:
|
||||
- tests/phpunit
|
||||
- tests/plugins/TesterPlugin
|
||||
- tools
|
||||
excludePaths:
|
||||
analyseAndScan:
|
||||
- build/php
|
||||
dynamicConstantNames:
|
||||
- pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD
|
||||
- pocketmine\DEBUG
|
||||
@ -54,5 +57,5 @@ parameters:
|
||||
#variadics don't work for this - mixed probably shouldn't work either, but for now it does
|
||||
#what we actually need is something that accepts an infinite number of parameters, but in the absence of that,
|
||||
#we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway.
|
||||
anyCallable: 'callable(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed'
|
||||
anyClosure: '\Closure(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed'
|
||||
anyCallable: 'callable(never, never, never, never, never, never, never, never, never, never) : mixed'
|
||||
anyClosure: '\Closure(never, never, never, never, never, never, never, never, never, never) : mixed'
|
||||
|
@ -1,4 +1,691 @@
|
||||
{
|
||||
"-2": -2,
|
||||
"-3": -3,
|
||||
"-4": -4,
|
||||
"-5": -5,
|
||||
"-6": -6,
|
||||
"-7": -7,
|
||||
"-8": -8,
|
||||
"-9": -9,
|
||||
"-10": -10,
|
||||
"-11": -11,
|
||||
"-12": -12,
|
||||
"-13": -13,
|
||||
"-14": -14,
|
||||
"-15": -15,
|
||||
"-16": -16,
|
||||
"-17": -17,
|
||||
"-18": -18,
|
||||
"-19": -19,
|
||||
"-20": -20,
|
||||
"-21": -21,
|
||||
"-22": -22,
|
||||
"-23": -23,
|
||||
"-24": -24,
|
||||
"-25": -25,
|
||||
"-26": -26,
|
||||
"-27": -27,
|
||||
"-28": -28,
|
||||
"-29": -29,
|
||||
"-30": -30,
|
||||
"-31": -31,
|
||||
"-32": -32,
|
||||
"-33": -33,
|
||||
"-34": -34,
|
||||
"-35": -35,
|
||||
"-36": -36,
|
||||
"-37": -37,
|
||||
"-38": -38,
|
||||
"-39": -39,
|
||||
"-40": -40,
|
||||
"-41": -41,
|
||||
"-42": -42,
|
||||
"-43": -43,
|
||||
"-44": -44,
|
||||
"-45": -45,
|
||||
"-46": -46,
|
||||
"-47": -47,
|
||||
"-48": -48,
|
||||
"-49": -49,
|
||||
"-50": -50,
|
||||
"-51": -51,
|
||||
"-52": -52,
|
||||
"-53": -53,
|
||||
"-54": -54,
|
||||
"-55": -55,
|
||||
"-56": -56,
|
||||
"-57": -57,
|
||||
"-58": -58,
|
||||
"-59": -59,
|
||||
"-60": -60,
|
||||
"-61": -61,
|
||||
"-62": -62,
|
||||
"-63": -63,
|
||||
"-64": -64,
|
||||
"-65": -65,
|
||||
"-66": -66,
|
||||
"-67": -67,
|
||||
"-68": -68,
|
||||
"-69": -69,
|
||||
"-70": -70,
|
||||
"-71": -71,
|
||||
"-72": -72,
|
||||
"-73": -73,
|
||||
"-74": -74,
|
||||
"-75": -75,
|
||||
"-76": -76,
|
||||
"-77": -77,
|
||||
"-78": -78,
|
||||
"-79": -79,
|
||||
"-80": -80,
|
||||
"-81": -81,
|
||||
"-82": -82,
|
||||
"-83": -83,
|
||||
"-84": -84,
|
||||
"-85": -85,
|
||||
"-86": -86,
|
||||
"-87": -87,
|
||||
"-88": -88,
|
||||
"-89": -89,
|
||||
"-90": -90,
|
||||
"-91": -91,
|
||||
"-92": -92,
|
||||
"-93": -93,
|
||||
"-94": -94,
|
||||
"-95": -95,
|
||||
"-96": -96,
|
||||
"-97": -97,
|
||||
"-98": -98,
|
||||
"-99": -99,
|
||||
"-100": -100,
|
||||
"-101": -101,
|
||||
"-102": -102,
|
||||
"-103": -103,
|
||||
"-104": -104,
|
||||
"-105": -105,
|
||||
"-106": -106,
|
||||
"-107": -107,
|
||||
"-108": -108,
|
||||
"-109": -109,
|
||||
"-110": -110,
|
||||
"-111": -111,
|
||||
"-112": -112,
|
||||
"-113": -113,
|
||||
"-114": -114,
|
||||
"-115": -115,
|
||||
"-116": -116,
|
||||
"-117": -117,
|
||||
"-118": -118,
|
||||
"-119": -119,
|
||||
"-120": -120,
|
||||
"-121": -121,
|
||||
"-122": -122,
|
||||
"-123": -123,
|
||||
"-124": -124,
|
||||
"-125": -125,
|
||||
"-126": -126,
|
||||
"-127": -127,
|
||||
"-128": -128,
|
||||
"-129": -129,
|
||||
"-130": -130,
|
||||
"-131": -131,
|
||||
"-132": -132,
|
||||
"-133": -133,
|
||||
"-134": -134,
|
||||
"-135": -135,
|
||||
"-136": -136,
|
||||
"-137": -137,
|
||||
"-138": -138,
|
||||
"-139": -139,
|
||||
"-140": -140,
|
||||
"-141": -141,
|
||||
"-142": -142,
|
||||
"-143": -143,
|
||||
"-144": -144,
|
||||
"-145": -145,
|
||||
"-146": -146,
|
||||
"-147": -147,
|
||||
"-148": -148,
|
||||
"-149": -149,
|
||||
"-150": -150,
|
||||
"-151": -151,
|
||||
"-152": -152,
|
||||
"-153": -153,
|
||||
"-154": -154,
|
||||
"-155": -155,
|
||||
"-156": -156,
|
||||
"-157": -157,
|
||||
"-159": -159,
|
||||
"-160": -160,
|
||||
"-161": -161,
|
||||
"-162": -162,
|
||||
"-163": -163,
|
||||
"-164": -164,
|
||||
"-165": -165,
|
||||
"-166": -166,
|
||||
"-167": -167,
|
||||
"-168": -168,
|
||||
"-169": -169,
|
||||
"-170": -170,
|
||||
"-171": -171,
|
||||
"-172": -172,
|
||||
"-173": -173,
|
||||
"-174": -174,
|
||||
"-175": -175,
|
||||
"-176": -176,
|
||||
"-177": -177,
|
||||
"-178": -178,
|
||||
"-179": -179,
|
||||
"-180": -180,
|
||||
"-181": -181,
|
||||
"-182": -182,
|
||||
"-183": -183,
|
||||
"-184": -184,
|
||||
"-185": -185,
|
||||
"-186": -186,
|
||||
"-187": -187,
|
||||
"-188": -188,
|
||||
"-189": -189,
|
||||
"-190": -190,
|
||||
"-191": -191,
|
||||
"-192": -192,
|
||||
"-193": -193,
|
||||
"-194": -194,
|
||||
"-195": -195,
|
||||
"-196": -196,
|
||||
"-197": -197,
|
||||
"-198": -198,
|
||||
"-199": -199,
|
||||
"-200": -200,
|
||||
"-201": -201,
|
||||
"-202": -202,
|
||||
"-203": -203,
|
||||
"-204": -204,
|
||||
"-206": -206,
|
||||
"-207": -207,
|
||||
"-208": -208,
|
||||
"-209": -209,
|
||||
"-210": -210,
|
||||
"-211": -211,
|
||||
"-213": -213,
|
||||
"-214": -214,
|
||||
"0": 0,
|
||||
"1": 1,
|
||||
"2": 2,
|
||||
"3": 3,
|
||||
"4": 4,
|
||||
"5": 5,
|
||||
"6": 6,
|
||||
"7": 7,
|
||||
"8": 8,
|
||||
"9": 9,
|
||||
"10": 10,
|
||||
"11": 11,
|
||||
"12": 12,
|
||||
"13": 13,
|
||||
"14": 14,
|
||||
"15": 15,
|
||||
"16": 16,
|
||||
"17": 17,
|
||||
"18": 18,
|
||||
"19": 19,
|
||||
"20": 20,
|
||||
"21": 21,
|
||||
"22": 22,
|
||||
"23": 23,
|
||||
"24": 24,
|
||||
"25": 25,
|
||||
"26": 26,
|
||||
"27": 27,
|
||||
"28": 28,
|
||||
"29": 29,
|
||||
"30": 30,
|
||||
"31": 31,
|
||||
"32": 32,
|
||||
"33": 33,
|
||||
"34": 34,
|
||||
"35": 35,
|
||||
"36": 36,
|
||||
"37": 37,
|
||||
"38": 38,
|
||||
"39": 39,
|
||||
"40": 40,
|
||||
"41": 41,
|
||||
"42": 42,
|
||||
"43": 43,
|
||||
"44": 44,
|
||||
"45": 45,
|
||||
"46": 46,
|
||||
"47": 47,
|
||||
"48": 48,
|
||||
"49": 49,
|
||||
"50": 50,
|
||||
"51": 51,
|
||||
"52": 52,
|
||||
"53": 53,
|
||||
"54": 54,
|
||||
"55": 55,
|
||||
"56": 56,
|
||||
"57": 57,
|
||||
"58": 58,
|
||||
"59": 59,
|
||||
"60": 60,
|
||||
"61": 61,
|
||||
"62": 62,
|
||||
"63": 63,
|
||||
"64": 64,
|
||||
"65": 65,
|
||||
"66": 66,
|
||||
"67": 67,
|
||||
"68": 68,
|
||||
"69": 69,
|
||||
"70": 70,
|
||||
"71": 71,
|
||||
"72": 72,
|
||||
"73": 73,
|
||||
"74": 74,
|
||||
"75": 75,
|
||||
"76": 76,
|
||||
"77": 77,
|
||||
"78": 78,
|
||||
"79": 79,
|
||||
"80": 80,
|
||||
"81": 81,
|
||||
"82": 82,
|
||||
"83": 83,
|
||||
"84": 84,
|
||||
"85": 85,
|
||||
"86": 86,
|
||||
"87": 87,
|
||||
"88": 88,
|
||||
"89": 89,
|
||||
"90": 90,
|
||||
"91": 91,
|
||||
"92": 92,
|
||||
"93": 93,
|
||||
"94": 94,
|
||||
"95": 95,
|
||||
"96": 96,
|
||||
"97": 97,
|
||||
"98": 98,
|
||||
"99": 99,
|
||||
"100": 100,
|
||||
"101": 101,
|
||||
"102": 102,
|
||||
"103": 103,
|
||||
"104": 104,
|
||||
"105": 105,
|
||||
"106": 106,
|
||||
"107": 107,
|
||||
"108": 108,
|
||||
"109": 109,
|
||||
"110": 110,
|
||||
"111": 111,
|
||||
"112": 112,
|
||||
"113": 113,
|
||||
"114": 114,
|
||||
"115": 115,
|
||||
"116": 116,
|
||||
"117": 117,
|
||||
"118": 118,
|
||||
"119": 119,
|
||||
"120": 120,
|
||||
"121": 121,
|
||||
"122": 122,
|
||||
"123": 123,
|
||||
"124": 124,
|
||||
"125": 125,
|
||||
"126": 126,
|
||||
"127": 127,
|
||||
"128": 128,
|
||||
"129": 129,
|
||||
"130": 130,
|
||||
"131": 131,
|
||||
"132": 132,
|
||||
"133": 133,
|
||||
"134": 134,
|
||||
"135": 135,
|
||||
"136": 136,
|
||||
"137": 137,
|
||||
"138": 138,
|
||||
"139": 139,
|
||||
"140": 140,
|
||||
"141": 141,
|
||||
"142": 142,
|
||||
"143": 143,
|
||||
"144": 144,
|
||||
"145": 145,
|
||||
"146": 146,
|
||||
"147": 147,
|
||||
"148": 148,
|
||||
"149": 149,
|
||||
"150": 150,
|
||||
"151": 151,
|
||||
"152": 152,
|
||||
"153": 153,
|
||||
"154": 154,
|
||||
"155": 155,
|
||||
"156": 156,
|
||||
"157": 157,
|
||||
"158": 158,
|
||||
"159": 159,
|
||||
"160": 160,
|
||||
"161": 161,
|
||||
"162": 162,
|
||||
"163": 163,
|
||||
"164": 164,
|
||||
"165": 165,
|
||||
"166": 166,
|
||||
"167": 167,
|
||||
"168": 168,
|
||||
"169": 169,
|
||||
"170": 170,
|
||||
"171": 171,
|
||||
"172": 172,
|
||||
"173": 173,
|
||||
"174": 174,
|
||||
"175": 175,
|
||||
"176": 176,
|
||||
"177": 177,
|
||||
"178": 178,
|
||||
"179": 179,
|
||||
"180": 180,
|
||||
"181": 181,
|
||||
"182": 182,
|
||||
"183": 183,
|
||||
"184": 184,
|
||||
"185": 185,
|
||||
"186": 186,
|
||||
"187": 187,
|
||||
"188": 188,
|
||||
"189": 189,
|
||||
"190": 190,
|
||||
"191": 191,
|
||||
"192": 192,
|
||||
"193": 193,
|
||||
"194": 194,
|
||||
"195": 195,
|
||||
"196": 196,
|
||||
"197": 197,
|
||||
"198": 198,
|
||||
"199": 199,
|
||||
"200": 200,
|
||||
"201": 201,
|
||||
"202": 202,
|
||||
"203": 203,
|
||||
"204": 204,
|
||||
"205": 205,
|
||||
"206": 206,
|
||||
"207": 207,
|
||||
"208": 208,
|
||||
"209": 209,
|
||||
"213": 213,
|
||||
"214": 214,
|
||||
"215": 215,
|
||||
"216": 216,
|
||||
"218": 218,
|
||||
"219": 219,
|
||||
"220": 220,
|
||||
"221": 221,
|
||||
"222": 222,
|
||||
"223": 223,
|
||||
"224": 224,
|
||||
"225": 225,
|
||||
"226": 226,
|
||||
"227": 227,
|
||||
"228": 228,
|
||||
"229": 229,
|
||||
"231": 231,
|
||||
"232": 232,
|
||||
"233": 233,
|
||||
"234": 234,
|
||||
"235": 235,
|
||||
"236": 236,
|
||||
"237": 237,
|
||||
"238": 238,
|
||||
"239": 239,
|
||||
"240": 240,
|
||||
"241": 241,
|
||||
"243": 243,
|
||||
"244": 244,
|
||||
"245": 245,
|
||||
"246": 246,
|
||||
"247": 247,
|
||||
"248": 248,
|
||||
"249": 249,
|
||||
"250": 250,
|
||||
"251": 251,
|
||||
"252": 252,
|
||||
"253": 253,
|
||||
"254": 254,
|
||||
"255": 255,
|
||||
"256": 256,
|
||||
"257": 257,
|
||||
"258": 258,
|
||||
"259": 259,
|
||||
"260": 260,
|
||||
"261": 261,
|
||||
"262": 262,
|
||||
"263": 263,
|
||||
"264": 264,
|
||||
"265": 265,
|
||||
"266": 266,
|
||||
"267": 267,
|
||||
"268": 268,
|
||||
"269": 269,
|
||||
"270": 270,
|
||||
"271": 271,
|
||||
"272": 272,
|
||||
"273": 273,
|
||||
"274": 274,
|
||||
"275": 275,
|
||||
"276": 276,
|
||||
"277": 277,
|
||||
"278": 278,
|
||||
"279": 279,
|
||||
"280": 280,
|
||||
"281": 281,
|
||||
"282": 282,
|
||||
"283": 283,
|
||||
"284": 284,
|
||||
"285": 285,
|
||||
"286": 286,
|
||||
"287": 287,
|
||||
"288": 288,
|
||||
"289": 289,
|
||||
"290": 290,
|
||||
"291": 291,
|
||||
"292": 292,
|
||||
"293": 293,
|
||||
"294": 294,
|
||||
"295": 295,
|
||||
"296": 296,
|
||||
"297": 297,
|
||||
"298": 298,
|
||||
"299": 299,
|
||||
"300": 300,
|
||||
"301": 301,
|
||||
"302": 302,
|
||||
"303": 303,
|
||||
"304": 304,
|
||||
"305": 305,
|
||||
"306": 306,
|
||||
"307": 307,
|
||||
"308": 308,
|
||||
"309": 309,
|
||||
"310": 310,
|
||||
"311": 311,
|
||||
"312": 312,
|
||||
"313": 313,
|
||||
"314": 314,
|
||||
"315": 315,
|
||||
"316": 316,
|
||||
"317": 317,
|
||||
"318": 318,
|
||||
"319": 319,
|
||||
"320": 320,
|
||||
"321": 321,
|
||||
"322": 322,
|
||||
"323": 323,
|
||||
"324": 324,
|
||||
"325": 325,
|
||||
"328": 328,
|
||||
"329": 329,
|
||||
"330": 330,
|
||||
"331": 331,
|
||||
"332": 332,
|
||||
"333": 333,
|
||||
"334": 334,
|
||||
"335": 335,
|
||||
"336": 336,
|
||||
"337": 337,
|
||||
"338": 338,
|
||||
"339": 339,
|
||||
"340": 340,
|
||||
"341": 341,
|
||||
"342": 342,
|
||||
"344": 344,
|
||||
"345": 345,
|
||||
"346": 346,
|
||||
"347": 347,
|
||||
"348": 348,
|
||||
"349": 349,
|
||||
"350": 350,
|
||||
"351": 351,
|
||||
"352": 352,
|
||||
"353": 353,
|
||||
"354": 354,
|
||||
"355": 355,
|
||||
"356": 356,
|
||||
"357": 357,
|
||||
"358": 358,
|
||||
"359": 359,
|
||||
"360": 360,
|
||||
"361": 361,
|
||||
"362": 362,
|
||||
"363": 363,
|
||||
"364": 364,
|
||||
"365": 365,
|
||||
"366": 366,
|
||||
"367": 367,
|
||||
"368": 368,
|
||||
"369": 369,
|
||||
"370": 370,
|
||||
"371": 371,
|
||||
"372": 372,
|
||||
"373": 373,
|
||||
"374": 374,
|
||||
"375": 375,
|
||||
"376": 376,
|
||||
"377": 377,
|
||||
"378": 378,
|
||||
"379": 379,
|
||||
"380": 380,
|
||||
"381": 381,
|
||||
"382": 382,
|
||||
"383": 383,
|
||||
"384": 384,
|
||||
"385": 385,
|
||||
"386": 386,
|
||||
"387": 387,
|
||||
"388": 388,
|
||||
"389": 389,
|
||||
"390": 390,
|
||||
"391": 391,
|
||||
"392": 392,
|
||||
"393": 393,
|
||||
"394": 394,
|
||||
"395": 395,
|
||||
"396": 396,
|
||||
"397": 397,
|
||||
"398": 398,
|
||||
"399": 399,
|
||||
"400": 400,
|
||||
"401": 401,
|
||||
"402": 402,
|
||||
"403": 403,
|
||||
"404": 404,
|
||||
"405": 405,
|
||||
"406": 406,
|
||||
"407": 407,
|
||||
"408": 408,
|
||||
"409": 409,
|
||||
"410": 410,
|
||||
"411": 411,
|
||||
"412": 412,
|
||||
"413": 413,
|
||||
"414": 414,
|
||||
"415": 415,
|
||||
"416": 416,
|
||||
"417": 417,
|
||||
"418": 418,
|
||||
"419": 419,
|
||||
"420": 420,
|
||||
"421": 421,
|
||||
"422": 422,
|
||||
"423": 423,
|
||||
"424": 424,
|
||||
"425": 425,
|
||||
"426": 426,
|
||||
"427": 427,
|
||||
"428": 428,
|
||||
"429": 429,
|
||||
"430": 430,
|
||||
"431": 431,
|
||||
"432": 432,
|
||||
"433": 433,
|
||||
"434": 434,
|
||||
"437": 437,
|
||||
"438": 438,
|
||||
"441": 441,
|
||||
"442": 442,
|
||||
"443": 443,
|
||||
"444": 444,
|
||||
"445": 445,
|
||||
"446": 446,
|
||||
"447": 447,
|
||||
"448": 448,
|
||||
"449": 449,
|
||||
"450": 450,
|
||||
"451": 451,
|
||||
"452": 452,
|
||||
"453": 453,
|
||||
"455": 455,
|
||||
"457": 457,
|
||||
"458": 458,
|
||||
"459": 459,
|
||||
"460": 460,
|
||||
"461": 461,
|
||||
"462": 462,
|
||||
"463": 463,
|
||||
"464": 464,
|
||||
"465": 465,
|
||||
"466": 466,
|
||||
"467": 467,
|
||||
"468": 468,
|
||||
"469": 469,
|
||||
"470": 470,
|
||||
"471": 471,
|
||||
"472": 472,
|
||||
"473": 473,
|
||||
"474": 474,
|
||||
"475": 475,
|
||||
"476": 476,
|
||||
"477": 477,
|
||||
"499": 499,
|
||||
"500": 500,
|
||||
"501": 501,
|
||||
"502": 502,
|
||||
"503": 503,
|
||||
"504": 504,
|
||||
"505": 505,
|
||||
"506": 506,
|
||||
"507": 507,
|
||||
"508": 508,
|
||||
"509": 509,
|
||||
"510": 510,
|
||||
"511": 511,
|
||||
"513": 513,
|
||||
"acacia_button": -140,
|
||||
"acacia_door": 430,
|
||||
"acacia_door_block": 196,
|
||||
@ -226,27 +913,16 @@
|
||||
"egg": 344,
|
||||
"element_0": 36,
|
||||
"element_1": -12,
|
||||
"element_2": -13,
|
||||
"element_3": -14,
|
||||
"element_4": -15,
|
||||
"element_5": -16,
|
||||
"element_6": -17,
|
||||
"element_7": -18,
|
||||
"element_8": -19,
|
||||
"element_9": -20,
|
||||
"element_10": -21,
|
||||
"element_100": -111,
|
||||
"element_101": -112,
|
||||
"element_102": -113,
|
||||
"element_103": -114,
|
||||
"element_104": -115,
|
||||
"element_105": -116,
|
||||
"element_106": -117,
|
||||
"element_107": -118,
|
||||
"element_108": -119,
|
||||
"element_109": -120,
|
||||
"element_11": -22,
|
||||
"element_110": -121,
|
||||
"element_111": -122,
|
||||
"element_112": -123,
|
||||
"element_113": -124,
|
||||
"element_114": -125,
|
||||
"element_115": -126,
|
||||
"element_116": -127,
|
||||
"element_117": -128,
|
||||
"element_118": -129,
|
||||
"element_12": -23,
|
||||
"element_13": -24,
|
||||
"element_14": -25,
|
||||
@ -255,7 +931,6 @@
|
||||
"element_17": -28,
|
||||
"element_18": -29,
|
||||
"element_19": -30,
|
||||
"element_2": -13,
|
||||
"element_20": -31,
|
||||
"element_21": -32,
|
||||
"element_22": -33,
|
||||
@ -266,7 +941,6 @@
|
||||
"element_27": -38,
|
||||
"element_28": -39,
|
||||
"element_29": -40,
|
||||
"element_3": -14,
|
||||
"element_30": -41,
|
||||
"element_31": -42,
|
||||
"element_32": -43,
|
||||
@ -277,7 +951,6 @@
|
||||
"element_37": -48,
|
||||
"element_38": -49,
|
||||
"element_39": -50,
|
||||
"element_4": -15,
|
||||
"element_40": -51,
|
||||
"element_41": -52,
|
||||
"element_42": -53,
|
||||
@ -288,7 +961,6 @@
|
||||
"element_47": -58,
|
||||
"element_48": -59,
|
||||
"element_49": -60,
|
||||
"element_5": -16,
|
||||
"element_50": -61,
|
||||
"element_51": -62,
|
||||
"element_52": -63,
|
||||
@ -299,7 +971,6 @@
|
||||
"element_57": -68,
|
||||
"element_58": -69,
|
||||
"element_59": -70,
|
||||
"element_6": -17,
|
||||
"element_60": -71,
|
||||
"element_61": -72,
|
||||
"element_62": -73,
|
||||
@ -310,7 +981,6 @@
|
||||
"element_67": -78,
|
||||
"element_68": -79,
|
||||
"element_69": -80,
|
||||
"element_7": -18,
|
||||
"element_70": -81,
|
||||
"element_71": -82,
|
||||
"element_72": -83,
|
||||
@ -321,7 +991,6 @@
|
||||
"element_77": -88,
|
||||
"element_78": -89,
|
||||
"element_79": -90,
|
||||
"element_8": -19,
|
||||
"element_80": -91,
|
||||
"element_81": -92,
|
||||
"element_82": -93,
|
||||
@ -332,7 +1001,6 @@
|
||||
"element_87": -98,
|
||||
"element_88": -99,
|
||||
"element_89": -100,
|
||||
"element_9": -20,
|
||||
"element_90": -101,
|
||||
"element_91": -102,
|
||||
"element_92": -103,
|
||||
@ -343,6 +1011,25 @@
|
||||
"element_97": -108,
|
||||
"element_98": -109,
|
||||
"element_99": -110,
|
||||
"element_100": -111,
|
||||
"element_101": -112,
|
||||
"element_102": -113,
|
||||
"element_103": -114,
|
||||
"element_104": -115,
|
||||
"element_105": -116,
|
||||
"element_106": -117,
|
||||
"element_107": -118,
|
||||
"element_108": -119,
|
||||
"element_109": -120,
|
||||
"element_110": -121,
|
||||
"element_111": -122,
|
||||
"element_112": -123,
|
||||
"element_113": -124,
|
||||
"element_114": -125,
|
||||
"element_115": -126,
|
||||
"element_116": -127,
|
||||
"element_117": -128,
|
||||
"element_118": -129,
|
||||
"elytra": 444,
|
||||
"emerald": 388,
|
||||
"emerald_block": 133,
|
||||
@ -532,8 +1219,8 @@
|
||||
"leather_pants": 300,
|
||||
"leather_tunic": 299,
|
||||
"leave": 18,
|
||||
"leaves": 18,
|
||||
"leave2": 161,
|
||||
"leaves": 18,
|
||||
"leaves2": 161,
|
||||
"lectern": -194,
|
||||
"lever": 69,
|
||||
|
Submodule resources/locale updated: 4a322da43e...09c709f242
Submodule resources/vanilla updated: 19569dd729...f29b7be8fa
@ -35,3 +35,4 @@ define('pocketmine\_CORE_CONSTANTS_INCLUDED', true);
|
||||
|
||||
define('pocketmine\PATH', dirname(__DIR__) . '/');
|
||||
define('pocketmine\RESOURCE_PATH', dirname(__DIR__) . '/resources/');
|
||||
define('pocketmine\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__) . '/vendor/autoload.php');
|
||||
|
@ -101,9 +101,12 @@ class CrashDump{
|
||||
/** @var string */
|
||||
private $path;
|
||||
|
||||
public function __construct(Server $server){
|
||||
private ?PluginManager $pluginManager;
|
||||
|
||||
public function __construct(Server $server, ?PluginManager $pluginManager){
|
||||
$this->time = microtime(true);
|
||||
$this->server = $server;
|
||||
$this->pluginManager = $pluginManager;
|
||||
|
||||
$crashPath = Path::join($this->server->getDataPath(), "crashdumps");
|
||||
if(!is_dir($crashPath)){
|
||||
@ -166,11 +169,11 @@ class CrashDump{
|
||||
}
|
||||
|
||||
private function pluginsData() : void{
|
||||
if($this->server->getPluginManager() instanceof PluginManager){
|
||||
if($this->pluginManager !== null){
|
||||
$plugins = $this->pluginManager->getPlugins();
|
||||
$this->addLine();
|
||||
$this->addLine("Loaded plugins:");
|
||||
$this->data["plugins"] = [];
|
||||
$plugins = $this->server->getPluginManager()->getPlugins();
|
||||
ksort($plugins, SORT_STRING);
|
||||
foreach($plugins as $p){
|
||||
$d = $p->getDescription();
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine;
|
||||
|
||||
use pocketmine\event\server\LowMemoryEvent;
|
||||
use pocketmine\network\mcpe\cache\ChunkCache;
|
||||
use pocketmine\scheduler\DumpWorkerMemoryTask;
|
||||
use pocketmine\scheduler\GarbageCollectionTask;
|
||||
use pocketmine\timings\Timings;
|
||||
@ -187,6 +188,7 @@ class MemoryManager{
|
||||
foreach($this->server->getWorldManager()->getWorlds() as $world){
|
||||
$world->clearCache(true);
|
||||
}
|
||||
ChunkCache::pruneCaches();
|
||||
}
|
||||
|
||||
if($this->lowMemChunkGC){
|
||||
|
@ -126,6 +126,9 @@ namespace pocketmine {
|
||||
if(version_compare($leveldb_version, "0.2.1") < 0){
|
||||
$messages[] = "php-leveldb >= 0.2.1 is required, while you have $leveldb_version.";
|
||||
}
|
||||
if(!defined('LEVELDB_ZLIB_RAW_COMPRESSION')){
|
||||
$messages[] = "Given version of php-leveldb doesn't support ZLIB_RAW compression (use https://github.com/pmmp/php-leveldb)";
|
||||
}
|
||||
}
|
||||
|
||||
$chunkutils2_version = phpversion("chunkutils2");
|
||||
@ -214,20 +217,13 @@ JIT_WARNING
|
||||
error_reporting(-1);
|
||||
set_ini_entries();
|
||||
|
||||
$opts = getopt("", ["bootstrap:"]);
|
||||
if(isset($opts["bootstrap"])){
|
||||
$bootstrap = ($real = realpath($opts["bootstrap"])) !== false ? $real : $opts["bootstrap"];
|
||||
}else{
|
||||
$bootstrap = dirname(__FILE__, 2) . '/vendor/autoload.php';
|
||||
}
|
||||
|
||||
if($bootstrap === false or !is_file($bootstrap)){
|
||||
$bootstrap = dirname(__FILE__, 2) . '/vendor/autoload.php';
|
||||
if(!is_file($bootstrap)){
|
||||
critical_error("Composer autoloader not found at " . $bootstrap);
|
||||
critical_error("Please install/update Composer dependencies or use provided builds.");
|
||||
exit(1);
|
||||
}
|
||||
define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap);
|
||||
require_once(\pocketmine\COMPOSER_AUTOLOADER_PATH);
|
||||
require_once($bootstrap);
|
||||
|
||||
$composerGitHash = InstalledVersions::getReference('pocketmine/pocketmine-mp');
|
||||
if($composerGitHash !== null){
|
||||
@ -307,7 +303,7 @@ JIT_WARNING
|
||||
|
||||
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||
$logger->debug("Some threads could not be stopped, performing a force-kill");
|
||||
Process::kill(Process::pid());
|
||||
Process::kill(Process::pid(), true);
|
||||
}
|
||||
}while(false);
|
||||
|
||||
|
259
src/Server.php
259
src/Server.php
@ -40,6 +40,7 @@ use pocketmine\entity\Location;
|
||||
use pocketmine\event\HandlerListManager;
|
||||
use pocketmine\event\player\PlayerCreationEvent;
|
||||
use pocketmine\event\player\PlayerDataSaveEvent;
|
||||
use pocketmine\event\player\PlayerLoginEvent;
|
||||
use pocketmine\event\server\CommandEvent;
|
||||
use pocketmine\event\server\DataPacketSendEvent;
|
||||
use pocketmine\event\server\QueryRegenerateEvent;
|
||||
@ -97,6 +98,7 @@ use pocketmine\utils\NotCloneable;
|
||||
use pocketmine\utils\NotSerializable;
|
||||
use pocketmine\utils\Process;
|
||||
use pocketmine\utils\Promise;
|
||||
use pocketmine\utils\SignalHandler;
|
||||
use pocketmine\utils\Terminal;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\utils\Utils;
|
||||
@ -105,24 +107,22 @@ use pocketmine\world\format\io\WorldProviderManager;
|
||||
use pocketmine\world\format\io\WritableWorldProviderManagerEntry;
|
||||
use pocketmine\world\generator\Generator;
|
||||
use pocketmine\world\generator\GeneratorManager;
|
||||
use pocketmine\world\generator\InvalidGeneratorOptionsException;
|
||||
use pocketmine\world\World;
|
||||
use pocketmine\world\WorldCreationOptions;
|
||||
use pocketmine\world\WorldManager;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
use Webmozart\PathUtil\Path;
|
||||
use function array_shift;
|
||||
use function array_sum;
|
||||
use function base64_encode;
|
||||
use function cli_set_process_title;
|
||||
use function copy;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function file_exists;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function filemtime;
|
||||
use function get_class;
|
||||
use function implode;
|
||||
use function ini_set;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
@ -251,6 +251,8 @@ class Server{
|
||||
/** @var Player[] */
|
||||
private array $playerList = [];
|
||||
|
||||
private SignalHandler $signalHandler;
|
||||
|
||||
/**
|
||||
* @var CommandSender[][]
|
||||
* @phpstan-var array<string, array<int, CommandSender>>
|
||||
@ -744,6 +746,11 @@ class Server{
|
||||
$this->autoloader = $autoloader;
|
||||
$this->logger = $logger;
|
||||
|
||||
$this->signalHandler = new SignalHandler(function() : void{
|
||||
$this->logger->info("Received signal interrupt, stopping the server");
|
||||
$this->shutdown();
|
||||
});
|
||||
|
||||
try{
|
||||
foreach([
|
||||
$dataPath,
|
||||
@ -966,91 +973,16 @@ class Server{
|
||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||
$this->enablePlugins(PluginEnableOrder::STARTUP());
|
||||
|
||||
foreach((array) $this->configGroup->getProperty("worlds", []) as $name => $options){
|
||||
if($options === null){
|
||||
$options = [];
|
||||
}elseif(!is_array($options)){
|
||||
continue;
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($name, true)){
|
||||
$creationOptions = WorldCreationOptions::create();
|
||||
//TODO: error checking
|
||||
|
||||
if(isset($options["generator"])){
|
||||
$generatorOptions = explode(":", $options["generator"]);
|
||||
$creationOptions->setGeneratorClass(GeneratorManager::getInstance()->getGenerator(array_shift($generatorOptions)));
|
||||
if(count($generatorOptions) > 0){
|
||||
$creationOptions->setGeneratorOptions(implode(":", $generatorOptions));
|
||||
}
|
||||
}
|
||||
if(isset($options["difficulty"]) && is_string($options["difficulty"])){
|
||||
$creationOptions->setDifficulty(World::getDifficultyFromString($options["difficulty"]));
|
||||
}
|
||||
if(isset($options["preset"]) && is_string($options["preset"])){
|
||||
$creationOptions->setGeneratorOptions($options["preset"]);
|
||||
}
|
||||
if(isset($options["seed"])){
|
||||
$convertedSeed = Generator::convertSeed((string) ($options["seed"] ?? ""));
|
||||
if($convertedSeed !== null){
|
||||
$creationOptions->setSeed($convertedSeed);
|
||||
}
|
||||
}
|
||||
|
||||
$this->worldManager->generateWorld($name, $creationOptions);
|
||||
}
|
||||
if(!$this->startupPrepareWorlds()){
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->worldManager->getDefaultWorld() === null){
|
||||
$default = $this->configGroup->getConfigString("level-name", "world");
|
||||
if(trim($default) == ""){
|
||||
$this->getLogger()->warning("level-name cannot be null, using default");
|
||||
$default = "world";
|
||||
$this->configGroup->setConfigString("level-name", "world");
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($default, true)){
|
||||
$creationOptions = WorldCreationOptions::create()
|
||||
->setGeneratorClass(GeneratorManager::getInstance()->getGenerator($this->configGroup->getConfigString("level-type")))
|
||||
->setGeneratorOptions($this->configGroup->getConfigString("generator-settings"));
|
||||
$convertedSeed = Generator::convertSeed($this->configGroup->getConfigString("level-seed"));
|
||||
if($convertedSeed !== null){
|
||||
$creationOptions->setSeed($convertedSeed);
|
||||
}
|
||||
$this->worldManager->generateWorld($default, $creationOptions);
|
||||
}
|
||||
|
||||
$world = $this->worldManager->getWorldByName($default);
|
||||
if($world === null){
|
||||
$this->getLogger()->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_defaultError()));
|
||||
$this->forceShutdown();
|
||||
|
||||
return;
|
||||
}
|
||||
$this->worldManager->setDefaultWorld($world);
|
||||
}
|
||||
|
||||
$this->enablePlugins(PluginEnableOrder::POSTWORLD());
|
||||
|
||||
$useQuery = $this->configGroup->getConfigBool("enable-query", true);
|
||||
if(!$this->network->registerInterface(new RakLibInterface($this)) && $useQuery){
|
||||
//RakLib would normally handle the transport for Query packets
|
||||
//if it's not registered we need to make sure Query still works
|
||||
$this->network->registerInterface(new DedicatedQueryNetworkInterface($this->getIp(), $this->getPort(), new \PrefixedLogger($this->logger, "Dedicated Query Interface")));
|
||||
}
|
||||
$this->logger->info($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_networkStart($this->getIp(), (string) $this->getPort())));
|
||||
|
||||
if($useQuery){
|
||||
$this->network->registerRawPacketHandler(new QueryHandler($this));
|
||||
if(!$this->startupPrepareNetworkInterfaces()){
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($this->getIPBans()->getEntries() as $entry){
|
||||
$this->network->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
if($this->configGroup->getPropertyBool("network.upnp-forwarding", false)){
|
||||
$this->network->registerInterface(new UPnPNetworkInterface($this->logger, Internet::getInternalIP(), $this->getPort()));
|
||||
}
|
||||
|
||||
if($this->configGroup->getPropertyBool("settings.send-usage", true)){
|
||||
if($this->configGroup->getPropertyBool("anonymous-statistics.enabled", true)){
|
||||
$this->sendUsageTicker = 6000;
|
||||
$this->sendUsage(SendUsageTask::TYPE_OPEN);
|
||||
}
|
||||
@ -1085,6 +1017,123 @@ class Server{
|
||||
}
|
||||
}
|
||||
|
||||
private function startupPrepareWorlds() : bool{
|
||||
$getGenerator = function(string $generatorName, string $generatorOptions, string $worldName) : ?string{
|
||||
$generatorEntry = GeneratorManager::getInstance()->getGenerator($generatorName);
|
||||
if($generatorEntry === null){
|
||||
$this->logger->error($this->language->translate(KnownTranslationFactory::pocketmine_level_generationError(
|
||||
$worldName,
|
||||
KnownTranslationFactory::pocketmine_level_unknownGenerator($generatorName)
|
||||
)));
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
$generatorEntry->validateGeneratorOptions($generatorOptions);
|
||||
}catch(InvalidGeneratorOptionsException $e){
|
||||
$this->logger->error($this->language->translate(KnownTranslationFactory::pocketmine_level_generationError(
|
||||
$worldName,
|
||||
KnownTranslationFactory::pocketmine_level_invalidGeneratorOptions($generatorOptions, $generatorName, $e->getMessage())
|
||||
)));
|
||||
return null;
|
||||
}
|
||||
return $generatorEntry->getGeneratorClass();
|
||||
};
|
||||
|
||||
foreach((array) $this->configGroup->getProperty("worlds", []) as $name => $options){
|
||||
if($options === null){
|
||||
$options = [];
|
||||
}elseif(!is_array($options)){
|
||||
continue;
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($name, true) && !$this->worldManager->isWorldGenerated($name)){
|
||||
$creationOptions = WorldCreationOptions::create();
|
||||
//TODO: error checking
|
||||
|
||||
$generatorName = $options["generator"] ?? "default";
|
||||
$generatorOptions = isset($options["preset"]) && is_string($options["preset"]) ? $options["preset"] : "";
|
||||
|
||||
$generatorClass = $getGenerator($generatorName, $generatorOptions, $name);
|
||||
if($generatorClass === null){
|
||||
continue;
|
||||
}
|
||||
$creationOptions->setGeneratorClass($generatorClass);
|
||||
$creationOptions->setGeneratorOptions($generatorOptions);
|
||||
|
||||
if(isset($options["difficulty"]) && is_string($options["difficulty"])){
|
||||
$creationOptions->setDifficulty(World::getDifficultyFromString($options["difficulty"]));
|
||||
}
|
||||
|
||||
if(isset($options["seed"])){
|
||||
$convertedSeed = Generator::convertSeed((string) ($options["seed"] ?? ""));
|
||||
if($convertedSeed !== null){
|
||||
$creationOptions->setSeed($convertedSeed);
|
||||
}
|
||||
}
|
||||
|
||||
$this->worldManager->generateWorld($name, $creationOptions);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->worldManager->getDefaultWorld() === null){
|
||||
$default = $this->configGroup->getConfigString("level-name", "world");
|
||||
if(trim($default) == ""){
|
||||
$this->getLogger()->warning("level-name cannot be null, using default");
|
||||
$default = "world";
|
||||
$this->configGroup->setConfigString("level-name", "world");
|
||||
}
|
||||
if(!$this->worldManager->loadWorld($default, true) && !$this->worldManager->isWorldGenerated($default)){
|
||||
$generatorName = $this->configGroup->getConfigString("level-type");
|
||||
$generatorOptions = $this->configGroup->getConfigString("generator-settings");
|
||||
$generatorClass = $getGenerator($generatorName, $generatorOptions, $default);
|
||||
if($generatorClass !== null){
|
||||
$creationOptions = WorldCreationOptions::create()
|
||||
->setGeneratorClass($generatorClass)
|
||||
->setGeneratorOptions($generatorOptions);
|
||||
$convertedSeed = Generator::convertSeed($this->configGroup->getConfigString("level-seed"));
|
||||
if($convertedSeed !== null){
|
||||
$creationOptions->setSeed($convertedSeed);
|
||||
}
|
||||
$this->worldManager->generateWorld($default, $creationOptions);
|
||||
}
|
||||
}
|
||||
|
||||
$world = $this->worldManager->getWorldByName($default);
|
||||
if($world === null){
|
||||
$this->getLogger()->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_level_defaultError()));
|
||||
$this->forceShutdown();
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->worldManager->setDefaultWorld($world);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function startupPrepareNetworkInterfaces() : bool{
|
||||
$useQuery = $this->configGroup->getConfigBool("enable-query", true);
|
||||
if(!$this->network->registerInterface(new RakLibInterface($this)) && $useQuery){
|
||||
//RakLib would normally handle the transport for Query packets
|
||||
//if it's not registered we need to make sure Query still works
|
||||
$this->network->registerInterface(new DedicatedQueryNetworkInterface($this->getIp(), $this->getPort(), new \PrefixedLogger($this->logger, "Dedicated Query Interface")));
|
||||
}
|
||||
$this->logger->info($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_networkStart($this->getIp(), (string) $this->getPort())));
|
||||
|
||||
if($useQuery){
|
||||
$this->network->registerRawPacketHandler(new QueryHandler($this));
|
||||
}
|
||||
|
||||
foreach($this->getIPBans()->getEntries() as $entry){
|
||||
$this->network->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
if($this->configGroup->getPropertyBool("network.upnp-forwarding", false)){
|
||||
$this->network->registerInterface(new UPnPNetworkInterface($this->logger, Internet::getInternalIP(), $this->getPort()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to a particular message broadcast channel.
|
||||
* The channel ID can be any arbitrary string.
|
||||
@ -1293,20 +1342,17 @@ class Server{
|
||||
$commandLine = $ev->getCommand();
|
||||
}
|
||||
|
||||
if($this->commandMap->dispatch($sender, $commandLine)){
|
||||
return true;
|
||||
}
|
||||
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_generic_notFound()->prefix(TextFormat::RED));
|
||||
|
||||
return false;
|
||||
return $this->commandMap->dispatch($sender, $commandLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts the server down correctly
|
||||
*/
|
||||
public function shutdown() : void{
|
||||
$this->isRunning = false;
|
||||
if($this->isRunning){
|
||||
$this->isRunning = false;
|
||||
$this->signalHandler->unregister();
|
||||
}
|
||||
}
|
||||
|
||||
public function forceShutdown() : void{
|
||||
@ -1371,7 +1417,7 @@ class Server{
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->logException($e);
|
||||
$this->logger->emergency("Crashed while crashing, killing process");
|
||||
@Process::kill(Process::pid());
|
||||
@Process::kill(Process::pid(), true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1430,7 +1476,7 @@ class Server{
|
||||
ini_set("memory_limit", '-1'); //Fix error dump not dumped on memory problems
|
||||
try{
|
||||
$this->logger->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_crash_create()));
|
||||
$dump = new CrashDump($this);
|
||||
$dump = new CrashDump($this, $this->pluginManager ?? null);
|
||||
|
||||
$this->logger->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_crash_submit($dump->getPath())));
|
||||
|
||||
@ -1501,7 +1547,7 @@ class Server{
|
||||
echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL;
|
||||
sleep($spacing);
|
||||
}
|
||||
@Process::kill(Process::pid());
|
||||
@Process::kill(Process::pid(), true);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1527,7 +1573,28 @@ class Server{
|
||||
}
|
||||
}
|
||||
|
||||
public function addOnlinePlayer(Player $player) : void{
|
||||
public function addOnlinePlayer(Player $player) : bool{
|
||||
$ev = new PlayerLoginEvent($player, "Plugin reason");
|
||||
$ev->call();
|
||||
if($ev->isCancelled() or !$player->isConnected()){
|
||||
$player->disconnect($ev->getKickMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$session = $player->getNetworkSession();
|
||||
$position = $player->getPosition();
|
||||
$this->logger->info($this->language->translate(KnownTranslationFactory::pocketmine_player_logIn(
|
||||
TextFormat::AQUA . $player->getName() . TextFormat::WHITE,
|
||||
$session->getIp(),
|
||||
(string) $session->getPort(),
|
||||
(string) $player->getId(),
|
||||
$position->getWorld()->getDisplayName(),
|
||||
(string) round($position->x, 4),
|
||||
(string) round($position->y, 4),
|
||||
(string) round($position->z, 4)
|
||||
)));
|
||||
|
||||
foreach($this->playerList as $p){
|
||||
$p->getNetworkSession()->onPlayerAdded($player);
|
||||
}
|
||||
@ -1537,6 +1604,8 @@ class Server{
|
||||
if($this->sendUsageTicker > 0){
|
||||
$this->uniquePlayers[$rawUUID] = $rawUUID;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function removeOnlinePlayer(Player $player) : void{
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\utils\Config;
|
||||
use function array_key_exists;
|
||||
use function getopt;
|
||||
use function is_bool;
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
use function strtolower;
|
||||
|
||||
final class ServerConfigGroup{
|
||||
@ -110,16 +112,20 @@ final class ServerConfigGroup{
|
||||
}else{
|
||||
$value = $this->serverProperties->exists($variable) ? $this->serverProperties->get($variable) : $defaultValue;
|
||||
}
|
||||
|
||||
if(is_bool($value)){
|
||||
return $value;
|
||||
}
|
||||
switch(strtolower($value)){
|
||||
case "on":
|
||||
case "true":
|
||||
case "1":
|
||||
case "yes":
|
||||
return true;
|
||||
if(is_int($value)){
|
||||
return $value !== 0;
|
||||
}
|
||||
if(is_string($value)){
|
||||
switch(strtolower($value)){
|
||||
case "on":
|
||||
case "true":
|
||||
case "1":
|
||||
case "yes":
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -29,7 +29,7 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
public const BASE_VERSION = "4.0.0-BETA3";
|
||||
public const BASE_VERSION = "4.0.0-BETA8";
|
||||
public const IS_DEVELOPMENT_BUILD = false;
|
||||
public const BUILD_NUMBER = 0;
|
||||
public const BUILD_CHANNEL = "beta";
|
||||
|
@ -115,7 +115,7 @@ class Bamboo extends Transparent{
|
||||
return 12 + (self::getOffsetSeed($x, 0, $z) % 5);
|
||||
}
|
||||
|
||||
public function getPositionOffset() : ?Vector3{
|
||||
public function getModelPositionOffset() : ?Vector3{
|
||||
$seed = self::getOffsetSeed($this->position->getFloorX(), 0, $this->position->getFloorZ());
|
||||
$retX = (($seed % 12) + 1) / 16;
|
||||
$retZ = ((($seed >> 8) % 12) + 1) / 16;
|
||||
@ -145,12 +145,12 @@ class Bamboo extends Transparent{
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($item instanceof Fertilizer){
|
||||
$top = $this->seekToTop();
|
||||
if($top->grow(self::getMaxHeight($top->position->getFloorX(), $top->position->getFloorZ()), mt_rand(1, 2))){
|
||||
if($top->grow(self::getMaxHeight($top->position->getFloorX(), $top->position->getFloorZ()), mt_rand(1, 2), $player)){
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
}elseif($item instanceof ItemBamboo){
|
||||
if($this->seekToTop()->grow(PHP_INT_MAX, 1)){
|
||||
if($this->seekToTop()->grow(PHP_INT_MAX, 1, $player)){
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
@ -165,7 +165,7 @@ class Bamboo extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
private function grow(int $maxHeight, int $growAmount) : bool{
|
||||
private function grow(int $maxHeight, int $growAmount, ?Player $player) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$world->getBlock($this->position->up())->canBeReplaced()){
|
||||
return false;
|
||||
@ -212,7 +212,7 @@ class Bamboo extends Transparent{
|
||||
$tx->addBlock($this->position->subtract(0, $idx - $growAmount, 0), $newBlock);
|
||||
}
|
||||
|
||||
$ev = new StructureGrowEvent($this, $tx);
|
||||
$ev = new StructureGrowEvent($this, $tx, $player);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
@ -229,7 +229,7 @@ class Bamboo extends Transparent{
|
||||
$world = $this->position->getWorld();
|
||||
if($this->ready){
|
||||
$this->ready = false;
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow(self::getMaxHeight($this->position->getFloorX(), $this->position->getFloorZ()), 1)){
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow(self::getMaxHeight($this->position->getFloorX(), $this->position->getFloorZ()), 1, null)){
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
}elseif($world->getBlock($this->position->up())->canBeReplaced()){
|
||||
|
@ -73,7 +73,7 @@ final class BambooSapling extends Flowable{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($item instanceof Fertilizer || $item instanceof ItemBamboo){
|
||||
if($this->grow()){
|
||||
if($this->grow($player)){
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
@ -87,7 +87,7 @@ final class BambooSapling extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
private function grow() : bool{
|
||||
private function grow(?Player $player) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
if(!$world->getBlock($this->position->up())->canBeReplaced()){
|
||||
return false;
|
||||
@ -98,7 +98,7 @@ final class BambooSapling extends Flowable{
|
||||
$tx->addBlock($this->position, $bamboo)
|
||||
->addBlock($this->position->up(), (clone $bamboo)->setLeafSize(Bamboo::SMALL_LEAVES));
|
||||
|
||||
$ev = new StructureGrowEvent($this, $tx);
|
||||
$ev = new StructureGrowEvent($this, $tx, $player);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
@ -115,7 +115,7 @@ final class BambooSapling extends Flowable{
|
||||
$world = $this->position->getWorld();
|
||||
if($this->ready){
|
||||
$this->ready = false;
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow()){
|
||||
if($world->getFullLight($this->position) < 9 || !$this->grow(null)){
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
}elseif($world->getBlock($this->position->up())->canBeReplaced()){
|
||||
|
@ -37,8 +37,6 @@ use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\BellRingSound;
|
||||
|
||||
final class Bell extends Transparent{
|
||||
private const BELL_RINGING_REPEAT_TICKS = 20;
|
||||
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
private BellAttachmentType $attachmentType;
|
||||
|
@ -179,7 +179,7 @@ class Block{
|
||||
* Returns whether the given block has the same type and properties as this block.
|
||||
*/
|
||||
public function isSameState(Block $other) : bool{
|
||||
return $this->isSameType($other) and $this->writeStateToMeta() === $other->writeStateToMeta();
|
||||
return $this->getFullId() === $other->getFullId();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -577,7 +577,7 @@ class Block{
|
||||
final public function getCollisionBoxes() : array{
|
||||
if($this->collisionBoxes === null){
|
||||
$this->collisionBoxes = $this->recalculateCollisionBoxes();
|
||||
$extraOffset = $this->getPositionOffset();
|
||||
$extraOffset = $this->getModelPositionOffset();
|
||||
$offset = $extraOffset !== null ? $this->position->addVector($extraOffset) : $this->position;
|
||||
foreach($this->collisionBoxes as $bb){
|
||||
$bb->offset($offset->x, $offset->y, $offset->z);
|
||||
@ -588,10 +588,10 @@ class Block{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an additional fractional vector to shift the block's effective position by based on the current position.
|
||||
* Returns an additional fractional vector to shift the block model's position by based on the current position.
|
||||
* Used to randomize position of things like bamboo canes and tall grass.
|
||||
*/
|
||||
public function getPositionOffset() : ?Vector3{
|
||||
public function getModelPositionOffset() : ?Vector3{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -183,6 +183,7 @@ class BlockFactory{
|
||||
$this->register(new EnderChest(new BID(Ids::ENDER_CHEST, 0, null, TileEnderChest::class), "Ender Chest", new BlockBreakInfo(22.5, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 3000.0)));
|
||||
$this->register(new Farmland(new BID(Ids::FARMLAND, 0), "Farmland", new BlockBreakInfo(0.6, BlockToolType::SHOVEL)));
|
||||
$this->register(new Fire(new BID(Ids::FIRE, 0), "Fire Block", BlockBreakInfo::instant()));
|
||||
$this->register(new FletchingTable(new BID(Ids::FLETCHING_TABLE, 0), "Fletching Table", new BlockBreakInfo(2.5, BlockToolType::AXE, 0, 2.5)));
|
||||
$this->register(new Flower(new BID(Ids::DANDELION, 0), "Dandelion", BlockBreakInfo::instant()));
|
||||
$this->register(new Flower(new BID(Ids::RED_FLOWER, Meta::FLOWER_ALLIUM), "Allium", BlockBreakInfo::instant()));
|
||||
$this->register(new Flower(new BID(Ids::RED_FLOWER, Meta::FLOWER_AZURE_BLUET), "Azure Bluet", BlockBreakInfo::instant()));
|
||||
@ -402,6 +403,7 @@ class BlockFactory{
|
||||
$this->registerSlabWithDoubleHighBitsRemapping(new Slab(BlockLegacyIdHelper::getStoneSlabIdentifier(4, Meta::STONE_SLAB4_STONE), "Stone", $stoneSlabBreakInfo));
|
||||
$this->register(new Opaque(new BID(Ids::STONECUTTER, 0), "Stonecutter", new BlockBreakInfo(3.5, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));
|
||||
$this->register(new Sugarcane(new BID(Ids::REEDS_BLOCK, 0, ItemIds::REEDS), "Sugarcane", BlockBreakInfo::instant()));
|
||||
$this->register(new SweetBerryBush(new BID(Ids::SWEET_BERRY_BUSH, 0, ItemIds::SWEET_BERRIES), "Sweet Berry Bush", BlockBreakInfo::instant()));
|
||||
$this->register(new TNT(new BID(Ids::TNT, 0), "TNT", BlockBreakInfo::instant()));
|
||||
|
||||
$fern = new TallGrass(new BID(Ids::TALLGRASS, Meta::TALLGRASS_FERN), "Fern", BlockBreakInfo::instant(BlockToolType::SHEARS, 1));
|
||||
@ -567,7 +569,6 @@ class BlockFactory{
|
||||
//TODO: minecraft:dropper
|
||||
//TODO: minecraft:end_gateway
|
||||
//TODO: minecraft:end_portal
|
||||
//TODO: minecraft:fletching_table
|
||||
//TODO: minecraft:grindstone
|
||||
//TODO: minecraft:jigsaw
|
||||
//TODO: minecraft:kelp
|
||||
@ -584,7 +585,6 @@ class BlockFactory{
|
||||
//TODO: minecraft:sticky_piston
|
||||
//TODO: minecraft:stonecutter_block
|
||||
//TODO: minecraft:structure_block
|
||||
$this->register(new SweetBerryBush(new BID(Ids::SWEET_BERRY_BUSH, 0, ItemIds::SWEET_BERRIES), "Sweet Berry Bush", BlockBreakInfo::instant()));
|
||||
//TODO: minecraft:turtle_egg
|
||||
//endregion
|
||||
|
||||
@ -952,7 +952,7 @@ class BlockFactory{
|
||||
* Deserializes a block from the provided legacy ID and legacy meta.
|
||||
*/
|
||||
public function get(int $id, int $meta) : Block{
|
||||
if($meta < 0 or $meta > (1 << Block::INTERNAL_METADATA_BITS)){
|
||||
if($meta < 0 or $meta >= (1 << Block::INTERNAL_METADATA_BITS)){
|
||||
throw new \InvalidArgumentException("Block meta value $meta is out of bounds");
|
||||
}
|
||||
|
||||
|
30
src/block/FletchingTable.php
Normal file
30
src/block/FletchingTable.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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;
|
||||
|
||||
class FletchingTable extends Opaque{
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -23,50 +23,72 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\RedstonePowerOffSound;
|
||||
use pocketmine\world\sound\RedstonePowerOnSound;
|
||||
|
||||
class Lever extends Flowable{
|
||||
protected const BOTTOM = 0;
|
||||
protected const SIDE = 1;
|
||||
protected const TOP = 2;
|
||||
protected LeverFacing $facing;
|
||||
protected bool $activated = false;
|
||||
|
||||
protected int $leverPos = self::BOTTOM;
|
||||
protected int $facing = Facing::NORTH;
|
||||
protected bool $powered = false;
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->facing = LeverFacing::UP_AXIS_X();
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
if($this->leverPos === self::BOTTOM){
|
||||
$rotationMeta = Facing::axis($this->facing) === Axis::Z ? 7 : 0;
|
||||
}elseif($this->leverPos === self::TOP){
|
||||
$rotationMeta = Facing::axis($this->facing) === Axis::Z ? 5 : 6;
|
||||
}else{
|
||||
$rotationMeta = 6 - BlockDataSerializer::writeHorizontalFacing($this->facing);
|
||||
}
|
||||
return $rotationMeta | ($this->powered ? BlockLegacyMetadata::LEVER_FLAG_POWERED : 0);
|
||||
$rotationMeta = match($this->facing->id()){
|
||||
LeverFacing::DOWN_AXIS_X()->id() => 0,
|
||||
LeverFacing::EAST()->id() => 1,
|
||||
LeverFacing::WEST()->id() => 2,
|
||||
LeverFacing::SOUTH()->id() => 3,
|
||||
LeverFacing::NORTH()->id() => 4,
|
||||
LeverFacing::UP_AXIS_Z()->id() => 5,
|
||||
LeverFacing::UP_AXIS_X()->id() => 6,
|
||||
LeverFacing::DOWN_AXIS_Z()->id() => 7,
|
||||
default => throw new AssumptionFailedError(),
|
||||
};
|
||||
return $rotationMeta | ($this->activated ? BlockLegacyMetadata::LEVER_FLAG_POWERED : 0);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$rotationMeta = $stateMeta & 0x07;
|
||||
if($rotationMeta === 5 or $rotationMeta === 6){
|
||||
$this->leverPos = self::TOP;
|
||||
$this->facing = $rotationMeta === 5 ? Facing::SOUTH : Facing::EAST;
|
||||
}elseif($rotationMeta === 7 or $rotationMeta === 0){
|
||||
$this->leverPos = self::BOTTOM;
|
||||
$this->facing = $rotationMeta === 7 ? Facing::SOUTH : Facing::EAST;
|
||||
}else{
|
||||
$this->leverPos = self::SIDE;
|
||||
$this->facing = BlockDataSerializer::readHorizontalFacing(6 - $rotationMeta);
|
||||
}
|
||||
$this->facing = match($rotationMeta){
|
||||
0 => LeverFacing::DOWN_AXIS_X(),
|
||||
1 => LeverFacing::EAST(),
|
||||
2 => LeverFacing::WEST(),
|
||||
3 => LeverFacing::SOUTH(),
|
||||
4 => LeverFacing::NORTH(),
|
||||
5 => LeverFacing::UP_AXIS_Z(),
|
||||
6 => LeverFacing::UP_AXIS_X(),
|
||||
7 => LeverFacing::DOWN_AXIS_Z(),
|
||||
default => throw new AssumptionFailedError("0x07 mask should make this impossible"), //phpstan doesn't understand :(
|
||||
};
|
||||
|
||||
$this->powered = ($stateMeta & BlockLegacyMetadata::LEVER_FLAG_POWERED) !== 0;
|
||||
$this->activated = ($stateMeta & BlockLegacyMetadata::LEVER_FLAG_POWERED) !== 0;
|
||||
}
|
||||
|
||||
public function getFacing() : LeverFacing{ return $this->facing; }
|
||||
|
||||
/** @return $this */
|
||||
public function setFacing(LeverFacing $facing) : self{
|
||||
$this->facing = $facing;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isActivated() : bool{ return $this->activated; }
|
||||
|
||||
/** @return $this */
|
||||
public function setActivated(bool $activated) : self{
|
||||
$this->activated = $activated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
@ -78,39 +100,37 @@ class Lever extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Facing::axis($face) === Axis::Y){
|
||||
$selectUpDownPos = function(LeverFacing $x, LeverFacing $z) use ($player) : LeverFacing{
|
||||
if($player !== null){
|
||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||
return Facing::axis($player->getHorizontalFacing()) === Axis::X ? $x : $z;
|
||||
}
|
||||
$this->leverPos = $face === Facing::DOWN ? self::BOTTOM : self::TOP;
|
||||
}else{
|
||||
$this->facing = $face;
|
||||
$this->leverPos = self::SIDE;
|
||||
}
|
||||
return $x;
|
||||
};
|
||||
$this->facing = match($face){
|
||||
Facing::DOWN => $selectUpDownPos(LeverFacing::DOWN_AXIS_X(), LeverFacing::DOWN_AXIS_Z()),
|
||||
Facing::UP => $selectUpDownPos(LeverFacing::UP_AXIS_X(), LeverFacing::UP_AXIS_Z()),
|
||||
Facing::NORTH => LeverFacing::NORTH(),
|
||||
Facing::SOUTH => LeverFacing::SOUTH(),
|
||||
Facing::WEST => LeverFacing::WEST(),
|
||||
Facing::EAST => LeverFacing::EAST(),
|
||||
default => throw new AssumptionFailedError("Bad facing value"),
|
||||
};
|
||||
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->leverPos === self::BOTTOM){
|
||||
$face = Facing::UP;
|
||||
}elseif($this->leverPos === self::TOP){
|
||||
$face = Facing::DOWN;
|
||||
}else{
|
||||
$face = Facing::opposite($this->facing);
|
||||
}
|
||||
|
||||
if(!$this->getSide($face)->isSolid()){
|
||||
if(!$this->getSide(Facing::opposite($this->facing->getFacing()))->isSolid()){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->powered = !$this->powered;
|
||||
$this->activated = !$this->activated;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
$this->position->getWorld()->addSound(
|
||||
$this->position->add(0.5, 0.5, 0.5),
|
||||
$this->powered ? new RedstonePowerOnSound() : new RedstonePowerOffSound()
|
||||
$this->activated ? new RedstonePowerOnSound() : new RedstonePowerOffSound()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class Sapling extends Flowable{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($item instanceof Fertilizer){
|
||||
$this->grow();
|
||||
$this->grow($player);
|
||||
|
||||
$item->pop();
|
||||
|
||||
@ -100,7 +100,7 @@ class Sapling extends Flowable{
|
||||
public function onRandomTick() : void{
|
||||
if($this->position->getWorld()->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 and mt_rand(1, 7) === 1){
|
||||
if($this->ready){
|
||||
$this->grow();
|
||||
$this->grow(null);
|
||||
}else{
|
||||
$this->ready = true;
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
@ -108,7 +108,7 @@ class Sapling extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
private function grow() : void{
|
||||
private function grow(?Player $player) : void{
|
||||
$random = new Random(mt_rand());
|
||||
$tree = TreeFactory::get($random, $this->treeType);
|
||||
$transaction = $tree?->getBlockTransaction($this->position->getWorld(), $this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ(), $random);
|
||||
@ -116,13 +116,11 @@ class Sapling extends Flowable{
|
||||
return;
|
||||
}
|
||||
|
||||
$ev = new StructureGrowEvent($this, $transaction);
|
||||
$ev = new StructureGrowEvent($this, $transaction, $player);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
if(!$ev->isCancelled()){
|
||||
$transaction->apply();
|
||||
}
|
||||
|
||||
$transaction->apply();
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
|
@ -300,6 +300,7 @@ use function assert;
|
||||
* @method static Farmland FARMLAND()
|
||||
* @method static TallGrass FERN()
|
||||
* @method static Fire FIRE()
|
||||
* @method static FletchingTable FLETCHING_TABLE()
|
||||
* @method static FlowerPot FLOWER_POT()
|
||||
* @method static FrostedIce FROSTED_ICE()
|
||||
* @method static Furnace FURNACE()
|
||||
@ -866,6 +867,7 @@ final class VanillaBlocks{
|
||||
self::register("farmland", $factory->get(60, 0));
|
||||
self::register("fern", $factory->get(31, 2));
|
||||
self::register("fire", $factory->get(51, 0));
|
||||
self::register("fletching_table", $factory->get(456, 0));
|
||||
self::register("flower_pot", $factory->get(140, 0));
|
||||
self::register("frosted_ice", $factory->get(207, 0));
|
||||
self::register("furnace", $factory->get(61, 2));
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\block\inventory;
|
||||
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\sound\ChestCloseSound;
|
||||
use pocketmine\world\sound\ChestOpenSound;
|
||||
@ -50,6 +51,6 @@ class ChestInventory extends SimpleInventory implements BlockInventory{
|
||||
$holder = $this->getHolder();
|
||||
|
||||
//event ID is always 1 for a chest
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(1, $isOpen ? 1 : 0, $holder->asVector3()));
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ use pocketmine\inventory\DelegateInventory;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\PlayerEnderInventory;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\sound\EnderChestCloseSound;
|
||||
@ -74,7 +75,7 @@ class EnderChestInventory extends DelegateInventory implements BlockInventory{
|
||||
$holder = $this->getHolder();
|
||||
|
||||
//event ID is always 1 for a chest
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(1, $isOpen ? 1 : 0, $holder->asVector3()));
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0));
|
||||
}
|
||||
|
||||
public function onClose(Player $who) : void{
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\inventory\SimpleInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\sound\ShulkerBoxCloseSound;
|
||||
use pocketmine\world\sound\ShulkerBoxOpenSound;
|
||||
@ -59,6 +60,6 @@ class ShulkerBoxInventory extends SimpleInventory implements BlockInventory{
|
||||
$holder = $this->getHolder();
|
||||
|
||||
//event ID is always 1 for a chest
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(1, $isOpen ? 1 : 0, $holder->asVector3()));
|
||||
$holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
|
||||
|
||||
final class Bell extends Spawnable{
|
||||
@ -81,6 +82,6 @@ final class Bell extends Spawnable{
|
||||
$nbt->setByte(self::TAG_RINGING, 1);
|
||||
$nbt->setInt(self::TAG_DIRECTION, BlockDataSerializer::writeLegacyHorizontalFacing($bellHitFace));
|
||||
$nbt->setInt(self::TAG_TICKS, 0);
|
||||
return BlockActorDataPacket::create($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ(), new CacheableNbt($nbt));
|
||||
return BlockActorDataPacket::create(BlockPosition::fromVector3($this->position), new CacheableNbt($nbt));
|
||||
}
|
||||
}
|
||||
|
67
src/block/utils/LeverFacing.php
Normal file
67
src/block/utils/LeverFacing.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?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\utils;
|
||||
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\utils\EnumTrait;
|
||||
|
||||
/**
|
||||
* This doc-block is generated automatically, do not modify it manually.
|
||||
* This must be regenerated whenever registry members are added, removed or changed.
|
||||
* @see build/generate-registry-annotations.php
|
||||
* @generate-registry-docblock
|
||||
*
|
||||
* @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()
|
||||
*/
|
||||
final class LeverFacing{
|
||||
use EnumTrait {
|
||||
__construct as Enum___construct;
|
||||
}
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("up_axis_x", Facing::UP),
|
||||
new self("up_axis_z", Facing::UP),
|
||||
new self("down_axis_x", Facing::DOWN),
|
||||
new self("down_axis_z", Facing::DOWN),
|
||||
new self("north", Facing::NORTH),
|
||||
new self("east", Facing::EAST),
|
||||
new self("south", Facing::SOUTH),
|
||||
new self("west", Facing::WEST),
|
||||
);
|
||||
}
|
||||
|
||||
private function __construct(string $enumName, private int $facing){
|
||||
$this->Enum___construct($enumName);
|
||||
}
|
||||
|
||||
public function getFacing() : int{ return $this->facing; }
|
||||
}
|
@ -25,7 +25,7 @@ namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\lang\Translatable;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||
use pocketmine\utils\EnumTrait;
|
||||
|
||||
/**
|
||||
@ -54,18 +54,18 @@ final class RecordType{
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new RecordType("disk_13", "C418 - 13", LevelSoundEventPacket::SOUND_RECORD_13, KnownTranslationFactory::item_record_13_desc()),
|
||||
new RecordType("disk_cat", "C418 - cat", LevelSoundEventPacket::SOUND_RECORD_CAT, KnownTranslationFactory::item_record_cat_desc()),
|
||||
new RecordType("disk_blocks", "C418 - blocks", LevelSoundEventPacket::SOUND_RECORD_BLOCKS, KnownTranslationFactory::item_record_blocks_desc()),
|
||||
new RecordType("disk_chirp", "C418 - chirp", LevelSoundEventPacket::SOUND_RECORD_CHIRP, KnownTranslationFactory::item_record_chirp_desc()),
|
||||
new RecordType("disk_far", "C418 - far", LevelSoundEventPacket::SOUND_RECORD_FAR, KnownTranslationFactory::item_record_far_desc()),
|
||||
new RecordType("disk_mall", "C418 - mall", LevelSoundEventPacket::SOUND_RECORD_MALL, KnownTranslationFactory::item_record_mall_desc()),
|
||||
new RecordType("disk_mellohi", "C418 - mellohi", LevelSoundEventPacket::SOUND_RECORD_MELLOHI, KnownTranslationFactory::item_record_mellohi_desc()),
|
||||
new RecordType("disk_stal", "C418 - stal", LevelSoundEventPacket::SOUND_RECORD_STAL, KnownTranslationFactory::item_record_stal_desc()),
|
||||
new RecordType("disk_strad", "C418 - strad", LevelSoundEventPacket::SOUND_RECORD_STRAD, KnownTranslationFactory::item_record_strad_desc()),
|
||||
new RecordType("disk_ward", "C418 - ward", LevelSoundEventPacket::SOUND_RECORD_WARD, KnownTranslationFactory::item_record_ward_desc()),
|
||||
new RecordType("disk_11", "C418 - 11", LevelSoundEventPacket::SOUND_RECORD_11, KnownTranslationFactory::item_record_11_desc()),
|
||||
new RecordType("disk_wait", "C418 - wait", LevelSoundEventPacket::SOUND_RECORD_WAIT, KnownTranslationFactory::item_record_wait_desc())
|
||||
new RecordType("disk_13", "C418 - 13", LevelSoundEvent::RECORD_13, KnownTranslationFactory::item_record_13_desc()),
|
||||
new RecordType("disk_cat", "C418 - cat", LevelSoundEvent::RECORD_CAT, KnownTranslationFactory::item_record_cat_desc()),
|
||||
new RecordType("disk_blocks", "C418 - blocks", LevelSoundEvent::RECORD_BLOCKS, KnownTranslationFactory::item_record_blocks_desc()),
|
||||
new RecordType("disk_chirp", "C418 - chirp", LevelSoundEvent::RECORD_CHIRP, KnownTranslationFactory::item_record_chirp_desc()),
|
||||
new RecordType("disk_far", "C418 - far", LevelSoundEvent::RECORD_FAR, KnownTranslationFactory::item_record_far_desc()),
|
||||
new RecordType("disk_mall", "C418 - mall", LevelSoundEvent::RECORD_MALL, KnownTranslationFactory::item_record_mall_desc()),
|
||||
new RecordType("disk_mellohi", "C418 - mellohi", LevelSoundEvent::RECORD_MELLOHI, KnownTranslationFactory::item_record_mellohi_desc()),
|
||||
new RecordType("disk_stal", "C418 - stal", LevelSoundEvent::RECORD_STAL, KnownTranslationFactory::item_record_stal_desc()),
|
||||
new RecordType("disk_strad", "C418 - strad", LevelSoundEvent::RECORD_STRAD, KnownTranslationFactory::item_record_strad_desc()),
|
||||
new RecordType("disk_ward", "C418 - ward", LevelSoundEvent::RECORD_WARD, KnownTranslationFactory::item_record_ward_desc()),
|
||||
new RecordType("disk_11", "C418 - 11", LevelSoundEvent::RECORD_11, KnownTranslationFactory::item_record_11_desc()),
|
||||
new RecordType("disk_wait", "C418 - wait", LevelSoundEvent::RECORD_WAIT, KnownTranslationFactory::item_record_wait_desc())
|
||||
//TODO: Lena Raine - Pigstep
|
||||
);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ abstract class Command{
|
||||
}
|
||||
|
||||
if($this->permissionMessage === null){
|
||||
$target->sendMessage(KnownTranslationFactory::commands_generic_permission()->prefix(TextFormat::RED));
|
||||
$target->sendMessage(KnownTranslationFactory::pocketmine_command_error_permission($this->name)->prefix(TextFormat::RED));
|
||||
}elseif($this->permissionMessage !== ""){
|
||||
$target->sendMessage(str_replace("<permission>", $permission ?? $this->permission, $this->permissionMessage));
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ use pocketmine\command\defaults\WhitelistCommand;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use function array_shift;
|
||||
use function count;
|
||||
use function explode;
|
||||
@ -210,26 +211,23 @@ class SimpleCommandMap implements CommandMap{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sentCommandLabel = array_shift($args);
|
||||
if($sentCommandLabel === null){
|
||||
return false;
|
||||
}
|
||||
$target = $this->getCommand($sentCommandLabel);
|
||||
if($target === null){
|
||||
return false;
|
||||
if($sentCommandLabel !== null && ($target = $this->getCommand($sentCommandLabel)) !== null){
|
||||
$target->timings->startTiming();
|
||||
|
||||
try{
|
||||
$target->execute($sender, $sentCommandLabel, $args);
|
||||
}catch(InvalidCommandSyntaxException $e){
|
||||
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage())));
|
||||
}finally{
|
||||
$target->timings->stopTiming();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$target->timings->startTiming();
|
||||
|
||||
try{
|
||||
$target->execute($sender, $sentCommandLabel, $args);
|
||||
}catch(InvalidCommandSyntaxException $e){
|
||||
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage())));
|
||||
}finally{
|
||||
$target->timings->stopTiming();
|
||||
}
|
||||
|
||||
return true;
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($sentCommandLabel ?? "", "/help")->prefix(TextFormat::RED));
|
||||
return false;
|
||||
}
|
||||
|
||||
public function clearCommands() : void{
|
||||
|
@ -53,7 +53,7 @@ class DefaultGamemodeCommand extends VanillaCommand{
|
||||
|
||||
$gameMode = GameMode::fromString($args[0]);
|
||||
if($gameMode === null){
|
||||
$sender->sendMessage("Unknown game mode");
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_unknown($args[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class GamemodeCommand extends VanillaCommand{
|
||||
|
||||
$gameMode = GameMode::fromString($args[0]);
|
||||
if($gameMode === null){
|
||||
$sender->sendMessage("Unknown game mode");
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_unknown($args[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class GamemodeCommand extends VanillaCommand{
|
||||
|
||||
$target->setGamemode($gameMode);
|
||||
if(!$gameMode->equals($target->getGamemode())){
|
||||
$sender->sendMessage("Game mode change for " . $target->getName() . " failed!");
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_failure($target->getName()));
|
||||
}else{
|
||||
if($target === $sender){
|
||||
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_gamemode_success_self($gameMode->getTranslatableName()));
|
||||
|
@ -68,7 +68,7 @@ class GarbageCollectorCommand extends VanillaCommand{
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gc_entities(TextFormat::RED . number_format($entitiesCollected))->prefix(TextFormat::GOLD));
|
||||
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gc_cycles(TextFormat::RED . number_format($cyclesCollected))->prefix(TextFormat::GOLD));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gc_memoryFreed(TextFormat::RED . number_format(round((($memory - memory_get_usage()) / 1024) / 1024, 2), 2) . " MB")->prefix(TextFormat::GOLD));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gc_memoryFreed(TextFormat::RED . number_format(round((($memory - memory_get_usage()) / 1024) / 1024, 2), 2))->prefix(TextFormat::GOLD));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ use pocketmine\item\StringToItemParser;
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\nbt\JsonNbtParser;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\permission\DefaultPermissionNames;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use function array_slice;
|
||||
@ -86,7 +87,12 @@ class GiveCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
$item->setNamedTag($tags);
|
||||
try{
|
||||
$item->setNamedTag($tags);
|
||||
}catch(NbtException $e){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_give_tagError($e->getMessage()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: overflow
|
||||
|
@ -105,17 +105,20 @@ class HelpCommand extends VanillaCommand{
|
||||
$lang = $sender->getLanguage();
|
||||
$description = $cmd->getDescription();
|
||||
$descriptionString = $description instanceof Translatable ? $lang->translate($description) : $description;
|
||||
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n";
|
||||
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $descriptionString . "\n";
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_header($commandName)
|
||||
->format(TextFormat::YELLOW . "--------- " . TextFormat::WHITE, TextFormat::YELLOW . " ---------"));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_description(TextFormat::WHITE . $descriptionString)
|
||||
->prefix(TextFormat::GOLD));
|
||||
|
||||
$usage = $cmd->getUsage();
|
||||
$usageString = $usage instanceof Translatable ? $lang->translate($usage) : $usage;
|
||||
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $usageString)) . "\n";
|
||||
$sender->sendMessage($message);
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_usage(TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $usageString)))
|
||||
->prefix(TextFormat::GOLD));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$sender->sendMessage(TextFormat::RED . "No help for " . strtolower($commandName));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($commandName, "/help")->prefix(TextFormat::RED));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class TeleportCommand extends VanillaCommand{
|
||||
$x = $this->getRelativeDouble($base->x, $sender, $targetArgs[0]);
|
||||
$y = $this->getRelativeDouble($base->y, $sender, $targetArgs[1], 0, 256);
|
||||
$z = $this->getRelativeDouble($base->z, $sender, $targetArgs[2]);
|
||||
$targetLocation = new Location($x, $y, $z, $yaw, $pitch, $base->getWorld());
|
||||
$targetLocation = new Location($x, $y, $z, $base->getWorld(), $yaw, $pitch);
|
||||
|
||||
$subject->teleport($targetLocation);
|
||||
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_tp_success_coordinates(
|
||||
|
@ -39,6 +39,7 @@ use function stream_socket_accept;
|
||||
use function stream_socket_get_name;
|
||||
use function stream_socket_server;
|
||||
use function stream_socket_shutdown;
|
||||
use function trim;
|
||||
use const PHP_BINARY;
|
||||
use const STREAM_SHUT_RDWR;
|
||||
|
||||
@ -113,7 +114,7 @@ final class ConsoleReaderThread extends Thread{
|
||||
break;
|
||||
}
|
||||
|
||||
$buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $command);
|
||||
$buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($command));
|
||||
if($notifier !== null){
|
||||
$notifier->wakeupSleeper();
|
||||
}
|
||||
|
@ -681,10 +681,12 @@ abstract class Entity{
|
||||
throw new \InvalidArgumentException("Fire ticks must be in range 0 ... " . 0x7fff . ", got $fireTicks");
|
||||
}
|
||||
$this->fireTicks = $fireTicks;
|
||||
$this->networkPropertiesDirty = true;
|
||||
}
|
||||
|
||||
public function extinguish() : void{
|
||||
$this->fireTicks = 0;
|
||||
$this->networkPropertiesDirty = true;
|
||||
}
|
||||
|
||||
public function isFireProof() : bool{
|
||||
@ -1183,9 +1185,9 @@ abstract class Entity{
|
||||
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,
|
||||
$this->boundingBox->minY - $this->ySize,
|
||||
($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2,
|
||||
$this->location->world,
|
||||
$this->location->yaw,
|
||||
$this->location->pitch,
|
||||
$this->location->world
|
||||
$this->location->pitch
|
||||
);
|
||||
|
||||
$this->getWorld()->onEntityMoved($this);
|
||||
@ -1416,23 +1418,27 @@ abstract class Entity{
|
||||
* Called by spawnTo() to send whatever packets needed to spawn the entity to the client.
|
||||
*/
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddActorPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->type = static::getNetworkTypeId();
|
||||
$pk->position = $this->location->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->yaw = $this->location->yaw;
|
||||
$pk->headYaw = $this->location->yaw; //TODO
|
||||
$pk->pitch = $this->location->pitch;
|
||||
$pk->attributes = array_map(function(Attribute $attr) : NetworkAttribute{
|
||||
return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue());
|
||||
}, $this->attributeMap->getAll());
|
||||
$pk->metadata = $this->getAllNetworkData();
|
||||
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
$player->getNetworkSession()->sendDataPacket(AddActorPacket::create(
|
||||
$this->getId(), //TODO: actor unique ID
|
||||
$this->getId(),
|
||||
static::getNetworkTypeId(),
|
||||
$this->location->asVector3(),
|
||||
$this->getMotion(),
|
||||
$this->location->pitch,
|
||||
$this->location->yaw,
|
||||
$this->location->yaw, //TODO: head yaw
|
||||
array_map(function(Attribute $attr) : NetworkAttribute{
|
||||
return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue());
|
||||
}, $this->attributeMap->getAll()),
|
||||
$this->getAllNetworkData(),
|
||||
[] //TODO: entity links
|
||||
));
|
||||
}
|
||||
|
||||
public function spawnTo(Player $player) : void{
|
||||
if($player->getWorld() !== $this->getWorld()){
|
||||
throw new \InvalidArgumentException("Player is not in the same world");
|
||||
}
|
||||
$id = spl_object_id($player);
|
||||
//TODO: this will cause some visible lag during chunk resends; if the player uses a spawn egg in a chunk, the
|
||||
//created entity won't be visible until after the resend arrives. However, this is better than possibly crashing
|
||||
|
@ -47,8 +47,10 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\convert\SkinAdapterSingleton;
|
||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\DeviceOS;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\StringMetadataProperty;
|
||||
@ -145,7 +147,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
*/
|
||||
public function sendSkin(?array $targets = null) : void{
|
||||
$this->server->broadcastPackets($targets ?? $this->hasSpawned, [
|
||||
PlayerSkinPacket::create($this->getUniqueId(), SkinAdapterSingleton::get()->toSkinData($this->skin))
|
||||
PlayerSkinPacket::create($this->getUniqueId(), "", "", SkinAdapterSingleton::get()->toSkinData($this->skin))
|
||||
]);
|
||||
}
|
||||
|
||||
@ -444,17 +446,24 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
$player->getNetworkSession()->sendDataPacket(PlayerListPacket::add([PlayerListEntry::createAdditionEntry($this->uuid, $this->id, $this->getName(), SkinAdapterSingleton::get()->toSkinData($this->skin))]));
|
||||
}
|
||||
|
||||
$pk = new AddPlayerPacket();
|
||||
$pk->uuid = $this->getUniqueId();
|
||||
$pk->username = $this->getName();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->position = $this->location->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->yaw = $this->location->yaw;
|
||||
$pk->pitch = $this->location->pitch;
|
||||
$pk->item = ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getInventory()->getItemInHand()));
|
||||
$pk->metadata = $this->getAllNetworkData();
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
$player->getNetworkSession()->sendDataPacket(AddPlayerPacket::create(
|
||||
$this->getUniqueId(),
|
||||
$this->getName(),
|
||||
$this->getId(), //TODO: actor unique ID
|
||||
$this->getId(),
|
||||
"",
|
||||
$this->location->asVector3(),
|
||||
$this->getMotion(),
|
||||
$this->location->pitch,
|
||||
$this->location->yaw,
|
||||
$this->location->yaw, //TODO: head yaw
|
||||
ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getInventory()->getItemInHand())),
|
||||
$this->getAllNetworkData(),
|
||||
AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->getId()), //TODO
|
||||
[], //TODO: entity links
|
||||
"", //device ID (we intentionally don't send this - secvuln)
|
||||
DeviceOS::UNKNOWN //we intentionally don't send this (secvuln)
|
||||
));
|
||||
|
||||
//TODO: Hack for MCPE 1.2.13: DATA_NAMETAG is useless in AddPlayerPacket, so it has to be sent separately
|
||||
$this->sendData([$player], [EntityMetadataProperties::NAMETAG => new StringMetadataProperty($this->getNameTag())]);
|
||||
|
@ -34,7 +34,7 @@ class Location extends Position{
|
||||
/** @var float */
|
||||
public $pitch;
|
||||
|
||||
public function __construct(float $x, float $y, float $z, float $yaw = 0.0, float $pitch = 0.0, ?World $world = null){
|
||||
public function __construct(float $x, float $y, float $z, ?World $world, float $yaw, float $pitch){
|
||||
$this->yaw = $yaw;
|
||||
$this->pitch = $pitch;
|
||||
parent::__construct($x, $y, $z, $world);
|
||||
@ -44,14 +44,14 @@ class Location extends Position{
|
||||
* @return Location
|
||||
*/
|
||||
public static function fromObject(Vector3 $pos, ?World $world, float $yaw = 0.0, float $pitch = 0.0){
|
||||
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, $world ?? (($pos instanceof Position) ? $pos->world : null));
|
||||
return new Location($pos->x, $pos->y, $pos->z, $world ?? (($pos instanceof Position) ? $pos->world : null), $yaw, $pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Location instance
|
||||
*/
|
||||
public function asLocation() : Location{
|
||||
return new Location($this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->world);
|
||||
return new Location($this->x, $this->y, $this->z, $this->world, $this->yaw, $this->pitch);
|
||||
}
|
||||
|
||||
public function getYaw() : float{
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class ArmSwingAnimation implements Animation{
|
||||
|
||||
@ -37,7 +38,7 @@ final class ArmSwingAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEventPacket::ARM_SWING, 0)
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEvent::ARM_SWING, 0)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\projectile\Arrow;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
class ArrowShakeAnimation implements Animation{
|
||||
|
||||
@ -40,7 +41,7 @@ class ArrowShakeAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->arrow->getId(), ActorEventPacket::ARROW_SHAKE, $this->durationInTicks)
|
||||
ActorEventPacket::create($this->arrow->getId(), ActorEvent::ARROW_SHAKE, $this->durationInTicks)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\entity\Human;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\convert\ItemTranslator;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class ConsumingItemAnimation implements Animation{
|
||||
|
||||
@ -45,7 +46,7 @@ final class ConsumingItemAnimation implements Animation{
|
||||
[$netId, $netData] = ItemTranslator::getInstance()->toNetworkId($this->item->getId(), $this->item->getMeta());
|
||||
return [
|
||||
//TODO: need to check the data values
|
||||
ActorEventPacket::create($this->human->getId(), ActorEventPacket::EATING_ITEM, ($netId << 16) | $netData)
|
||||
ActorEventPacket::create($this->human->getId(), ActorEvent::EATING_ITEM, ($netId << 16) | $netData)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class DeathAnimation implements Animation{
|
||||
|
||||
@ -37,7 +38,7 @@ final class DeathAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEventPacket::DEATH_ANIMATION, 0)
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEvent::DEATH_ANIMATION, 0)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class HurtAnimation implements Animation{
|
||||
|
||||
@ -37,7 +38,7 @@ final class HurtAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEventPacket::HURT_ANIMATION, 0)
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEvent::HURT_ANIMATION, 0)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class RespawnAnimation implements Animation{
|
||||
|
||||
@ -37,7 +38,7 @@ final class RespawnAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEventPacket::RESPAWN, 0)
|
||||
ActorEventPacket::create($this->entity->getId(), ActorEvent::RESPAWN, 0)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\Squid;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class SquidInkCloudAnimation implements Animation{
|
||||
|
||||
@ -37,7 +38,7 @@ final class SquidInkCloudAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->squid->getId(), ActorEventPacket::SQUID_INK_CLOUD, 0)
|
||||
ActorEventPacket::create($this->squid->getId(), ActorEvent::SQUID_INK_CLOUD, 0)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\entity\animation;
|
||||
|
||||
use pocketmine\entity\Human;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class TotemUseAnimation implements Animation{
|
||||
|
||||
@ -38,7 +39,7 @@ final class TotemUseAnimation implements Animation{
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
ActorEventPacket::create($this->human->getId(), ActorEventPacket::CONSUME_TOTEM, 0)
|
||||
ActorEventPacket::create($this->human->getId(), ActorEvent::CONSUME_TOTEM, 0)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -206,14 +206,15 @@ class ItemEntity extends Entity{
|
||||
}
|
||||
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddItemActorPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->position = $this->location->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->item = ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getItem()));
|
||||
$pk->metadata = $this->getAllNetworkData();
|
||||
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
$player->getNetworkSession()->sendDataPacket(AddItemActorPacket::create(
|
||||
$this->getId(), //TODO: entity unique ID
|
||||
$this->getId(),
|
||||
ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getItem())),
|
||||
$this->location->asVector3(),
|
||||
$this->getMotion(),
|
||||
$this->getAllNetworkData(),
|
||||
false //TODO: I have no idea what this is needed for, but right now we don't support fishing anyway
|
||||
));
|
||||
}
|
||||
|
||||
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||
@ -227,8 +228,8 @@ class ItemEntity extends Entity{
|
||||
|
||||
$item = $this->getItem();
|
||||
$playerInventory = match(true){
|
||||
$player->getOffHandInventory()->getItem(0)->canStackWith($item) and $player->getOffHandInventory()->canAddItem($item) => $player->getOffHandInventory(),
|
||||
$player->getInventory()->canAddItem($item) => $player->getInventory(),
|
||||
$player->getOffHandInventory()->getItem(0)->canStackWith($item) and $player->getOffHandInventory()->getAddableItemQuantity($item) > 0 => $player->getOffHandInventory(),
|
||||
$player->getInventory()->getAddableItemQuantity($item) > 0 => $player->getInventory(),
|
||||
default => null
|
||||
};
|
||||
|
||||
@ -246,7 +247,12 @@ class ItemEntity extends Entity{
|
||||
$viewer->getNetworkSession()->onPlayerPickUpItem($player, $this);
|
||||
}
|
||||
|
||||
$ev->getInventory()?->addItem($ev->getItem());
|
||||
$inventory = $ev->getInventory();
|
||||
if($inventory !== null){
|
||||
foreach($inventory->addItem($ev->getItem()) as $remains){
|
||||
$this->getWorld()->dropItem($this->location, $remains, new Vector3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
$this->flagForDespawn();
|
||||
}
|
||||
}
|
||||
|
@ -149,17 +149,17 @@ class Painting extends Entity{
|
||||
}
|
||||
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddPaintingPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->position = new Vector3(
|
||||
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,
|
||||
($this->boundingBox->minY + $this->boundingBox->maxY) / 2,
|
||||
($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2
|
||||
);
|
||||
$pk->direction = self::FACING_TO_DATA[$this->facing];
|
||||
$pk->title = $this->motive->getName();
|
||||
|
||||
$player->getNetworkSession()->sendDataPacket($pk);
|
||||
$player->getNetworkSession()->sendDataPacket(AddPaintingPacket::create(
|
||||
$this->getId(), //TODO: entity unique ID
|
||||
$this->getId(),
|
||||
new Vector3(
|
||||
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,
|
||||
($this->boundingBox->minY + $this->boundingBox->maxY) / 2,
|
||||
($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2
|
||||
),
|
||||
self::FACING_TO_DATA[$this->facing],
|
||||
$this->motive->getName()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,7 +176,7 @@ abstract class Projectile extends Entity{
|
||||
Timings::$entityMove->startTiming();
|
||||
|
||||
$start = $this->location->asVector3();
|
||||
$end = $start->addVector($this->motion);
|
||||
$end = $start->add($dx, $dy, $dz);
|
||||
|
||||
$blockHit = null;
|
||||
$entityHit = null;
|
||||
|
@ -7,6 +7,7 @@ namespace pocketmine\event\block;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
/**
|
||||
@ -17,13 +18,23 @@ class StructureGrowEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
private BlockTransaction $transaction;
|
||||
private ?Player $player;
|
||||
|
||||
public function __construct(Block $block, BlockTransaction $transaction){
|
||||
public function __construct(Block $block, BlockTransaction $transaction, ?Player $player){
|
||||
parent::__construct($block);
|
||||
$this->transaction = $transaction;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function getTransaction() : BlockTransaction{
|
||||
return $this->transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* It returns the player which grows the structure.
|
||||
* It returns null when the structure grows by itself.
|
||||
*/
|
||||
public function getPlayer() : ?Player{
|
||||
return $this->player;
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ namespace pocketmine\event\player;
|
||||
use pocketmine\event\Event;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Utils;
|
||||
use function is_a;
|
||||
|
||||
/**
|
||||
@ -96,10 +97,7 @@ class PlayerCreationEvent extends Event{
|
||||
* @phpstan-param class-string<Player> $class
|
||||
*/
|
||||
public function setPlayerClass($class) : void{
|
||||
if(!is_a($class, $this->baseClass, true)){
|
||||
throw new \RuntimeException("Class $class must extend " . $this->baseClass);
|
||||
}
|
||||
|
||||
Utils::testValidInstance($class, $this->baseClass);
|
||||
$this->playerClass = $class;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ use pocketmine\player\Player;
|
||||
|
||||
class PlayerDeathEvent extends EntityDeathEvent{
|
||||
/** @var Player */
|
||||
protected $entity;
|
||||
protected $player;
|
||||
|
||||
/** @var Translatable|string */
|
||||
private $deathMessage;
|
||||
@ -49,6 +49,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
*/
|
||||
public function __construct(Player $entity, array $drops, int $xp, Translatable|string|null $deathMessage){
|
||||
parent::__construct($entity, $drops, $xp);
|
||||
$this->player = $entity;
|
||||
$this->deathMessage = $deathMessage ?? self::deriveMessage($entity->getDisplayName(), $entity->getLastDamageCause());
|
||||
}
|
||||
|
||||
@ -56,11 +57,11 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
* @return Player
|
||||
*/
|
||||
public function getEntity(){
|
||||
return $this->entity;
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
public function getPlayer() : Player{
|
||||
return $this->entity;
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
public function getDeathMessage() : Translatable|string{
|
||||
|
@ -169,6 +169,10 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
|
||||
public function canAddItem(Item $item) : bool{
|
||||
return $this->getAddableItemQuantity($item) === $item->getCount();
|
||||
}
|
||||
|
||||
public function getAddableItemQuantity(Item $item) : int{
|
||||
$count = $item->getCount();
|
||||
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
||||
$slot = $this->getItem($i);
|
||||
@ -181,11 +185,11 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
|
||||
if($count <= 0){
|
||||
return true;
|
||||
return $item->getCount();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $item->getCount() - $count;
|
||||
}
|
||||
|
||||
public function addItem(Item ...$slots) : array{
|
||||
|
@ -63,6 +63,11 @@ interface Inventory{
|
||||
*/
|
||||
public function canAddItem(Item $item) : bool;
|
||||
|
||||
/**
|
||||
* Returns how many items from the given itemstack can be added to this inventory.
|
||||
*/
|
||||
public function getAddableItemQuantity(Item $item) : int;
|
||||
|
||||
/**
|
||||
* Removes the given Item from the inventory.
|
||||
* It will return the Items that couldn't be removed.
|
||||
|
@ -37,6 +37,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
@ -240,6 +241,7 @@ class Item implements \JsonSerializable{
|
||||
* Sets the Item's NBT from the supplied CompoundTag object.
|
||||
*
|
||||
* @return $this
|
||||
* @throws NbtException
|
||||
*/
|
||||
public function setNamedTag(CompoundTag $tag) : Item{
|
||||
if($tag->getCount() === 0){
|
||||
@ -255,6 +257,7 @@ class Item implements \JsonSerializable{
|
||||
/**
|
||||
* Removes the Item's NBT.
|
||||
* @return $this
|
||||
* @throws NbtException
|
||||
*/
|
||||
public function clearNamedTag() : Item{
|
||||
$this->nbt = new CompoundTag();
|
||||
@ -262,6 +265,9 @@ class Item implements \JsonSerializable{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NbtException
|
||||
*/
|
||||
protected function deserializeCompoundTag(CompoundTag $tag) : void{
|
||||
$this->customName = "";
|
||||
$this->lore = [];
|
||||
|
@ -41,6 +41,7 @@ use pocketmine\entity\Villager;
|
||||
use pocketmine\entity\Zombie;
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use pocketmine\world\World;
|
||||
@ -444,6 +445,7 @@ class ItemFactory{
|
||||
* Deserializes an item from the provided legacy ID, legacy meta, count and NBT.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws NbtException
|
||||
*/
|
||||
public function get(int $id, int $meta = 0, int $count = 1, ?CompoundTag $tags = null) : Item{
|
||||
/** @var Item|null $item */
|
||||
|
@ -31,7 +31,6 @@ use function file_get_contents;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
use function is_numeric;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use function str_replace;
|
||||
use function strtolower;
|
||||
@ -63,8 +62,8 @@ final class LegacyStringToItemParser{
|
||||
if(!is_array($mappings)) throw new AssumptionFailedError("Invalid mappings format, expected array");
|
||||
|
||||
foreach($mappings as $name => $id){
|
||||
if(!is_string($name) or !is_int($id)) throw new AssumptionFailedError("Invalid mappings format, expected string keys and int values");
|
||||
$result->addMapping($name, $id);
|
||||
if(!is_int($id)) throw new AssumptionFailedError("Invalid mappings format, expected int values");
|
||||
$result->addMapping((string) $name, $id);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -84,6 +83,14 @@ final class LegacyStringToItemParser{
|
||||
$this->map[$alias] = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array<string, int>
|
||||
*/
|
||||
public function getMappings() : array{
|
||||
return $this->map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse the specified string into Item types.
|
||||
*
|
||||
@ -106,9 +113,7 @@ final class LegacyStringToItemParser{
|
||||
throw new LegacyStringToItemParserException("Unable to parse \"" . $b[1] . "\" from \"" . $input . "\" as a valid meta value");
|
||||
}
|
||||
|
||||
if(is_numeric($b[0])){
|
||||
$item = $this->itemFactory->get((int) $b[0], $meta);
|
||||
}elseif(isset($this->map[strtolower($b[0])])){
|
||||
if(isset($this->map[strtolower($b[0])])){
|
||||
$item = $this->itemFactory->get($this->map[strtolower($b[0])], $meta);
|
||||
}else{
|
||||
throw new LegacyStringToItemParserException("Unable to resolve \"" . $input . "\" to a valid item");
|
||||
|
@ -530,6 +530,7 @@ final class StringToItemParser{
|
||||
$result->registerBlock("fence_gate_spruce", fn() => VanillaBlocks::SPRUCE_FENCE_GATE());
|
||||
$result->registerBlock("fern", fn() => VanillaBlocks::FERN());
|
||||
$result->registerBlock("fire", fn() => VanillaBlocks::FIRE());
|
||||
$result->registerBlock("fletching_table", fn() => VanillaBlocks::FLETCHING_TABLE());
|
||||
$result->registerBlock("flower_pot", fn() => VanillaBlocks::FLOWER_POT());
|
||||
$result->registerBlock("flower_pot_block", fn() => VanillaBlocks::FLOWER_POT());
|
||||
$result->registerBlock("flowing_lava", fn() => VanillaBlocks::LAVA());
|
||||
|
@ -573,6 +573,12 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::COMMANDS_WHITELIST_USAGE, []);
|
||||
}
|
||||
|
||||
public static function death_attack_anvil(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::DEATH_ATTACK_ANVIL, [
|
||||
0 => $param0,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function death_attack_arrow(Translatable|string $param0, Translatable|string $param1) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::DEATH_ATTACK_ARROW, [
|
||||
0 => $param0,
|
||||
@ -1103,6 +1109,18 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_ENCHANT_DESCRIPTION, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_error_permission(Translatable|string $commandName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_ERROR_PERMISSION, [
|
||||
"commandName" => $commandName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_error_playerNotFound(Translatable|string $playerName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_ERROR_PLAYERNOTFOUND, [
|
||||
"playerName" => $playerName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_exception(Translatable|string $param0, Translatable|string $param1, Translatable|string $param2) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_EXCEPTION, [
|
||||
0 => $param0,
|
||||
@ -1115,6 +1133,18 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_GAMEMODE_DESCRIPTION, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_gamemode_failure(Translatable|string $playerName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_GAMEMODE_FAILURE, [
|
||||
"playerName" => $playerName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_gamemode_unknown(Translatable|string $gameModeName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_GAMEMODE_UNKNOWN, [
|
||||
"gameModeName" => $gameModeName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_gc_chunks(Translatable|string $chunksCollected) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_GC_CHUNKS, [
|
||||
"chunksCollected" => $chunksCollected,
|
||||
@ -1159,6 +1189,24 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_DESCRIPTION, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_help_specificCommand_description(Translatable|string $description) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_DESCRIPTION, [
|
||||
"description" => $description,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_help_specificCommand_header(Translatable|string $commandName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_HEADER, [
|
||||
"commandName" => $commandName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_help_specificCommand_usage(Translatable|string $usage) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_USAGE, [
|
||||
"usage" => $usage,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_kick_description() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_KICK_DESCRIPTION, []);
|
||||
}
|
||||
@ -1179,6 +1227,13 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_ME_DESCRIPTION, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_notFound(Translatable|string $commandName, Translatable|string $helpCommand) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_NOTFOUND, [
|
||||
"commandName" => $commandName,
|
||||
"helpCommand" => $helpCommand,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_command_op_description() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_OP_DESCRIPTION, []);
|
||||
}
|
||||
@ -1490,6 +1545,25 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_conversion_finish(Translatable|string $worldName, Translatable|string $backupPath) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_CONVERSION_FINISH, [
|
||||
"worldName" => $worldName,
|
||||
"backupPath" => $backupPath,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_conversion_start(Translatable|string $worldName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_CONVERSION_START, [
|
||||
"worldName" => $worldName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_corrupted(Translatable|string $details) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_CORRUPTED, [
|
||||
"details" => $details,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_defaultError() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_DEFAULTERROR, []);
|
||||
}
|
||||
@ -1501,6 +1575,14 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_invalidGeneratorOptions(Translatable|string $preset, Translatable|string $generatorName, Translatable|string $details) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_INVALIDGENERATOROPTIONS, [
|
||||
"preset" => $preset,
|
||||
"generatorName" => $generatorName,
|
||||
"details" => $details,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_loadError(Translatable|string $param0, Translatable|string $param1) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_LOADERROR, [
|
||||
0 => $param0,
|
||||
@ -1520,16 +1602,36 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_spawnTerrainGenerationProgress(Translatable|string $done, Translatable|string $total, Translatable|string $percentageDone) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_SPAWNTERRAINGENERATIONPROGRESS, [
|
||||
"done" => $done,
|
||||
"total" => $total,
|
||||
"percentageDone" => $percentageDone,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_unknownFormat() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_UNKNOWNFORMAT, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_unknownGenerator(Translatable|string $generatorName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_UNKNOWNGENERATOR, [
|
||||
"generatorName" => $generatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_unloading(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_UNLOADING, [
|
||||
0 => $param0,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_level_unsupportedFormat(Translatable|string $details) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_LEVEL_UNSUPPORTEDFORMAT, [
|
||||
"details" => $details,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_player_invalidEntity(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLAYER_INVALIDENTITY, [
|
||||
0 => $param0,
|
||||
@ -1577,6 +1679,12 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_badDataFolder(Translatable|string $dataFolder) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_BADDATAFOLDER, [
|
||||
"dataFolder" => $dataFolder,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_circularDependency() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_CIRCULARDEPENDENCY, []);
|
||||
}
|
||||
@ -1602,23 +1710,36 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_disallowedByBlacklist() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_DISALLOWEDBYBLACKLIST, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_disallowedByWhitelist() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_DISALLOWEDBYWHITELIST, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_duplicateError(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_DUPLICATEERROR, [
|
||||
0 => $param0,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_emptyExtensionVersionConstraint(Translatable|string $constraintIndex, Translatable|string $extensionName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_EMPTYEXTENSIONVERSIONCONSTRAINT, [
|
||||
"constraintIndex" => $constraintIndex,
|
||||
"extensionName" => $extensionName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_enable(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_ENABLE, [
|
||||
0 => $param0,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_fileError(Translatable|string $param0, Translatable|string $param1, Translatable|string $param2) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_FILEERROR, [
|
||||
0 => $param0,
|
||||
1 => $param1,
|
||||
2 => $param2,
|
||||
public static function pocketmine_plugin_extensionNotLoaded(Translatable|string $extensionName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_EXTENSIONNOTLOADED, [
|
||||
"extensionName" => $extensionName,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -1634,6 +1755,14 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_incompatibleExtensionVersion(Translatable|string $extensionVersion, Translatable|string $extensionName, Translatable|string $pluginRequirement) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_INCOMPATIBLEEXTENSIONVERSION, [
|
||||
"extensionVersion" => $extensionVersion,
|
||||
"extensionName" => $extensionName,
|
||||
"pluginRequirement" => $pluginRequirement,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_incompatibleOS(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_INCOMPATIBLEOS, [
|
||||
0 => $param0,
|
||||
@ -1652,6 +1781,25 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_invalidAPI(Translatable|string $apiVersion) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_INVALIDAPI, [
|
||||
"apiVersion" => $apiVersion,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_invalidExtensionVersionConstraint(Translatable|string $versionConstraint, Translatable|string $extensionName) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_INVALIDEXTENSIONVERSIONCONSTRAINT, [
|
||||
"versionConstraint" => $versionConstraint,
|
||||
"extensionName" => $extensionName,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_invalidManifest(Translatable|string $details) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_INVALIDMANIFEST, [
|
||||
"details" => $details,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_load(Translatable|string $param0) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_LOAD, [
|
||||
0 => $param0,
|
||||
@ -1665,6 +1813,16 @@ final class KnownTranslationFactory{
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_mainClassNotFound() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_MAINCLASSNOTFOUND, []);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_mainClassWrongType(Translatable|string $pluginInterface) : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_MAINCLASSWRONGTYPE, [
|
||||
"pluginInterface" => $pluginInterface,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function pocketmine_plugin_restrictedName() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_RESTRICTEDNAME, []);
|
||||
}
|
||||
@ -1917,6 +2075,10 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::POTION_SATURATION, []);
|
||||
}
|
||||
|
||||
public static function potion_slowFalling() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POTION_SLOWFALLING, []);
|
||||
}
|
||||
|
||||
public static function potion_waterBreathing() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::POTION_WATERBREATHING, []);
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ final class KnownTranslationKeys{
|
||||
public const COMMANDS_WHITELIST_REMOVE_SUCCESS = "commands.whitelist.remove.success";
|
||||
public const COMMANDS_WHITELIST_REMOVE_USAGE = "commands.whitelist.remove.usage";
|
||||
public const COMMANDS_WHITELIST_USAGE = "commands.whitelist.usage";
|
||||
public const DEATH_ATTACK_ANVIL = "death.attack.anvil";
|
||||
public const DEATH_ATTACK_ARROW = "death.attack.arrow";
|
||||
public const DEATH_ATTACK_ARROW_ITEM = "death.attack.arrow.item";
|
||||
public const DEATH_ATTACK_CACTUS = "death.attack.cactus";
|
||||
@ -243,8 +244,12 @@ final class KnownTranslationKeys{
|
||||
public const POCKETMINE_COMMAND_DIFFICULTY_DESCRIPTION = "pocketmine.command.difficulty.description";
|
||||
public const POCKETMINE_COMMAND_EFFECT_DESCRIPTION = "pocketmine.command.effect.description";
|
||||
public const POCKETMINE_COMMAND_ENCHANT_DESCRIPTION = "pocketmine.command.enchant.description";
|
||||
public const POCKETMINE_COMMAND_ERROR_PERMISSION = "pocketmine.command.error.permission";
|
||||
public const POCKETMINE_COMMAND_ERROR_PLAYERNOTFOUND = "pocketmine.command.error.playerNotFound";
|
||||
public const POCKETMINE_COMMAND_EXCEPTION = "pocketmine.command.exception";
|
||||
public const POCKETMINE_COMMAND_GAMEMODE_DESCRIPTION = "pocketmine.command.gamemode.description";
|
||||
public const POCKETMINE_COMMAND_GAMEMODE_FAILURE = "pocketmine.command.gamemode.failure";
|
||||
public const POCKETMINE_COMMAND_GAMEMODE_UNKNOWN = "pocketmine.command.gamemode.unknown";
|
||||
public const POCKETMINE_COMMAND_GC_CHUNKS = "pocketmine.command.gc.chunks";
|
||||
public const POCKETMINE_COMMAND_GC_CYCLES = "pocketmine.command.gc.cycles";
|
||||
public const POCKETMINE_COMMAND_GC_DESCRIPTION = "pocketmine.command.gc.description";
|
||||
@ -254,11 +259,15 @@ final class KnownTranslationKeys{
|
||||
public const POCKETMINE_COMMAND_GIVE_DESCRIPTION = "pocketmine.command.give.description";
|
||||
public const POCKETMINE_COMMAND_GIVE_USAGE = "pocketmine.command.give.usage";
|
||||
public const POCKETMINE_COMMAND_HELP_DESCRIPTION = "pocketmine.command.help.description";
|
||||
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_DESCRIPTION = "pocketmine.command.help.specificCommand.description";
|
||||
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_HEADER = "pocketmine.command.help.specificCommand.header";
|
||||
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_USAGE = "pocketmine.command.help.specificCommand.usage";
|
||||
public const POCKETMINE_COMMAND_KICK_DESCRIPTION = "pocketmine.command.kick.description";
|
||||
public const POCKETMINE_COMMAND_KILL_DESCRIPTION = "pocketmine.command.kill.description";
|
||||
public const POCKETMINE_COMMAND_KILL_USAGE = "pocketmine.command.kill.usage";
|
||||
public const POCKETMINE_COMMAND_LIST_DESCRIPTION = "pocketmine.command.list.description";
|
||||
public const POCKETMINE_COMMAND_ME_DESCRIPTION = "pocketmine.command.me.description";
|
||||
public const POCKETMINE_COMMAND_NOTFOUND = "pocketmine.command.notFound";
|
||||
public const POCKETMINE_COMMAND_OP_DESCRIPTION = "pocketmine.command.op.description";
|
||||
public const POCKETMINE_COMMAND_PARTICLE_DESCRIPTION = "pocketmine.command.particle.description";
|
||||
public const POCKETMINE_COMMAND_PARTICLE_USAGE = "pocketmine.command.particle.usage";
|
||||
@ -324,33 +333,50 @@ final class KnownTranslationKeys{
|
||||
public const POCKETMINE_LEVEL_AMBIGUOUSFORMAT = "pocketmine.level.ambiguousFormat";
|
||||
public const POCKETMINE_LEVEL_BACKGROUNDGENERATION = "pocketmine.level.backgroundGeneration";
|
||||
public const POCKETMINE_LEVEL_BADDEFAULTFORMAT = "pocketmine.level.badDefaultFormat";
|
||||
public const POCKETMINE_LEVEL_CONVERSION_FINISH = "pocketmine.level.conversion.finish";
|
||||
public const POCKETMINE_LEVEL_CONVERSION_START = "pocketmine.level.conversion.start";
|
||||
public const POCKETMINE_LEVEL_CORRUPTED = "pocketmine.level.corrupted";
|
||||
public const POCKETMINE_LEVEL_DEFAULTERROR = "pocketmine.level.defaultError";
|
||||
public const POCKETMINE_LEVEL_GENERATIONERROR = "pocketmine.level.generationError";
|
||||
public const POCKETMINE_LEVEL_INVALIDGENERATOROPTIONS = "pocketmine.level.invalidGeneratorOptions";
|
||||
public const POCKETMINE_LEVEL_LOADERROR = "pocketmine.level.loadError";
|
||||
public const POCKETMINE_LEVEL_NOTFOUND = "pocketmine.level.notFound";
|
||||
public const POCKETMINE_LEVEL_PREPARING = "pocketmine.level.preparing";
|
||||
public const POCKETMINE_LEVEL_SPAWNTERRAINGENERATIONPROGRESS = "pocketmine.level.spawnTerrainGenerationProgress";
|
||||
public const POCKETMINE_LEVEL_UNKNOWNFORMAT = "pocketmine.level.unknownFormat";
|
||||
public const POCKETMINE_LEVEL_UNKNOWNGENERATOR = "pocketmine.level.unknownGenerator";
|
||||
public const POCKETMINE_LEVEL_UNLOADING = "pocketmine.level.unloading";
|
||||
public const POCKETMINE_LEVEL_UNSUPPORTEDFORMAT = "pocketmine.level.unsupportedFormat";
|
||||
public const POCKETMINE_PLAYER_INVALIDENTITY = "pocketmine.player.invalidEntity";
|
||||
public const POCKETMINE_PLAYER_INVALIDMOVE = "pocketmine.player.invalidMove";
|
||||
public const POCKETMINE_PLAYER_LOGIN = "pocketmine.player.logIn";
|
||||
public const POCKETMINE_PLAYER_LOGOUT = "pocketmine.player.logOut";
|
||||
public const POCKETMINE_PLUGIN_ALIASERROR = "pocketmine.plugin.aliasError";
|
||||
public const POCKETMINE_PLUGIN_AMBIGUOUSMINAPI = "pocketmine.plugin.ambiguousMinAPI";
|
||||
public const POCKETMINE_PLUGIN_BADDATAFOLDER = "pocketmine.plugin.badDataFolder";
|
||||
public const POCKETMINE_PLUGIN_CIRCULARDEPENDENCY = "pocketmine.plugin.circularDependency";
|
||||
public const POCKETMINE_PLUGIN_COMMANDERROR = "pocketmine.plugin.commandError";
|
||||
public const POCKETMINE_PLUGIN_DEPRECATEDEVENT = "pocketmine.plugin.deprecatedEvent";
|
||||
public const POCKETMINE_PLUGIN_DISABLE = "pocketmine.plugin.disable";
|
||||
public const POCKETMINE_PLUGIN_DISALLOWEDBYBLACKLIST = "pocketmine.plugin.disallowedByBlacklist";
|
||||
public const POCKETMINE_PLUGIN_DISALLOWEDBYWHITELIST = "pocketmine.plugin.disallowedByWhitelist";
|
||||
public const POCKETMINE_PLUGIN_DUPLICATEERROR = "pocketmine.plugin.duplicateError";
|
||||
public const POCKETMINE_PLUGIN_EMPTYEXTENSIONVERSIONCONSTRAINT = "pocketmine.plugin.emptyExtensionVersionConstraint";
|
||||
public const POCKETMINE_PLUGIN_ENABLE = "pocketmine.plugin.enable";
|
||||
public const POCKETMINE_PLUGIN_FILEERROR = "pocketmine.plugin.fileError";
|
||||
public const POCKETMINE_PLUGIN_EXTENSIONNOTLOADED = "pocketmine.plugin.extensionNotLoaded";
|
||||
public const POCKETMINE_PLUGIN_GENERICLOADERROR = "pocketmine.plugin.genericLoadError";
|
||||
public const POCKETMINE_PLUGIN_INCOMPATIBLEAPI = "pocketmine.plugin.incompatibleAPI";
|
||||
public const POCKETMINE_PLUGIN_INCOMPATIBLEEXTENSIONVERSION = "pocketmine.plugin.incompatibleExtensionVersion";
|
||||
public const POCKETMINE_PLUGIN_INCOMPATIBLEOS = "pocketmine.plugin.incompatibleOS";
|
||||
public const POCKETMINE_PLUGIN_INCOMPATIBLEPHPVERSION = "pocketmine.plugin.incompatiblePhpVersion";
|
||||
public const POCKETMINE_PLUGIN_INCOMPATIBLEPROTOCOL = "pocketmine.plugin.incompatibleProtocol";
|
||||
public const POCKETMINE_PLUGIN_INVALIDAPI = "pocketmine.plugin.invalidAPI";
|
||||
public const POCKETMINE_PLUGIN_INVALIDEXTENSIONVERSIONCONSTRAINT = "pocketmine.plugin.invalidExtensionVersionConstraint";
|
||||
public const POCKETMINE_PLUGIN_INVALIDMANIFEST = "pocketmine.plugin.invalidManifest";
|
||||
public const POCKETMINE_PLUGIN_LOAD = "pocketmine.plugin.load";
|
||||
public const POCKETMINE_PLUGIN_LOADERROR = "pocketmine.plugin.loadError";
|
||||
public const POCKETMINE_PLUGIN_MAINCLASSNOTFOUND = "pocketmine.plugin.mainClassNotFound";
|
||||
public const POCKETMINE_PLUGIN_MAINCLASSWRONGTYPE = "pocketmine.plugin.mainClassWrongType";
|
||||
public const POCKETMINE_PLUGIN_RESTRICTEDNAME = "pocketmine.plugin.restrictedName";
|
||||
public const POCKETMINE_PLUGIN_SPACESDISCOURAGED = "pocketmine.plugin.spacesDiscouraged";
|
||||
public const POCKETMINE_PLUGIN_UNKNOWNDEPENDENCY = "pocketmine.plugin.unknownDependency";
|
||||
@ -404,6 +430,7 @@ final class KnownTranslationKeys{
|
||||
public const POTION_REGENERATION = "potion.regeneration";
|
||||
public const POTION_RESISTANCE = "potion.resistance";
|
||||
public const POTION_SATURATION = "potion.saturation";
|
||||
public const POTION_SLOWFALLING = "potion.slowFalling";
|
||||
public const POTION_WATERBREATHING = "potion.waterBreathing";
|
||||
public const POTION_WEAKNESS = "potion.weakness";
|
||||
public const POTION_WITHER = "potion.wither";
|
||||
|
@ -58,7 +58,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
public function __construct(int $chunkX, int $chunkZ, Chunk $chunk, CompressBatchPromise $promise, Compressor $compressor, ?\Closure $onError = null){
|
||||
$this->compressor = $compressor;
|
||||
|
||||
$this->chunk = FastChunkSerializer::serializeWithoutLight($chunk);
|
||||
$this->chunk = FastChunkSerializer::serializeTerrain($chunk);
|
||||
$this->chunkX = $chunkX;
|
||||
$this->chunkZ = $chunkZ;
|
||||
$this->tiles = ChunkSerializer::serializeTiles($chunk);
|
||||
@ -68,7 +68,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
$chunk = FastChunkSerializer::deserialize($this->chunk);
|
||||
$chunk = FastChunkSerializer::deserializeTerrain($this->chunk);
|
||||
$subCount = ChunkSerializer::getSubChunkCount($chunk);
|
||||
$encoderContext = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary());
|
||||
$payload = ChunkSerializer::serializeFullChunk($chunk, RuntimeBlockMapping::getInstance(), $encoderContext, $this->tiles);
|
||||
|
@ -45,6 +45,7 @@ use pocketmine\network\mcpe\protocol\CreativeContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventorySlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\CreativeContentEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
@ -164,27 +165,22 @@ class InventoryManager{
|
||||
//TODO: we should be using some kind of tagging system to identify the types. Instanceof is flaky especially
|
||||
//if the class isn't final, not to mention being inflexible.
|
||||
if($inv instanceof BlockInventory){
|
||||
switch(true){
|
||||
case $inv instanceof LoomInventory:
|
||||
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::LOOM, $inv->getHolder())];
|
||||
case $inv instanceof FurnaceInventory:
|
||||
return match($inv->getFurnaceType()->id()){
|
||||
FurnaceType::FURNACE()->id() => [ContainerOpenPacket::blockInvVec3($id, WindowTypes::FURNACE, $inv->getHolder())],
|
||||
FurnaceType::BLAST_FURNACE()->id() => [ContainerOpenPacket::blockInvVec3($id, WindowTypes::BLAST_FURNACE, $inv->getHolder())],
|
||||
FurnaceType::SMOKER()->id() => [ContainerOpenPacket::blockInvVec3($id, WindowTypes::SMOKER, $inv->getHolder())],
|
||||
$blockPosition = BlockPosition::fromVector3($inv->getHolder());
|
||||
$windowType = match(true){
|
||||
$inv instanceof LoomInventory => WindowTypes::LOOM,
|
||||
$inv instanceof FurnaceInventory => match($inv->getFurnaceType()->id()){
|
||||
FurnaceType::FURNACE()->id() => WindowTypes::FURNACE,
|
||||
FurnaceType::BLAST_FURNACE()->id() => WindowTypes::BLAST_FURNACE,
|
||||
FurnaceType::SMOKER()->id() => WindowTypes::SMOKER,
|
||||
default => throw new AssumptionFailedError("Unreachable")
|
||||
};
|
||||
case $inv instanceof EnchantInventory:
|
||||
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::ENCHANTMENT, $inv->getHolder())];
|
||||
case $inv instanceof BrewingStandInventory:
|
||||
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::BREWING_STAND, $inv->getHolder())];
|
||||
case $inv instanceof AnvilInventory:
|
||||
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::ANVIL, $inv->getHolder())];
|
||||
case $inv instanceof HopperInventory:
|
||||
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::HOPPER, $inv->getHolder())];
|
||||
default:
|
||||
return [ContainerOpenPacket::blockInvVec3($id, WindowTypes::CONTAINER, $inv->getHolder())];
|
||||
}
|
||||
},
|
||||
$inv instanceof EnchantInventory => WindowTypes::ENCHANTMENT,
|
||||
$inv instanceof BrewingStandInventory => WindowTypes::BREWING_STAND,
|
||||
$inv instanceof AnvilInventory => WindowTypes::ANVIL,
|
||||
$inv instanceof HopperInventory => WindowTypes::HOPPER,
|
||||
default => WindowTypes::CONTAINER
|
||||
};
|
||||
return [ContainerOpenPacket::blockInv($id, $windowType, $blockPosition)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -279,6 +275,7 @@ class InventoryManager{
|
||||
$this->player->getId(),
|
||||
ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->player->getInventory()->getItemInHand())),
|
||||
$selected,
|
||||
$selected,
|
||||
ContainerIds::INVENTORY
|
||||
));
|
||||
$this->clientSelectedHotbarSlot = $selected;
|
||||
|
@ -88,6 +88,7 @@ use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandData;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandEnum;
|
||||
use pocketmine\network\mcpe\protocol\types\command\CommandParameter;
|
||||
@ -234,6 +235,10 @@ class NetworkSession{
|
||||
return;
|
||||
}
|
||||
$this->player = $player;
|
||||
if(!$this->server->addOnlinePlayer($player)){
|
||||
return;
|
||||
}
|
||||
|
||||
$this->invManager = new InventoryManager($this->player, $this);
|
||||
|
||||
$effectManager = $this->player->getEffects();
|
||||
@ -442,6 +447,8 @@ class NetworkSession{
|
||||
}
|
||||
}
|
||||
|
||||
public function getPacketSerializerContext() : PacketSerializerContext{ return $this->packetSerializerContext; }
|
||||
|
||||
public function getBroadcaster() : PacketBroadcaster{ return $this->broadcaster; }
|
||||
|
||||
public function getCompressor() : Compressor{
|
||||
@ -722,16 +729,17 @@ class NetworkSession{
|
||||
$yaw = $yaw ?? $location->getYaw();
|
||||
$pitch = $pitch ?? $location->getPitch();
|
||||
|
||||
$pk = new MovePlayerPacket();
|
||||
$pk->entityRuntimeId = $this->player->getId();
|
||||
$pk->position = $this->player->getOffsetPosition($pos);
|
||||
$pk->pitch = $pitch;
|
||||
$pk->headYaw = $yaw;
|
||||
$pk->yaw = $yaw;
|
||||
$pk->mode = $mode;
|
||||
$pk->onGround = $this->player->onGround;
|
||||
|
||||
$this->sendDataPacket($pk);
|
||||
$this->sendDataPacket(MovePlayerPacket::simple(
|
||||
$this->player->getId(),
|
||||
$this->player->getOffsetPosition($pos),
|
||||
$pitch,
|
||||
$yaw,
|
||||
$yaw, //TODO: head yaw
|
||||
$mode,
|
||||
$this->player->onGround,
|
||||
0, //TODO: riding entity ID
|
||||
0 //TODO: tick
|
||||
));
|
||||
|
||||
if($this->handler instanceof InGamePacketHandler){
|
||||
$this->handler->forceMoveSync = true;
|
||||
@ -744,18 +752,25 @@ class NetworkSession{
|
||||
}
|
||||
|
||||
public function syncViewAreaCenterPoint(Vector3 $newPos, int $viewDistance) : void{
|
||||
$this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create($newPos->getFloorX(), $newPos->getFloorY(), $newPos->getFloorZ(), $viewDistance * 16)); //blocks, not chunks >.>
|
||||
$this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(BlockPosition::fromVector3($newPos), $viewDistance * 16)); //blocks, not chunks >.>
|
||||
}
|
||||
|
||||
public function syncPlayerSpawnPoint(Position $newSpawn) : void{
|
||||
[$x, $y, $z] = [$newSpawn->getFloorX(), $newSpawn->getFloorY(), $newSpawn->getFloorZ()];
|
||||
$this->sendDataPacket(SetSpawnPositionPacket::playerSpawn($x, $y, $z, DimensionIds::OVERWORLD, $x, $y, $z));
|
||||
$newSpawnBlockPosition = BlockPosition::fromVector3($newSpawn);
|
||||
//TODO: respawn causing block position (bed, respawn anchor)
|
||||
$this->sendDataPacket(SetSpawnPositionPacket::playerSpawn($newSpawnBlockPosition, DimensionIds::OVERWORLD, $newSpawnBlockPosition));
|
||||
}
|
||||
|
||||
public function syncWorldSpawnPoint(Position $newSpawn) : void{
|
||||
$this->sendDataPacket(SetSpawnPositionPacket::worldSpawn(BlockPosition::fromVector3($newSpawn), DimensionIds::OVERWORLD));
|
||||
}
|
||||
|
||||
public function syncGameMode(GameMode $mode, bool $isRollback = false) : void{
|
||||
$this->sendDataPacket(SetPlayerGameTypePacket::create(TypeConverter::getInstance()->coreGameModeToProtocol($mode)));
|
||||
$this->syncAdventureSettings($this->player);
|
||||
if(!$isRollback){
|
||||
if($this->player !== null){
|
||||
$this->syncAdventureSettings($this->player);
|
||||
}
|
||||
if(!$isRollback && $this->invManager !== null){
|
||||
$this->invManager->syncCreative();
|
||||
}
|
||||
}
|
||||
@ -764,7 +779,15 @@ class NetworkSession{
|
||||
* TODO: make this less specialized
|
||||
*/
|
||||
public function syncAdventureSettings(Player $for) : void{
|
||||
$pk = new AdventureSettingsPacket();
|
||||
$isOp = $for->hasPermission(DefaultPermissions::ROOT_OPERATOR);
|
||||
$pk = AdventureSettingsPacket::create(
|
||||
0,
|
||||
$isOp ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL,
|
||||
0,
|
||||
$isOp ? PlayerPermissions::OPERATOR : PlayerPermissions::MEMBER,
|
||||
0,
|
||||
$for->getId()
|
||||
);
|
||||
|
||||
$pk->setFlag(AdventureSettingsPacket::WORLD_IMMUTABLE, $for->isSpectator());
|
||||
$pk->setFlag(AdventureSettingsPacket::NO_PVP, $for->isSpectator());
|
||||
@ -775,11 +798,6 @@ class NetworkSession{
|
||||
|
||||
//TODO: permission flags
|
||||
|
||||
$isOp = $for->hasPermission(DefaultPermissions::ROOT_OPERATOR);
|
||||
$pk->commandPermission = ($isOp ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL);
|
||||
$pk->playerPermission = ($isOp ? PlayerPermissions::OPERATOR : PlayerPermissions::MEMBER);
|
||||
$pk->entityUniqueId = $for->getId();
|
||||
|
||||
$this->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
@ -816,9 +834,9 @@ class NetworkSession{
|
||||
}
|
||||
|
||||
public function syncAvailableCommands() : void{
|
||||
$pk = new AvailableCommandsPacket();
|
||||
$commandData = [];
|
||||
foreach($this->server->getCommandMap()->getCommands() as $name => $command){
|
||||
if(isset($pk->commandData[$command->getName()]) or $command->getName() === "help" or !$command->testPermissionSilent($this->player)){
|
||||
if(isset($commandData[$command->getName()]) or $command->getName() === "help" or !$command->testPermissionSilent($this->player)){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -845,10 +863,10 @@ class NetworkSession{
|
||||
]
|
||||
);
|
||||
|
||||
$pk->commandData[$command->getName()] = $data;
|
||||
$commandData[$command->getName()] = $data;
|
||||
}
|
||||
|
||||
$this->sendDataPacket($pk);
|
||||
$this->sendDataPacket(AvailableCommandsPacket::create($commandData, [], [], []));
|
||||
}
|
||||
|
||||
public function onRawChatMessage(string $message) : void{
|
||||
@ -933,8 +951,8 @@ class NetworkSession{
|
||||
$world = $this->player->getWorld();
|
||||
$this->syncWorldTime($world->getTime());
|
||||
$this->syncWorldDifficulty($world->getDifficulty());
|
||||
$this->syncWorldSpawnPoint($world->getSpawnLocation());
|
||||
//TODO: weather needs to be synced here (when implemented)
|
||||
//TODO: world spawn needs to be synced here
|
||||
}
|
||||
}
|
||||
|
||||
@ -956,12 +974,12 @@ class NetworkSession{
|
||||
public function onMobMainHandItemChange(Human $mob) : void{
|
||||
//TODO: we could send zero for slot here because remote players don't need to know which slot was selected
|
||||
$inv = $mob->getInventory();
|
||||
$this->sendDataPacket(MobEquipmentPacket::create($mob->getId(), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($inv->getItemInHand())), $inv->getHeldItemIndex(), ContainerIds::INVENTORY));
|
||||
$this->sendDataPacket(MobEquipmentPacket::create($mob->getId(), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($inv->getItemInHand())), $inv->getHeldItemIndex(), $inv->getHeldItemIndex(), ContainerIds::INVENTORY));
|
||||
}
|
||||
|
||||
public function onMobOffHandItemChange(Human $mob) : void{
|
||||
$inv = $mob->getOffHandInventory();
|
||||
$this->sendDataPacket(MobEquipmentPacket::create($mob->getId(), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($inv->getItem(0))), 0, ContainerIds::OFFHAND));
|
||||
$this->sendDataPacket(MobEquipmentPacket::create($mob->getId(), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($inv->getItem(0))), 0, 0, ContainerIds::OFFHAND));
|
||||
}
|
||||
|
||||
public function onMobArmorChange(Living $mob) : void{
|
||||
|
@ -23,10 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\network\mcpe\compression\Compressor;
|
||||
use pocketmine\network\mcpe\convert\GlobalItemTypeDictionary;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketBatch;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializerContext;
|
||||
use pocketmine\Server;
|
||||
use function spl_object_id;
|
||||
|
||||
@ -40,35 +37,40 @@ final class StandardPacketBroadcaster implements PacketBroadcaster{
|
||||
}
|
||||
|
||||
public function broadcastPackets(array $recipients, array $packets) : void{
|
||||
//TODO: we should be using session-specific serializer contexts for this
|
||||
$stream = PacketBatch::fromPackets(new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()), ...$packets);
|
||||
|
||||
/** @var Compressor[] $compressors */
|
||||
$buffers = [];
|
||||
$compressors = [];
|
||||
/** @var NetworkSession[][] $compressorTargets */
|
||||
$compressorTargets = [];
|
||||
$targetMap = [];
|
||||
foreach($recipients as $recipient){
|
||||
$compressor = $recipient->getCompressor();
|
||||
$compressorId = spl_object_id($compressor);
|
||||
$serializerContext = $recipient->getPacketSerializerContext();
|
||||
$bufferId = spl_object_id($serializerContext);
|
||||
if(!isset($buffers[$bufferId])){
|
||||
$buffers[$bufferId] = PacketBatch::fromPackets($serializerContext, ...$packets);
|
||||
}
|
||||
|
||||
//TODO: different compressors might be compatible, it might not be necessary to split them up by object
|
||||
$compressors[$compressorId] = $compressor;
|
||||
$compressorTargets[$compressorId][] = $recipient;
|
||||
$compressor = $recipient->getCompressor();
|
||||
$compressors[spl_object_id($compressor)] = $compressor;
|
||||
|
||||
$targetMap[$bufferId][spl_object_id($compressor)][] = $recipient;
|
||||
}
|
||||
|
||||
foreach($compressors as $compressorId => $compressor){
|
||||
if(!$compressor->willCompress($stream->getBuffer())){
|
||||
foreach($compressorTargets[$compressorId] as $target){
|
||||
foreach($packets as $pk){
|
||||
$target->addToSendBuffer($pk);
|
||||
foreach($targetMap as $bufferId => $compressorMap){
|
||||
$buffer = $buffers[$bufferId];
|
||||
foreach($compressorMap as $compressorId => $compressorTargets){
|
||||
$compressor = $compressors[$compressorId];
|
||||
if(!$compressor->willCompress($buffer->getBuffer())){
|
||||
foreach($compressorTargets as $target){
|
||||
foreach($packets as $pk){
|
||||
$target->addToSendBuffer($pk);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$promise = $this->server->prepareBatch($buffer, $compressor);
|
||||
foreach($compressorTargets as $target){
|
||||
$target->queueCompressed($promise);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$promise = $this->server->prepareBatch($stream, $compressor);
|
||||
foreach($compressorTargets[$compressorId] as $target){
|
||||
$target->queueCompressed($promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
16
src/network/mcpe/cache/ChunkCache.php
vendored
16
src/network/mcpe/cache/ChunkCache.php
vendored
@ -36,9 +36,6 @@ use function strlen;
|
||||
|
||||
/**
|
||||
* This class is used by the current MCPE protocol system to store cached chunk packets for fast resending.
|
||||
*
|
||||
* TODO: make MemoryManager aware of this so the cache can be destroyed when memory is low
|
||||
* TODO: this needs a hook for world unloading
|
||||
*/
|
||||
class ChunkCache implements ChunkListener{
|
||||
/** @var self[][] */
|
||||
@ -69,6 +66,19 @@ class ChunkCache implements ChunkListener{
|
||||
return self::$instances[$worldId][$compressorId];
|
||||
}
|
||||
|
||||
public static function pruneCaches() : void{
|
||||
foreach(self::$instances as $compressorMap){
|
||||
foreach($compressorMap as $chunkCache){
|
||||
foreach($chunkCache->caches as $chunkHash => $promise){
|
||||
if($promise->hasResult()){
|
||||
//Do not clear promises that are not yet fulfilled; they will have requesters waiting on them
|
||||
unset($chunkCache->caches[$chunkHash]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @var World */
|
||||
private $world;
|
||||
/** @var Compressor */
|
||||
|
11
src/network/mcpe/cache/CraftingDataCache.php
vendored
11
src/network/mcpe/cache/CraftingDataCache.php
vendored
@ -71,15 +71,14 @@ final class CraftingDataCache{
|
||||
*/
|
||||
private function buildCraftingDataCache(CraftingManager $manager) : CraftingDataPacket{
|
||||
Timings::$craftingDataCacheRebuild->startTiming();
|
||||
$pk = new CraftingDataPacket();
|
||||
$pk->cleanRecipes = true;
|
||||
|
||||
$counter = 0;
|
||||
$nullUUID = Uuid::fromString(Uuid::NIL);
|
||||
$converter = TypeConverter::getInstance();
|
||||
$recipesWithTypeIds = [];
|
||||
foreach($manager->getShapelessRecipes() as $list){
|
||||
foreach($list as $recipe){
|
||||
$pk->entries[] = new ProtocolShapelessRecipe(
|
||||
$recipesWithTypeIds[] = new ProtocolShapelessRecipe(
|
||||
CraftingDataPacket::ENTRY_SHAPELESS,
|
||||
Binary::writeInt(++$counter),
|
||||
array_map(function(Item $item) use ($converter) : RecipeIngredient{
|
||||
@ -104,7 +103,7 @@ final class CraftingDataCache{
|
||||
$inputs[$row][$column] = $converter->coreItemStackToRecipeIngredient($recipe->getIngredient($column, $row));
|
||||
}
|
||||
}
|
||||
$pk->entries[] = $r = new ProtocolShapedRecipe(
|
||||
$recipesWithTypeIds[] = $r = new ProtocolShapedRecipe(
|
||||
CraftingDataPacket::ENTRY_SHAPED,
|
||||
Binary::writeInt(++$counter),
|
||||
$inputs,
|
||||
@ -128,7 +127,7 @@ final class CraftingDataCache{
|
||||
};
|
||||
foreach($manager->getFurnaceRecipeManager($furnaceType)->getAll() as $recipe){
|
||||
$input = $converter->coreItemStackToNet($recipe->getInput());
|
||||
$pk->entries[] = new ProtocolFurnaceRecipe(
|
||||
$recipesWithTypeIds[] = new ProtocolFurnaceRecipe(
|
||||
CraftingDataPacket::ENTRY_FURNACE_DATA,
|
||||
$input->getId(),
|
||||
$input->getMeta(),
|
||||
@ -139,6 +138,6 @@ final class CraftingDataCache{
|
||||
}
|
||||
|
||||
Timings::$craftingDataCacheRebuild->stopTiming();
|
||||
return $pk;
|
||||
return CraftingDataPacket::create($recipesWithTypeIds, [], [], [], true);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\convert;
|
||||
|
||||
use pocketmine\data\bedrock\LegacyItemIdToStringIdMap;
|
||||
use pocketmine\network\mcpe\protocol\serializer\ItemTypeDictionary;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
@ -76,10 +77,7 @@ final class ItemTranslator{
|
||||
if($legacyStringToIntMapRaw === false){
|
||||
throw new AssumptionFailedError("Missing required resource file");
|
||||
}
|
||||
$legacyStringToIntMap = json_decode($legacyStringToIntMapRaw, true);
|
||||
if(!is_array($legacyStringToIntMap)){
|
||||
throw new AssumptionFailedError("Invalid mapping table format");
|
||||
}
|
||||
$legacyStringToIntMap = LegacyItemIdToStringIdMap::getInstance();
|
||||
|
||||
/** @phpstan-var array<string, int> $simpleMappings */
|
||||
$simpleMappings = [];
|
||||
@ -87,13 +85,14 @@ final class ItemTranslator{
|
||||
if(!is_string($oldId) || !is_string($newId)){
|
||||
throw new AssumptionFailedError("Invalid item table format");
|
||||
}
|
||||
if(!isset($legacyStringToIntMap[$oldId])){
|
||||
$intId = $legacyStringToIntMap->stringToLegacy($oldId);
|
||||
if($intId === null){
|
||||
//new item without a fixed legacy ID - we can't handle this right now
|
||||
continue;
|
||||
}
|
||||
$simpleMappings[$newId] = $legacyStringToIntMap[$oldId];
|
||||
$simpleMappings[$newId] = $intId;
|
||||
}
|
||||
foreach($legacyStringToIntMap as $stringId => $intId){
|
||||
foreach($legacyStringToIntMap->getStringToLegacyMap() as $stringId => $intId){
|
||||
if(isset($simpleMappings[$stringId])){
|
||||
throw new \UnexpectedValueException("Old ID $stringId collides with new ID");
|
||||
}
|
||||
@ -110,7 +109,12 @@ final class ItemTranslator{
|
||||
if(!is_numeric($meta) || !is_string($newId)){
|
||||
throw new AssumptionFailedError("Invalid item table format");
|
||||
}
|
||||
$complexMappings[$newId] = [$legacyStringToIntMap[$oldId], (int) $meta];
|
||||
$intId = $legacyStringToIntMap->stringToLegacy($oldId);
|
||||
if($intId === null){
|
||||
//new item without a fixed legacy ID - we can't handle this right now
|
||||
continue;
|
||||
}
|
||||
$complexMappings[$newId] = [$intId, (int) $meta];
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,10 +146,10 @@ final class ItemTranslator{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array{int, int}
|
||||
* @return int[]|null
|
||||
* @phpstan-return array{int, int}|null
|
||||
*/
|
||||
public function toNetworkId(int $internalId, int $internalMeta) : array{
|
||||
public function toNetworkIdQuiet(int $internalId, int $internalMeta) : ?array{
|
||||
if($internalMeta === -1){
|
||||
$internalMeta = 0x7fff;
|
||||
}
|
||||
@ -156,17 +160,27 @@ final class ItemTranslator{
|
||||
return [$this->simpleCoreToNetMapping[$internalId], $internalMeta];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("Unmapped ID/metadata combination $internalId:$internalMeta");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array{int, int}
|
||||
*/
|
||||
public function toNetworkId(int $internalId, int $internalMeta) : array{
|
||||
return $this->toNetworkIdQuiet($internalId, $internalMeta) ??
|
||||
throw new \InvalidArgumentException("Unmapped ID/metadata combination $internalId:$internalMeta");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array{int, int}
|
||||
* @throws TypeConversionException
|
||||
*/
|
||||
public function fromNetworkId(int $networkId, int $networkMeta, ?bool &$isComplexMapping = null) : array{
|
||||
if(isset($this->complexNetToCoreMapping[$networkId])){
|
||||
if($networkMeta !== 0){
|
||||
throw new \UnexpectedValueException("Unexpected non-zero network meta on complex item mapping");
|
||||
throw new TypeConversionException("Unexpected non-zero network meta on complex item mapping");
|
||||
}
|
||||
$isComplexMapping = true;
|
||||
return $this->complexNetToCoreMapping[$networkId];
|
||||
@ -175,12 +189,13 @@ final class ItemTranslator{
|
||||
if(isset($this->simpleNetToCoreMapping[$networkId])){
|
||||
return [$this->simpleNetToCoreMapping[$networkId], $networkMeta];
|
||||
}
|
||||
throw new \UnexpectedValueException("Unmapped network ID/metadata combination $networkId:$networkMeta");
|
||||
throw new TypeConversionException("Unmapped network ID/metadata combination $networkId:$networkMeta");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array{int, int}
|
||||
* @throws TypeConversionException
|
||||
*/
|
||||
public function fromNetworkIdWithWildcardHandling(int $networkId, int $networkMeta) : array{
|
||||
$isComplexMapping = false;
|
||||
|
35
src/network/mcpe/convert/TypeConversionException.php
Normal file
35
src/network/mcpe/convert/TypeConversionException.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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\network\mcpe\convert;
|
||||
|
||||
/**
|
||||
* Thrown by TypeConverter if a problem occurred during converting of network types to PM core types (e.g. invalid item
|
||||
* ID, invalid NBT, etc).
|
||||
*/
|
||||
final class TypeConversionException extends \RuntimeException{
|
||||
|
||||
public static function wrap(\Throwable $previous, ?string $prefix = null) : self{
|
||||
return new self(($prefix !== null ? $prefix . ": " : "") . $previous->getMessage(), 0, $previous);
|
||||
}
|
||||
}
|
@ -37,6 +37,7 @@ use pocketmine\item\Durable;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\network\mcpe\InventoryManager;
|
||||
@ -57,6 +58,7 @@ class TypeConverter{
|
||||
|
||||
private const DAMAGE_TAG = "Damage"; //TAG_Int
|
||||
private const DAMAGE_TAG_CONFLICT_RESOLUTION = "___Damage_ProtocolCollisionResolution___";
|
||||
private const PM_ID_TAG = "___Id___";
|
||||
private const PM_META_TAG = "___Meta___";
|
||||
|
||||
/** @var int */
|
||||
@ -142,26 +144,40 @@ class TypeConverter{
|
||||
}
|
||||
|
||||
$isBlockItem = $itemStack->getId() < 256;
|
||||
if($itemStack instanceof Durable and $itemStack->getDamage() > 0){
|
||||
if($nbt !== null){
|
||||
if(($existing = $nbt->getTag(self::DAMAGE_TAG)) !== null){
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
$nbt->setTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION, $existing);
|
||||
}
|
||||
}else{
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::DAMAGE_TAG, $itemStack->getDamage());
|
||||
}elseif($isBlockItem && $itemStack->getMeta() !== 0){
|
||||
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
||||
//client sends it back to us, because as of 1.16.220, blockitems quietly discard their metadata
|
||||
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
||||
|
||||
$idMeta = ItemTranslator::getInstance()->toNetworkIdQuiet($itemStack->getId(), $itemStack->getMeta());
|
||||
if($idMeta === null){
|
||||
//Display unmapped items as INFO_UPDATE, but stick something in their NBT to make sure they don't stack with
|
||||
//other unmapped items.
|
||||
[$id, $meta] = ItemTranslator::getInstance()->toNetworkId(ItemIds::INFO_UPDATE, 0);
|
||||
if($nbt === null){
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::PM_ID_TAG, $itemStack->getId());
|
||||
$nbt->setInt(self::PM_META_TAG, $itemStack->getMeta());
|
||||
}else{
|
||||
[$id, $meta] = $idMeta;
|
||||
|
||||
if($itemStack instanceof Durable and $itemStack->getDamage() > 0){
|
||||
if($nbt !== null){
|
||||
if(($existing = $nbt->getTag(self::DAMAGE_TAG)) !== null){
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
$nbt->setTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION, $existing);
|
||||
}
|
||||
}else{
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::DAMAGE_TAG, $itemStack->getDamage());
|
||||
}elseif($isBlockItem && $itemStack->getMeta() !== 0){
|
||||
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
||||
//client sends it back to us, because as of 1.16.220, blockitems quietly discard their metadata
|
||||
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
||||
if($nbt === null){
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::PM_META_TAG, $itemStack->getMeta());
|
||||
}
|
||||
}
|
||||
[$id, $meta] = ItemTranslator::getInstance()->toNetworkId($itemStack->getId(), $itemStack->getMeta());
|
||||
|
||||
$blockRuntimeId = 0;
|
||||
if($isBlockItem){
|
||||
@ -183,6 +199,9 @@ class TypeConverter{
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TypeConversionException
|
||||
*/
|
||||
public function netItemStackToCore(ItemStack $itemStack) : Item{
|
||||
if($itemStack->getId() === 0){
|
||||
return ItemFactory::getInstance()->get(ItemIds::AIR, 0, 0);
|
||||
@ -193,14 +212,16 @@ class TypeConverter{
|
||||
|
||||
if($compound !== null){
|
||||
$compound = clone $compound;
|
||||
if(($idTag = $compound->getTag(self::PM_ID_TAG)) instanceof IntTag){
|
||||
$id = $idTag->getValue();
|
||||
$compound->removeTag(self::PM_ID_TAG);
|
||||
}
|
||||
if(($damageTag = $compound->getTag(self::DAMAGE_TAG)) instanceof IntTag){
|
||||
$meta = $damageTag->getValue();
|
||||
$compound->removeTag(self::DAMAGE_TAG);
|
||||
if(($conflicted = $compound->getTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION)) !== null){
|
||||
$compound->removeTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION);
|
||||
$compound->setTag(self::DAMAGE_TAG, $conflicted);
|
||||
}elseif($compound->count() === 0){
|
||||
$compound = null;
|
||||
}
|
||||
}elseif(($metaTag = $compound->getTag(self::PM_META_TAG)) instanceof IntTag){
|
||||
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
||||
@ -208,18 +229,22 @@ class TypeConverter{
|
||||
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
||||
$meta = $metaTag->getValue();
|
||||
$compound->removeTag(self::PM_META_TAG);
|
||||
if($compound->count() === 0){
|
||||
$compound = null;
|
||||
}
|
||||
}
|
||||
if($compound->count() === 0){
|
||||
$compound = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ItemFactory::getInstance()->get(
|
||||
$id,
|
||||
$meta,
|
||||
$itemStack->getCount(),
|
||||
$compound
|
||||
);
|
||||
try{
|
||||
return ItemFactory::getInstance()->get(
|
||||
$id,
|
||||
$meta,
|
||||
$itemStack->getCount(),
|
||||
$compound
|
||||
);
|
||||
}catch(NbtException $e){
|
||||
throw TypeConversionException::wrap($e, "Bad itemstack NBT data");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,15 +264,23 @@ class TypeConverter{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws TypeConversionException
|
||||
*/
|
||||
public function createInventoryAction(NetworkInventoryAction $action, Player $player, InventoryManager $inventoryManager) : ?InventoryAction{
|
||||
if($action->oldItem->getItemStack()->equals($action->newItem->getItemStack())){
|
||||
//filter out useless noise in 1.13
|
||||
return null;
|
||||
}
|
||||
$old = $this->netItemStackToCore($action->oldItem->getItemStack());
|
||||
$new = $this->netItemStackToCore($action->newItem->getItemStack());
|
||||
try{
|
||||
$old = $this->netItemStackToCore($action->oldItem->getItemStack());
|
||||
}catch(TypeConversionException $e){
|
||||
throw TypeConversionException::wrap($e, "Inventory action: oldItem");
|
||||
}
|
||||
try{
|
||||
$new = $this->netItemStackToCore($action->newItem->getItemStack());
|
||||
}catch(TypeConversionException $e){
|
||||
throw TypeConversionException::wrap($e, "Inventory action: newItem");
|
||||
}
|
||||
switch($action->sourceType){
|
||||
case NetworkInventoryAction::SOURCE_CONTAINER:
|
||||
if($action->windowId === ContainerIds::UI and $action->inventorySlot > 0){
|
||||
@ -273,7 +306,7 @@ class TypeConverter{
|
||||
fn(Inventory $i) => $i instanceof LoomInventory);
|
||||
}
|
||||
if($mapped === null){
|
||||
throw new \UnexpectedValueException("Unmatched UI inventory slot offset $pSlot");
|
||||
throw new TypeConversionException("Unmatched UI inventory slot offset $pSlot");
|
||||
}
|
||||
[$slot, $window] = $mapped;
|
||||
}else{
|
||||
@ -284,10 +317,10 @@ class TypeConverter{
|
||||
return new SlotChangeAction($window, $slot, $old, $new);
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException("No open container with window ID $action->windowId");
|
||||
throw new TypeConversionException("No open container with window ID $action->windowId");
|
||||
case NetworkInventoryAction::SOURCE_WORLD:
|
||||
if($action->inventorySlot !== NetworkInventoryAction::ACTION_MAGIC_SLOT_DROP_ITEM){
|
||||
throw new \UnexpectedValueException("Only expecting drop-item world actions from the client!");
|
||||
throw new TypeConversionException("Only expecting drop-item world actions from the client!");
|
||||
}
|
||||
|
||||
return new DropItemAction($new);
|
||||
@ -298,7 +331,7 @@ class TypeConverter{
|
||||
case NetworkInventoryAction::ACTION_MAGIC_SLOT_CREATIVE_CREATE_ITEM:
|
||||
return new CreateItemAction($old);
|
||||
default:
|
||||
throw new \UnexpectedValueException("Unexpected creative action type $action->inventorySlot");
|
||||
throw new TypeConversionException("Unexpected creative action type $action->inventorySlot");
|
||||
|
||||
}
|
||||
case NetworkInventoryAction::SOURCE_TODO:
|
||||
@ -310,9 +343,9 @@ class TypeConverter{
|
||||
}
|
||||
|
||||
//TODO: more stuff
|
||||
throw new \UnexpectedValueException("No open container with window ID $action->windowId");
|
||||
throw new TypeConversionException("No open container with window ID $action->windowId");
|
||||
default:
|
||||
throw new \UnexpectedValueException("Unknown inventory source type $action->sourceType");
|
||||
throw new TypeConversionException("Unknown inventory source type $action->sourceType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\handler;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerAction;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class DeathPacketHandler extends PacketHandler{
|
||||
@ -49,7 +50,7 @@ class DeathPacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
if($packet->action === PlayerActionPacket::ACTION_RESPAWN){
|
||||
if($packet->action === PlayerAction::RESPAWN){
|
||||
$this->player->respawn();
|
||||
return true;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\convert\SkinAdapterSingleton;
|
||||
use pocketmine\network\mcpe\convert\TypeConversionException;
|
||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||
use pocketmine\network\mcpe\InventoryManager;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
@ -82,6 +83,7 @@ use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\MismatchTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\NetworkInventoryAction;
|
||||
@ -91,6 +93,7 @@ use pocketmine\network\mcpe\protocol\types\inventory\UIInventorySlotOffset;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\WindowTypes;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerAction;
|
||||
use pocketmine\network\PacketHandlingException;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
@ -198,14 +201,14 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleActorEvent(ActorEventPacket $packet) : bool{
|
||||
if($packet->entityRuntimeId !== $this->player->getId()){
|
||||
if($packet->actorRuntimeId !== $this->player->getId()){
|
||||
//TODO HACK: EATING_ITEM is sent back to the server when the server sends it for other players (1.14 bug, maybe earlier)
|
||||
return $packet->event === ActorEventPacket::EATING_ITEM;
|
||||
return $packet->actorRuntimeId === ActorEvent::EATING_ITEM;
|
||||
}
|
||||
$this->player->doCloseInventory();
|
||||
|
||||
switch($packet->event){
|
||||
case ActorEventPacket::EATING_ITEM: //TODO: ignore this and handle it server-side
|
||||
switch($packet->eventId){
|
||||
case ActorEvent::EATING_ITEM: //TODO: ignore this and handle it server-side
|
||||
$item = $this->player->getInventory()->getItemInHand();
|
||||
if($item->isNull()){
|
||||
return false;
|
||||
@ -271,8 +274,8 @@ class InGamePacketHandler extends PacketHandler{
|
||||
if($action !== null){
|
||||
$actions[] = $action;
|
||||
}
|
||||
}catch(\UnexpectedValueException $e){
|
||||
$this->session->getLogger()->debug("Unhandled inventory action: " . $e->getMessage());
|
||||
}catch(TypeConversionException $e){
|
||||
$this->session->getLogger()->debug("Error unpacking inventory action: " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -355,12 +358,12 @@ class InGamePacketHandler extends PacketHandler{
|
||||
switch($data->getActionType()){
|
||||
case UseItemTransactionData::ACTION_CLICK_BLOCK:
|
||||
//TODO: start hack for client spam bug
|
||||
$clickPos = $data->getClickPos();
|
||||
$clickPos = $data->getClickPosition();
|
||||
$spamBug = ($this->lastRightClickData !== null and
|
||||
microtime(true) - $this->lastRightClickTime < 0.1 and //100ms
|
||||
$this->lastRightClickData->getPlayerPos()->distanceSquared($data->getPlayerPos()) < 0.00001 and
|
||||
$this->lastRightClickData->getBlockPos()->equals($data->getBlockPos()) and
|
||||
$this->lastRightClickData->getClickPos()->distanceSquared($clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error
|
||||
$this->lastRightClickData->getPlayerPosition()->distanceSquared($data->getPlayerPosition()) < 0.00001 and
|
||||
$this->lastRightClickData->getBlockPosition()->equals($data->getBlockPosition()) and
|
||||
$this->lastRightClickData->getClickPosition()->distanceSquared($clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error
|
||||
);
|
||||
//get rid of continued spam if the player clicks and holds right-click
|
||||
$this->lastRightClickData = $data;
|
||||
@ -370,9 +373,10 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
//TODO: end hack for client spam bug
|
||||
|
||||
$blockPos = $data->getBlockPos();
|
||||
if(!$this->player->interactBlock($blockPos, $data->getFace(), $clickPos)){
|
||||
$this->onFailedBlockAction($blockPos, $data->getFace());
|
||||
$blockPos = $data->getBlockPosition();
|
||||
$vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
|
||||
if(!$this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos)){
|
||||
$this->onFailedBlockAction($vBlockPos, $data->getFace());
|
||||
}elseif(
|
||||
!array_key_exists($windowId = InventoryManager::HARDCODED_CRAFTING_GRID_WINDOW_ID, $this->openHardcodedWindows) &&
|
||||
$this->player->getCraftingGrid()->getGridWidth() === CraftingGrid::SIZE_BIG
|
||||
@ -380,7 +384,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
//TODO: HACK! crafting grid doesn't fit very well into the current PM container system, so this hack
|
||||
//allows it to carry on working approximately the same way as it did in 1.14
|
||||
$this->openHardcodedWindows[$windowId] = true;
|
||||
$this->session->sendDataPacket(ContainerOpenPacket::blockInvVec3(
|
||||
$this->session->sendDataPacket(ContainerOpenPacket::blockInv(
|
||||
InventoryManager::HARDCODED_CRAFTING_GRID_WINDOW_ID,
|
||||
WindowTypes::WORKBENCH,
|
||||
$blockPos
|
||||
@ -388,9 +392,10 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
return true;
|
||||
case UseItemTransactionData::ACTION_BREAK_BLOCK:
|
||||
$blockPos = $data->getBlockPos();
|
||||
if(!$this->player->breakBlock($blockPos)){
|
||||
$this->onFailedBlockAction($blockPos, null);
|
||||
$blockPos = $data->getBlockPosition();
|
||||
$vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
|
||||
if(!$this->player->breakBlock($vBlockPos)){
|
||||
$this->onFailedBlockAction($vBlockPos, null);
|
||||
}
|
||||
return true;
|
||||
case UseItemTransactionData::ACTION_CLICK_AIR:
|
||||
@ -431,7 +436,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
private function handleUseItemOnEntityTransaction(UseItemOnEntityTransactionData $data) : bool{
|
||||
$target = $this->player->getWorld()->getEntity($data->getEntityRuntimeId());
|
||||
$target = $this->player->getWorld()->getEntity($data->getActorRuntimeId());
|
||||
if($target === null){
|
||||
return false;
|
||||
}
|
||||
@ -441,7 +446,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
//TODO: use transactiondata for rollbacks here
|
||||
switch($data->getActionType()){
|
||||
case UseItemOnEntityTransactionData::ACTION_INTERACT:
|
||||
if(!$this->player->interactEntity($target, $data->getClickPos())){
|
||||
if(!$this->player->interactEntity($target, $data->getClickPosition())){
|
||||
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
|
||||
}
|
||||
return true;
|
||||
@ -497,7 +502,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
//TODO: implement handling for this where it matters
|
||||
return true;
|
||||
}
|
||||
$target = $this->player->getWorld()->getEntity($packet->target);
|
||||
$target = $this->player->getWorld()->getEntity($packet->targetActorRuntimeId);
|
||||
if($target === null){
|
||||
return false;
|
||||
}
|
||||
@ -520,7 +525,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
return $this->player->pickBlock(new Vector3($packet->blockX, $packet->blockY, $packet->blockZ), $packet->addUserData);
|
||||
return $this->player->pickBlock(new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()), $packet->addUserData);
|
||||
}
|
||||
|
||||
public function handleActorPickRequest(ActorPickRequestPacket $packet) : bool{
|
||||
@ -528,63 +533,63 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
$pos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||
$pos = new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
|
||||
|
||||
switch($packet->action){
|
||||
case PlayerActionPacket::ACTION_START_BREAK:
|
||||
case PlayerAction::START_BREAK:
|
||||
if(!$this->player->attackBlock($pos, $packet->face)){
|
||||
$this->onFailedBlockAction($pos, $packet->face);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PlayerActionPacket::ACTION_ABORT_BREAK:
|
||||
case PlayerActionPacket::ACTION_STOP_BREAK:
|
||||
case PlayerAction::ABORT_BREAK:
|
||||
case PlayerAction::STOP_BREAK:
|
||||
$this->player->stopBreakBlock($pos);
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_START_SLEEPING:
|
||||
case PlayerAction::START_SLEEPING:
|
||||
//unused
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_STOP_SLEEPING:
|
||||
case PlayerAction::STOP_SLEEPING:
|
||||
$this->player->stopSleep();
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_JUMP:
|
||||
case PlayerAction::JUMP:
|
||||
$this->player->jump();
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_START_SPRINT:
|
||||
case PlayerAction::START_SPRINT:
|
||||
if(!$this->player->toggleSprint(true)){
|
||||
$this->player->sendData([$this->player]);
|
||||
}
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_STOP_SPRINT:
|
||||
case PlayerAction::STOP_SPRINT:
|
||||
if(!$this->player->toggleSprint(false)){
|
||||
$this->player->sendData([$this->player]);
|
||||
}
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_START_SNEAK:
|
||||
case PlayerAction::START_SNEAK:
|
||||
if(!$this->player->toggleSneak(true)){
|
||||
$this->player->sendData([$this->player]);
|
||||
}
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_STOP_SNEAK:
|
||||
case PlayerAction::STOP_SNEAK:
|
||||
if(!$this->player->toggleSneak(false)){
|
||||
$this->player->sendData([$this->player]);
|
||||
}
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_START_GLIDE:
|
||||
case PlayerActionPacket::ACTION_STOP_GLIDE:
|
||||
case PlayerAction::START_GLIDE:
|
||||
case PlayerAction::STOP_GLIDE:
|
||||
break; //TODO
|
||||
case PlayerActionPacket::ACTION_CRACK_BREAK:
|
||||
case PlayerAction::CRACK_BREAK:
|
||||
$this->player->continueBreakBlock($pos, $packet->face);
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_START_SWIMMING:
|
||||
case PlayerAction::START_SWIMMING:
|
||||
break; //TODO
|
||||
case PlayerActionPacket::ACTION_STOP_SWIMMING:
|
||||
case PlayerAction::STOP_SWIMMING:
|
||||
//TODO: handle this when it doesn't spam every damn tick (yet another spam bug!!)
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_INTERACT_BLOCK: //TODO: ignored (for now)
|
||||
case PlayerAction::INTERACT_BLOCK: //TODO: ignored (for now)
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_CREATIVE_PLAYER_DESTROY_BLOCK:
|
||||
case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
|
||||
//TODO: do we need to handle this?
|
||||
break;
|
||||
default:
|
||||
@ -627,7 +632,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
if($packet->entityUniqueId !== $this->player->getId()){
|
||||
if($packet->targetActorUniqueId !== $this->player->getId()){
|
||||
return false; //TODO: operators can change other people's permissions using this
|
||||
}
|
||||
|
||||
@ -647,13 +652,13 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleBlockActorData(BlockActorDataPacket $packet) : bool{
|
||||
$pos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||
$pos = new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
|
||||
if($pos->distanceSquared($this->player->getLocation()) > 10000){
|
||||
return false;
|
||||
}
|
||||
|
||||
$block = $this->player->getLocation()->getWorld()->getBlock($pos);
|
||||
$nbt = $packet->namedtag->getRoot();
|
||||
$nbt = $packet->nbt->getRoot();
|
||||
if(!($nbt instanceof CompoundTag)) throw new AssumptionFailedError("PHPStan should ensure this is a CompoundTag"); //for phpstorm's benefit
|
||||
|
||||
if($block instanceof BaseSign){
|
||||
@ -677,7 +682,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->session->getLogger()->debug("Invalid sign update data: " . base64_encode($packet->namedtag->getEncodedNbt()));
|
||||
$this->session->getLogger()->debug("Invalid sign update data: " . base64_encode($packet->nbt->getEncodedNbt()));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -711,9 +716,10 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
$block = $this->player->getWorld()->getBlockAt($packet->x, $packet->y, $packet->z);
|
||||
$blockPosition = $packet->blockPosition;
|
||||
$block = $this->player->getWorld()->getBlockAt($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ());
|
||||
if($block instanceof ItemFrame and $block->getFramedItem() !== null){
|
||||
return $this->player->attackBlock(new Vector3($packet->x, $packet->y, $packet->z), $block->getFacing());
|
||||
return $this->player->attackBlock(new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ()), $block->getFacing());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -31,9 +31,11 @@ use pocketmine\network\mcpe\InventoryManager;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\network\mcpe\protocol\types\BoolGameRule;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\Experiments;
|
||||
use pocketmine\network\mcpe\protocol\types\LevelSettings;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerMovementSettings;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerMovementType;
|
||||
use pocketmine\network\mcpe\protocol\types\SpawnSettings;
|
||||
@ -64,39 +66,46 @@ class PreSpawnPacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function setUp() : void{
|
||||
$spawnPosition = $this->player->getSpawn();
|
||||
$location = $this->player->getLocation();
|
||||
|
||||
$pk = new StartGamePacket();
|
||||
$pk->entityUniqueId = $this->player->getId();
|
||||
$pk->entityRuntimeId = $this->player->getId();
|
||||
$pk->playerGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->player->getGamemode());
|
||||
$pk->playerPosition = $this->player->getOffsetPosition($location);
|
||||
$pk->pitch = $location->pitch;
|
||||
$pk->yaw = $location->yaw;
|
||||
$pk->seed = -1;
|
||||
$pk->spawnSettings = new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT, "", DimensionIds::OVERWORLD); //TODO: implement this properly
|
||||
$pk->worldGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->server->getGamemode());
|
||||
$pk->difficulty = $location->getWorld()->getDifficulty();
|
||||
$pk->spawnX = $spawnPosition->getFloorX();
|
||||
$pk->spawnY = $spawnPosition->getFloorY();
|
||||
$pk->spawnZ = $spawnPosition->getFloorZ();
|
||||
$pk->hasAchievementsDisabled = true;
|
||||
$pk->time = $location->getWorld()->getTime();
|
||||
$pk->eduEditionOffer = 0;
|
||||
$pk->rainLevel = 0; //TODO: implement these properly
|
||||
$pk->lightningLevel = 0;
|
||||
$pk->commandsEnabled = true;
|
||||
$pk->gameRules = [
|
||||
$levelSettings = new LevelSettings();
|
||||
$levelSettings->seed = -1;
|
||||
$levelSettings->spawnSettings = new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT, "", DimensionIds::OVERWORLD); //TODO: implement this properly
|
||||
$levelSettings->worldGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->server->getGamemode());
|
||||
$levelSettings->difficulty = $location->getWorld()->getDifficulty();
|
||||
$levelSettings->spawnPosition = BlockPosition::fromVector3($location->getWorld()->getSpawnLocation());
|
||||
$levelSettings->hasAchievementsDisabled = true;
|
||||
$levelSettings->time = $location->getWorld()->getTime();
|
||||
$levelSettings->eduEditionOffer = 0;
|
||||
$levelSettings->rainLevel = 0; //TODO: implement these properly
|
||||
$levelSettings->lightningLevel = 0;
|
||||
$levelSettings->commandsEnabled = true;
|
||||
$levelSettings->gameRules = [
|
||||
"naturalregeneration" => new BoolGameRule(false, false) //Hack for client side regeneration
|
||||
];
|
||||
$pk->experiments = new Experiments([], false);
|
||||
$pk->levelId = "";
|
||||
$pk->worldName = $this->server->getMotd();
|
||||
$pk->itemTable = GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(); //TODO: check if this is actually needed
|
||||
$pk->playerMovementSettings = new PlayerMovementSettings(PlayerMovementType::LEGACY, 0, false);
|
||||
$pk->serverSoftwareVersion = sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true));
|
||||
$this->session->sendDataPacket($pk);
|
||||
$levelSettings->experiments = new Experiments([], false);
|
||||
|
||||
$this->session->sendDataPacket(StartGamePacket::create(
|
||||
$this->player->getId(),
|
||||
$this->player->getId(),
|
||||
TypeConverter::getInstance()->coreGameModeToProtocol($this->player->getGamemode()),
|
||||
$this->player->getOffsetPosition($location),
|
||||
$location->pitch,
|
||||
$location->yaw,
|
||||
$levelSettings,
|
||||
"",
|
||||
$this->server->getMotd(),
|
||||
"",
|
||||
false,
|
||||
new PlayerMovementSettings(PlayerMovementType::LEGACY, 0, false),
|
||||
0,
|
||||
0,
|
||||
"",
|
||||
false,
|
||||
sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true)),
|
||||
[],
|
||||
GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries()
|
||||
));
|
||||
|
||||
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
||||
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getBiomeDefs());
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\lang\KnownTranslationKeys;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
@ -34,6 +35,7 @@ use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\Experiments;
|
||||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackInfoEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackStackEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackType;
|
||||
use pocketmine\resourcepacks\ResourcePack;
|
||||
use pocketmine\resourcepacks\ResourcePackManager;
|
||||
use function array_map;
|
||||
@ -113,7 +115,9 @@ class ResourcePacksPacketHandler extends PacketHandler{
|
||||
self::PACK_CHUNK_SIZE,
|
||||
(int) ceil($pack->getPackSize() / self::PACK_CHUNK_SIZE),
|
||||
$pack->getPackSize(),
|
||||
$pack->getSha256()
|
||||
$pack->getSha256(),
|
||||
false,
|
||||
ResourcePackType::ADDON //TODO: this might be an addon (not behaviour pack), needed to properly support client-side custom items
|
||||
));
|
||||
}
|
||||
$this->session->getLogger()->debug("Player requested download of " . count($packet->packIds) . " resource packs");
|
||||
@ -130,7 +134,7 @@ class ResourcePacksPacketHandler extends PacketHandler{
|
||||
//we don't force here, because it doesn't have user-facing effects
|
||||
//but it does have an annoying side-effect when true: it makes
|
||||
//the client remove its own non-server-supplied resource packs.
|
||||
$this->session->sendDataPacket(ResourcePackStackPacket::create($stack, [], false, new Experiments([], false)));
|
||||
$this->session->sendDataPacket(ResourcePackStackPacket::create($stack, [], false, ProtocolInfo::MINECRAFT_VERSION_NETWORK, new Experiments([], false)));
|
||||
$this->session->getLogger()->debug("Applying resource pack stack");
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_COMPLETED:
|
||||
|
@ -35,7 +35,6 @@ use pocketmine\network\Network;
|
||||
use pocketmine\network\PacketHandlingException;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\snooze\SleeperNotifier;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\Utils;
|
||||
use raklib\protocol\EncapsulatedPacket;
|
||||
use raklib\protocol\PacketReliability;
|
||||
@ -51,7 +50,6 @@ use function mt_rand;
|
||||
use function random_bytes;
|
||||
use function rtrim;
|
||||
use function substr;
|
||||
use const PTHREADS_INHERIT_CONSTANTS;
|
||||
|
||||
class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
/**
|
||||
@ -122,7 +120,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
while($this->eventReceiver->handle($this));
|
||||
});
|
||||
$this->server->getLogger()->debug("Waiting for RakLib to start...");
|
||||
$this->rakLib->startAndWait(PTHREADS_INHERIT_CONSTANTS); //HACK: MainLogger needs constants for exception logging
|
||||
$this->rakLib->startAndWait();
|
||||
$this->server->getLogger()->debug("RakLib booted successfully");
|
||||
}
|
||||
|
||||
@ -193,10 +191,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
$logger->error("Bad packet (error ID $errorId): " . $e->getMessage());
|
||||
|
||||
//intentionally doesn't use logException, we don't want spammy packet error traces to appear in release mode
|
||||
$logger->debug("Origin: " . Filesystem::cleanPath($e->getFile()) . "(" . $e->getLine() . ")");
|
||||
foreach(Utils::printableTrace($e->getTrace()) as $frame){
|
||||
$logger->debug($frame);
|
||||
}
|
||||
$logger->debug(implode("\n", Utils::printableExceptionInfo($e)));
|
||||
$session->disconnect("Packet processing error (Error ID: $errorId)");
|
||||
$this->interface->blockAddress($address, 5);
|
||||
}
|
||||
|
@ -32,10 +32,8 @@ use pocketmine\network\mcpe\protocol\serializer\PacketSerializerContext;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\PalettedBlockArray;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
use function count;
|
||||
use function str_repeat;
|
||||
|
||||
final class ChunkSerializer{
|
||||
|
||||
@ -48,7 +46,7 @@ final class ChunkSerializer{
|
||||
* Chunks are sent in a stack, so every chunk below the top non-empty one must be sent.
|
||||
*/
|
||||
public static function getSubChunkCount(Chunk $chunk) : int{
|
||||
for($count = $chunk->getSubChunks()->count(); $count > 0; --$count){
|
||||
for($count = count($chunk->getSubChunks()); $count > 0; --$count){
|
||||
if($chunk->getSubChunk($count - 1)->isEmptyFast()){
|
||||
continue;
|
||||
}
|
||||
@ -83,23 +81,18 @@ final class ChunkSerializer{
|
||||
$stream->putByte(count($layers));
|
||||
|
||||
foreach($layers as $blocks){
|
||||
if($blocks->getBitsPerBlock() === 0){
|
||||
//TODO: we use these in memory, but the game doesn't support them yet
|
||||
//polyfill them with 1-bpb instead
|
||||
$bitsPerBlock = 1;
|
||||
$words = str_repeat("\x00", PalettedBlockArray::getExpectedWordArraySize(1));
|
||||
}else{
|
||||
$bitsPerBlock = $blocks->getBitsPerBlock();
|
||||
$words = $blocks->getWordArray();
|
||||
}
|
||||
$bitsPerBlock = $blocks->getBitsPerBlock();
|
||||
$words = $blocks->getWordArray();
|
||||
$stream->putByte(($bitsPerBlock << 1) | ($persistentBlockStates ? 0 : 1));
|
||||
$stream->put($words);
|
||||
$palette = $blocks->getPalette();
|
||||
|
||||
//these LSHIFT by 1 uvarints are optimizations: the client expects zigzag varints here
|
||||
//but since we know they are always unsigned, we can avoid the extra fcall overhead of
|
||||
//zigzag and just shift directly.
|
||||
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
||||
if($bitsPerBlock !== 0){
|
||||
//these LSHIFT by 1 uvarints are optimizations: the client expects zigzag varints here
|
||||
//but since we know they are always unsigned, we can avoid the extra fcall overhead of
|
||||
//zigzag and just shift directly.
|
||||
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
||||
}
|
||||
if($persistentBlockStates){
|
||||
$nbtSerializer = new NetworkNbtSerializer();
|
||||
foreach($palette as $p){
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\network\upnp;
|
||||
|
||||
use pocketmine\network\NetworkInterface;
|
||||
use pocketmine\utils\Internet;
|
||||
use pocketmine\utils\InternetException;
|
||||
|
||||
final class UPnPNetworkInterface implements NetworkInterface{
|
||||
|
||||
@ -50,12 +51,12 @@ final class UPnPNetworkInterface implements NetworkInterface{
|
||||
|
||||
public function start() : void{
|
||||
$this->logger->info("Attempting to portforward...");
|
||||
$this->serviceURL = UPnP::getServiceUrl();
|
||||
|
||||
try{
|
||||
$this->serviceURL = UPnP::getServiceUrl();
|
||||
UPnP::portForward($this->serviceURL, Internet::getInternalIP(), $this->port, $this->port);
|
||||
$this->logger->info("Forwarded $this->ip:$this->port to external port $this->port");
|
||||
}catch(UPnPException $e){
|
||||
}catch(UPnPException | InternetException $e){
|
||||
$this->logger->error("UPnP portforward failed: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -51,65 +51,56 @@ abstract class DefaultPermissions{
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::BROADCAST_ADMIN, "Allows the user to receive administrative broadcasts"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::BROADCAST_USER, "Allows the user to receive user broadcasts"), [$everyoneRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_ADD, "Allows the user to add a player to the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_REMOVE, "Allows the user to remove a player from the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_RELOAD, "Allows the user to reload the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_ENABLE, "Allows the user to enable the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_DISABLE, "Allows the user to disable the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_LIST, "Allows the user to list all players on the server whitelist"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_BAN_PLAYER, "Allows the user to ban players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_BAN_IP, "Allows the user to ban IP addresses"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_BAN_LIST, "Allows the user to list banned players"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_UNBAN_PLAYER, "Allows the user to unban players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_UNBAN_IP, "Allows the user to unban IP addresses"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_BAN_PLAYER, "Allows the user to ban players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_CLEAR_OTHER, "Allows the user to clear inventory of other players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_CLEAR_SELF, "Allows the user to clear their own inventory"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_DEFAULTGAMEMODE, "Allows the user to change the default gamemode"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_DIFFICULTY, "Allows the user to change the game difficulty"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_DUMPMEMORY, "Allows the user to dump memory contents"), [$consoleRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_EFFECT, "Allows the user to give/take potion effects"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_ENCHANT, "Allows the user to enchant items"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_GAMEMODE, "Allows the user to change the gamemode of players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_GC, "Allows the user to fire garbage collection tasks"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_GIVE, "Allows the user to give items to players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_HELP, "Allows the user to view the help menu"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_KICK, "Allows the user to kick players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_KILL_OTHER, "Allows the user to kill other players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_KILL_SELF, "Allows the user to commit suicide"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_LIST, "Allows the user to list all online players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_ME, "Allows the user to perform a chat action"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_OP_GIVE, "Allows the user to give a player operator status"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_OP_TAKE, "Allows the user to take a player's operator status"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SAVE_ENABLE, "Allows the user to enable automatic saving"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_PARTICLE, "Allows the user to create particle effects"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_PLUGINS, "Allows the user to view the list of plugins"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SAVE_DISABLE, "Allows the user to disable automatic saving"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SAVE_ENABLE, "Allows the user to enable automatic saving"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SAVE_PERFORM, "Allows the user to perform a manual save"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SAY, "Allows the user to talk as the console"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SEED, "Allows the user to view the seed of the world"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SETWORLDSPAWN, "Allows the user to change the world spawn"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SPAWNPOINT, "Allows the user to change player's spawnpoint"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_STATUS, "Allows the user to view the server performance"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_STOP, "Allows the user to stop the server"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TELEPORT, "Allows the user to teleport players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TELL, "Allows the user to privately message another player"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIME_ADD, "Allows the user to fast-forward time"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIME_QUERY, "Allows the user query the time"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIME_SET, "Allows the user to change the time"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIME_START, "Allows the user to restart the time"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIME_STOP, "Allows the user to stop the time"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIME_QUERY, "Allows the user query the time"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_KILL_SELF, "Allows the user to commit suicide"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_KILL_OTHER, "Allows the user to kill other players"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_CLEAR_SELF, "Allows the user to clear their own inventory"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_CLEAR_OTHER, "Allows the user to clear inventory of other players"), [$operatorRoot]);
|
||||
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_ME, "Allows the user to perform a chat action"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TELL, "Allows the user to privately message another player"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SAY, "Allows the user to talk as the console"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_GIVE, "Allows the user to give items to players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_EFFECT, "Allows the user to give/take potion effects"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_ENCHANT, "Allows the user to enchant items"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_PARTICLE, "Allows the user to create particle effects"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TELEPORT, "Allows the user to teleport players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_KICK, "Allows the user to kick players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_STOP, "Allows the user to stop the server"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_LIST, "Allows the user to list all online players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_HELP, "Allows the user to view the help menu"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_PLUGINS, "Allows the user to view the list of plugins"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_VERSION, "Allows the user to view the version of the server"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_GAMEMODE, "Allows the user to change the gamemode of players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_DEFAULTGAMEMODE, "Allows the user to change the default gamemode"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SEED, "Allows the user to view the seed of the world"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_STATUS, "Allows the user to view the server performance"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_GC, "Allows the user to fire garbage collection tasks"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_DUMPMEMORY, "Allows the user to dump memory contents"), [$consoleRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIMINGS, "Allows the user to records timings for all plugin events"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SPAWNPOINT, "Allows the user to change player's spawnpoint"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_SETWORLDSPAWN, "Allows the user to change the world spawn"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TRANSFERSERVER, "Allows the user to transfer self to another server"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TIMINGS, "Allows the user to record timings to analyse server performance"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TITLE, "Allows the user to send a title to the specified player"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_DIFFICULTY, "Allows the user to change the game difficulty"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_TRANSFERSERVER, "Allows the user to transfer self to another server"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_UNBAN_IP, "Allows the user to unban IP addresses"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_UNBAN_PLAYER, "Allows the user to unban players"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_VERSION, "Allows the user to view the version of the server"), [$everyoneRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_ADD, "Allows the user to add a player to the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_DISABLE, "Allows the user to disable the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_ENABLE, "Allows the user to enable the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_LIST, "Allows the user to list all players on the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_RELOAD, "Allows the user to reload the server whitelist"), [$operatorRoot]);
|
||||
self::registerPermission(new Permission(DefaultPermissionNames::COMMAND_WHITELIST_REMOVE, "Allows the user to remove a player from the server whitelist"), [$operatorRoot]);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class PermissionParser{
|
||||
/**
|
||||
* @param bool|string $value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws PermissionParserException
|
||||
*/
|
||||
public static function defaultFromString($value) : string{
|
||||
if(is_bool($value)){
|
||||
@ -70,7 +70,7 @@ class PermissionParser{
|
||||
return self::DEFAULT_STRING_MAP[$lower];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("Unknown permission default name \"$value\"");
|
||||
throw new PermissionParserException("Unknown permission default name \"$value\"");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,6 +79,7 @@ class PermissionParser{
|
||||
*
|
||||
* @return Permission[][]
|
||||
* @phpstan-return array<string, list<Permission>>
|
||||
* @throws PermissionParserException
|
||||
*/
|
||||
public static function loadPermissions(array $data, string $default = self::DEFAULT_FALSE) : array{
|
||||
$result = [];
|
||||
@ -89,7 +90,7 @@ class PermissionParser{
|
||||
}
|
||||
|
||||
if(isset($entry["children"])){
|
||||
throw new \InvalidArgumentException("Nested permission declarations are no longer supported. Declare each permission separately.");
|
||||
throw new PermissionParserException("Nested permission declarations are no longer supported. Declare each permission separately.");
|
||||
}
|
||||
|
||||
if(isset($entry["description"])){
|
||||
|
31
src/permission/PermissionParserException.php
Normal file
31
src/permission/PermissionParserException.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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\permission;
|
||||
|
||||
/**
|
||||
* Thrown by PermissionParser when it encounters data that it doesn't like.
|
||||
*/
|
||||
final class PermissionParserException extends \RuntimeException{
|
||||
|
||||
}
|
@ -63,7 +63,6 @@ use pocketmine\event\player\PlayerItemUseEvent;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\player\PlayerJumpEvent;
|
||||
use pocketmine\event\player\PlayerKickEvent;
|
||||
use pocketmine\event\player\PlayerLoginEvent;
|
||||
use pocketmine\event\player\PlayerMoveEvent;
|
||||
use pocketmine\event\player\PlayerQuitEvent;
|
||||
use pocketmine\event\player\PlayerRespawnEvent;
|
||||
@ -98,6 +97,7 @@ use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\BlockPosition;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
|
||||
@ -133,7 +133,6 @@ use function max;
|
||||
use function microtime;
|
||||
use function min;
|
||||
use function preg_match;
|
||||
use function round;
|
||||
use function spl_object_id;
|
||||
use function sqrt;
|
||||
use function strlen;
|
||||
@ -272,32 +271,13 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
|
||||
$world = $spawnLocation->getWorld();
|
||||
//load the spawn chunk so we can see the terrain
|
||||
$world->registerChunkLoader($this->chunkLoader, $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE, true);
|
||||
$world->registerChunkListener($this, $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE);
|
||||
$this->usedChunks[World::chunkHash($spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE)] = UsedChunkStatus::NEEDED();
|
||||
$xSpawnChunk = $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE;
|
||||
$zSpawnChunk = $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE;
|
||||
$world->registerChunkLoader($this->chunkLoader, $xSpawnChunk, $zSpawnChunk, true);
|
||||
$world->registerChunkListener($this, $xSpawnChunk, $zSpawnChunk);
|
||||
$this->usedChunks[World::chunkHash($xSpawnChunk, $zSpawnChunk)] = UsedChunkStatus::NEEDED();
|
||||
|
||||
parent::__construct($spawnLocation, $this->playerInfo->getSkin(), $namedtag);
|
||||
|
||||
$ev = new PlayerLoginEvent($this, "Plugin reason");
|
||||
$ev->call();
|
||||
if($ev->isCancelled() or !$this->isConnected()){
|
||||
$this->disconnect($ev->getKickMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->server->getLogger()->info($this->getServer()->getLanguage()->translate(KnownTranslationFactory::pocketmine_player_logIn(
|
||||
TextFormat::AQUA . $this->username . TextFormat::WHITE,
|
||||
$session->getIp(),
|
||||
(string) $session->getPort(),
|
||||
(string) $this->id,
|
||||
$this->getWorld()->getDisplayName(),
|
||||
(string) round($this->location->x, 4),
|
||||
(string) round($this->location->y, 4),
|
||||
(string) round($this->location->z, 4)
|
||||
)));
|
||||
|
||||
$this->server->addOnlinePlayer($this);
|
||||
}
|
||||
|
||||
protected function initHumanData(CompoundTag $nbt) : void{
|
||||
@ -414,7 +394,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}
|
||||
|
||||
public function spawnTo(Player $player) : void{
|
||||
if($this->isAlive() and $player->isAlive() and $player->getWorld() === $this->getWorld() and $player->canSee($this) and !$this->isSpectator()){
|
||||
if($this->isAlive() and $player->isAlive() and $player->canSee($this) and !$this->isSpectator()){
|
||||
parent::spawnTo($player);
|
||||
}
|
||||
}
|
||||
@ -2206,7 +2186,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$properties->setGenericFlag(EntityMetadataFlags::ACTION, $this->startAction > -1);
|
||||
|
||||
$properties->setPlayerFlag(PlayerMetadataFlags::SLEEP, $this->sleeping !== null);
|
||||
$properties->setBlockPos(EntityMetadataProperties::PLAYER_BED_POSITION, $this->sleeping ?? new Vector3(0, 0, 0));
|
||||
$properties->setBlockPos(EntityMetadataProperties::PLAYER_BED_POSITION, $this->sleeping !== null ? BlockPosition::fromVector3($this->sleeping) : new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public function sendData(?array $targets, ?array $data = null) : void{
|
||||
|
@ -28,6 +28,7 @@ use pocketmine\entity\animation\ArmSwingAnimation;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\LevelEvent;
|
||||
use pocketmine\world\particle\BlockPunchParticle;
|
||||
use pocketmine\world\sound\BlockPunchSound;
|
||||
use function abs;
|
||||
@ -70,7 +71,7 @@ final class SurvivalBlockBreakHandler{
|
||||
if($this->breakSpeed > 0){
|
||||
$this->player->getWorld()->broadcastPacketToViewers(
|
||||
$this->blockPos,
|
||||
LevelEventPacket::create(LevelEventPacket::EVENT_BLOCK_START_BREAK, (int) (65535 * $this->breakSpeed), $this->blockPos)
|
||||
LevelEventPacket::create(LevelEvent::BLOCK_START_BREAK, (int) (65535 * $this->breakSpeed), $this->blockPos)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -147,7 +148,7 @@ final class SurvivalBlockBreakHandler{
|
||||
if($this->player->getWorld()->isInLoadedTerrain($this->blockPos)){
|
||||
$this->player->getWorld()->broadcastPacketToViewers(
|
||||
$this->blockPos,
|
||||
LevelEventPacket::create(LevelEventPacket::EVENT_BLOCK_STOP_BREAK, 0, $this->blockPos)
|
||||
LevelEventPacket::create(LevelEvent::BLOCK_STOP_BREAK, 0, $this->blockPos)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,6 @@ use function dirname;
|
||||
use function fclose;
|
||||
use function file_exists;
|
||||
use function fopen;
|
||||
use function gettype;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_string;
|
||||
use function mkdir;
|
||||
use function rtrim;
|
||||
use function stream_copy_to_stream;
|
||||
@ -171,45 +167,34 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
$this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_commandError($key, $this->getDescription()->getFullName())));
|
||||
continue;
|
||||
}
|
||||
if(is_array($data)){ //TODO: error out if it isn't
|
||||
$newCmd = new PluginCommand($key, $this, $this);
|
||||
if(isset($data["description"])){
|
||||
$newCmd->setDescription($data["description"]);
|
||||
}
|
||||
|
||||
if(isset($data["usage"])){
|
||||
$newCmd->setUsage($data["usage"]);
|
||||
}
|
||||
|
||||
if(isset($data["aliases"]) and is_array($data["aliases"])){
|
||||
$aliasList = [];
|
||||
foreach($data["aliases"] as $alias){
|
||||
if(strpos($alias, ":") !== false){
|
||||
$this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_aliasError($alias, $this->getDescription()->getFullName())));
|
||||
continue;
|
||||
}
|
||||
$aliasList[] = $alias;
|
||||
}
|
||||
|
||||
$newCmd->setAliases($aliasList);
|
||||
}
|
||||
|
||||
if(isset($data["permission"])){
|
||||
if(is_bool($data["permission"])){
|
||||
$newCmd->setPermission($data["permission"] ? "true" : "false");
|
||||
}elseif(is_string($data["permission"])){
|
||||
$newCmd->setPermission($data["permission"]);
|
||||
}else{
|
||||
$this->logger->error("Permission must be a string, " . gettype($data["permission"]) . " given for command $key");
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data["permission-message"])){
|
||||
$newCmd->setPermissionMessage($data["permission-message"]);
|
||||
}
|
||||
|
||||
$pluginCmds[] = $newCmd;
|
||||
$newCmd = new PluginCommand($key, $this, $this);
|
||||
if(($description = $data->getDescription()) !== null){
|
||||
$newCmd->setDescription($description);
|
||||
}
|
||||
|
||||
if(($usageMessage = $data->getUsageMessage()) !== null){
|
||||
$newCmd->setUsage($usageMessage);
|
||||
}
|
||||
|
||||
$aliasList = [];
|
||||
foreach($data->getAliases() as $alias){
|
||||
if(strpos($alias, ":") !== false){
|
||||
$this->logger->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_aliasError($alias, $this->getDescription()->getFullName())));
|
||||
continue;
|
||||
}
|
||||
$aliasList[] = $alias;
|
||||
}
|
||||
|
||||
$newCmd->setAliases($aliasList);
|
||||
|
||||
$newCmd->setPermission($data->getPermission());
|
||||
|
||||
if(($permissionDeniedMessage = $data->getPermissionDeniedMessage()) !== null){
|
||||
$newCmd->setPermissionMessage($permissionDeniedMessage);
|
||||
}
|
||||
|
||||
$pluginCmds[] = $newCmd;
|
||||
}
|
||||
|
||||
if(count($pluginCmds) > 0){
|
||||
|
@ -25,16 +25,14 @@ namespace pocketmine\plugin;
|
||||
|
||||
use pocketmine\permission\Permission;
|
||||
use pocketmine\permission\PermissionParser;
|
||||
use pocketmine\permission\PermissionParserException;
|
||||
use function array_map;
|
||||
use function array_values;
|
||||
use function is_array;
|
||||
use function phpversion;
|
||||
use function is_string;
|
||||
use function preg_match;
|
||||
use function str_replace;
|
||||
use function stripos;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function version_compare;
|
||||
use function yaml_parse;
|
||||
|
||||
class PluginDescription{
|
||||
@ -42,53 +40,46 @@ class PluginDescription{
|
||||
* @var mixed[]
|
||||
* @phpstan-var array<string, mixed>
|
||||
*/
|
||||
private $map;
|
||||
private array $map;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
/** @var string */
|
||||
private $main;
|
||||
private string $name;
|
||||
private string $main;
|
||||
private string $srcNamespacePrefix = "";
|
||||
/** @var string[] */
|
||||
private $api;
|
||||
private array $api;
|
||||
/** @var int[] */
|
||||
private $compatibleMcpeProtocols = [];
|
||||
private array $compatibleMcpeProtocols = [];
|
||||
/** @var string[] */
|
||||
private $compatibleOperatingSystems = [];
|
||||
private array $compatibleOperatingSystems = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, list<string>>
|
||||
*/
|
||||
private $extensions = [];
|
||||
private array $extensions = [];
|
||||
/** @var string[] */
|
||||
private $depend = [];
|
||||
private array $depend = [];
|
||||
/** @var string[] */
|
||||
private $softDepend = [];
|
||||
private array $softDepend = [];
|
||||
/** @var string[] */
|
||||
private $loadBefore = [];
|
||||
/** @var string */
|
||||
private $version;
|
||||
private array $loadBefore = [];
|
||||
private string $version;
|
||||
/**
|
||||
* @var mixed[][]
|
||||
* @phpstan-var array<string, array<string, mixed>>
|
||||
* @var PluginDescriptionCommandEntry[]
|
||||
* @phpstan-var array<string, PluginDescriptionCommandEntry>
|
||||
*/
|
||||
private $commands = [];
|
||||
/** @var string */
|
||||
private $description = "";
|
||||
private array $commands = [];
|
||||
private string $description = "";
|
||||
/** @var string[] */
|
||||
private $authors = [];
|
||||
/** @var string */
|
||||
private $website = "";
|
||||
/** @var string */
|
||||
private $prefix = "";
|
||||
/** @var PluginEnableOrder */
|
||||
private $order;
|
||||
private array $authors = [];
|
||||
private string $website = "";
|
||||
private string $prefix = "";
|
||||
private PluginEnableOrder $order;
|
||||
|
||||
/**
|
||||
* @var Permission[][]
|
||||
* @phpstan-var array<string, list<Permission>>
|
||||
*/
|
||||
private $permissions = [];
|
||||
private array $permissions = [];
|
||||
|
||||
/**
|
||||
* @param string|mixed[] $yamlString
|
||||
@ -99,20 +90,20 @@ class PluginDescription{
|
||||
|
||||
/**
|
||||
* @param mixed[] $plugin
|
||||
* @throws PluginException
|
||||
* @throws PluginDescriptionParseException
|
||||
*/
|
||||
private function loadMap(array $plugin) : void{
|
||||
$this->map = $plugin;
|
||||
|
||||
$this->name = $plugin["name"];
|
||||
if(preg_match('/^[A-Za-z0-9 _.-]+$/', $this->name) === 0){
|
||||
throw new PluginException("Invalid Plugin name");
|
||||
throw new PluginDescriptionParseException("Invalid Plugin name");
|
||||
}
|
||||
$this->name = str_replace(" ", "_", $this->name);
|
||||
$this->version = (string) $plugin["version"];
|
||||
$this->main = $plugin["main"];
|
||||
if(stripos($this->main, "pocketmine\\") === 0){
|
||||
throw new PluginException("Invalid Plugin main, cannot start within the PocketMine namespace");
|
||||
throw new PluginDescriptionParseException("Invalid Plugin main, cannot start within the PocketMine namespace");
|
||||
}
|
||||
|
||||
$this->srcNamespacePrefix = $plugin["src-namespace-prefix"] ?? "";
|
||||
@ -122,7 +113,24 @@ class PluginDescription{
|
||||
$this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin["os"] ?? []));
|
||||
|
||||
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
|
||||
$this->commands = $plugin["commands"];
|
||||
foreach($plugin["commands"] as $commandName => $commandData){
|
||||
if(!is_string($commandName)){
|
||||
throw new PluginDescriptionParseException("Invalid Plugin commands, key must be the name of the command");
|
||||
}
|
||||
if(!is_array($commandData)){
|
||||
throw new PluginDescriptionParseException("Command $commandName has invalid properties");
|
||||
}
|
||||
if(!isset($commandData["permission"]) || !is_string($commandData["permission"])){
|
||||
throw new PluginDescriptionParseException("Command $commandName does not have a valid permission set");
|
||||
}
|
||||
$this->commands[$commandName] = new PluginDescriptionCommandEntry(
|
||||
$commandData["description"] ?? null,
|
||||
$commandData["usage"] ?? null,
|
||||
$commandData["aliases"] ?? [],
|
||||
$commandData["permission"],
|
||||
$commandData["permission-message"] ?? null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($plugin["depend"])){
|
||||
@ -153,7 +161,7 @@ class PluginDescription{
|
||||
if(isset($plugin["load"])){
|
||||
$order = PluginEnableOrder::fromString($plugin["load"]);
|
||||
if($order === null){
|
||||
throw new PluginException("Invalid Plugin \"load\"");
|
||||
throw new PluginDescriptionParseException("Invalid Plugin \"load\"");
|
||||
}
|
||||
$this->order = $order;
|
||||
}else{
|
||||
@ -175,7 +183,11 @@ class PluginDescription{
|
||||
}
|
||||
|
||||
if(isset($plugin["permissions"])){
|
||||
$this->permissions = PermissionParser::loadPermissions($plugin["permissions"]);
|
||||
try{
|
||||
$this->permissions = PermissionParser::loadPermissions($plugin["permissions"]);
|
||||
}catch(PermissionParserException $e){
|
||||
throw new PluginDescriptionParseException("Invalid Plugin \"permissions\": " . $e->getMessage(), 0, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,8 +228,8 @@ class PluginDescription{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[][]
|
||||
* @phpstan-return array<string, array<string, mixed>>
|
||||
* @return PluginDescriptionCommandEntry[]
|
||||
* @phpstan-return array<string, PluginDescriptionCommandEntry>
|
||||
*/
|
||||
public function getCommands() : array{
|
||||
return $this->commands;
|
||||
@ -231,40 +243,6 @@ class PluginDescription{
|
||||
return $this->extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current PHP runtime has the extensions required by the plugin.
|
||||
*
|
||||
* @throws PluginException if there are required extensions missing or have incompatible version, or if the version constraint cannot be parsed
|
||||
*/
|
||||
public function checkRequiredExtensions() : void{
|
||||
foreach($this->extensions as $name => $versionConstrs){
|
||||
$gotVersion = phpversion($name);
|
||||
if($gotVersion === false){
|
||||
throw new PluginException("Required extension $name not loaded");
|
||||
}
|
||||
|
||||
foreach($versionConstrs as $constr){ // versionConstrs_loop
|
||||
if($constr === "*"){
|
||||
continue;
|
||||
}
|
||||
if($constr === ""){
|
||||
throw new PluginException("One of the extension version constraints of $name is empty. Consider quoting the version string in plugin.yml");
|
||||
}
|
||||
foreach(["<=", "le", "<>", "!=", "ne", "<", "lt", "==", "=", "eq", ">=", "ge", ">", "gt"] as $comparator){
|
||||
// warning: the > character should be quoted in YAML
|
||||
if(substr($constr, 0, strlen($comparator)) === $comparator){
|
||||
$version = substr($constr, strlen($comparator));
|
||||
if(!version_compare($gotVersion, $version, $comparator)){
|
||||
throw new PluginException("Required extension $name has an incompatible version ($gotVersion not $constr)");
|
||||
}
|
||||
continue 2; // versionConstrs_loop
|
||||
}
|
||||
}
|
||||
throw new PluginException("Error parsing version constraint: $constr");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
|
53
src/plugin/PluginDescriptionCommandEntry.php
Normal file
53
src/plugin/PluginDescriptionCommandEntry.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?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;
|
||||
|
||||
final class PluginDescriptionCommandEntry{
|
||||
|
||||
/**
|
||||
* @param string[] $aliases
|
||||
* @phpstan-param list<string> $aliases
|
||||
*/
|
||||
public function __construct(
|
||||
private ?string $description,
|
||||
private ?string $usageMessage,
|
||||
private array $aliases,
|
||||
private string $permission,
|
||||
private ?string $permissionDeniedMessage,
|
||||
){}
|
||||
|
||||
public function getDescription() : ?string{ return $this->description; }
|
||||
|
||||
public function getUsageMessage() : ?string{ return $this->usageMessage; }
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
public function getAliases() : array{ return $this->aliases; }
|
||||
|
||||
public function getPermission() : string{ return $this->permission; }
|
||||
|
||||
public function getPermissionDeniedMessage() : ?string{ return $this->permissionDeniedMessage; }
|
||||
}
|
31
src/plugin/PluginDescriptionParseException.php
Normal file
31
src/plugin/PluginDescriptionParseException.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Thrown when invalid things are found in a PluginDescription during loading
|
||||
*/
|
||||
final class PluginDescriptionParseException extends PluginException{
|
||||
|
||||
}
|
@ -23,15 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\plugin;
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Rules\AllOf;
|
||||
use Respect\Validation\Rules\ArrayType;
|
||||
use Respect\Validation\Rules\Each;
|
||||
use Respect\Validation\Rules\In;
|
||||
use Respect\Validation\Rules\Key;
|
||||
use Respect\Validation\Rules\StringType;
|
||||
use Respect\Validation\Validator;
|
||||
use function array_flip;
|
||||
use function is_array;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
|
||||
class PluginGraylist{
|
||||
|
||||
@ -70,17 +66,27 @@ class PluginGraylist{
|
||||
* @param mixed[] $array
|
||||
*/
|
||||
public static function fromArray(array $array) : PluginGraylist{
|
||||
$validator = new Validator(
|
||||
new Key("mode", new In(['whitelist', 'blacklist'], true), true),
|
||||
new Key("plugins", new AllOf(new ArrayType(), new Each(new StringType())), true)
|
||||
);
|
||||
$validator->setName('plugin_list.yml');
|
||||
try{
|
||||
$validator->assert($array);
|
||||
}catch(NestedValidationException $e){
|
||||
throw new \InvalidArgumentException($e->getFullMessage(), 0, $e);
|
||||
if(!isset($array["mode"]) || ($array["mode"] !== "whitelist" && $array["mode"] !== "blacklist")){
|
||||
throw new \InvalidArgumentException("\"mode\" must be set");
|
||||
}
|
||||
return new PluginGraylist($array["plugins"], $array["mode"] === 'whitelist');
|
||||
$isWhitelist = match($array["mode"]){
|
||||
"whitelist" => true,
|
||||
"blacklist" => false,
|
||||
default => throw new \InvalidArgumentException("\"mode\" must be either \"whitelist\" or \"blacklist\"")
|
||||
};
|
||||
$plugins = [];
|
||||
if(isset($array["plugins"])){
|
||||
if(!is_array($array["plugins"])){
|
||||
throw new \InvalidArgumentException("\"plugins\" must be an array");
|
||||
}
|
||||
foreach($array["plugins"] as $k => $v){
|
||||
if(!is_string($v) && !is_int($v) && !is_float($v)){
|
||||
throw new \InvalidArgumentException("\"plugins\" contains invalid element at position $k");
|
||||
}
|
||||
$plugins[] = (string) $v;
|
||||
}
|
||||
}
|
||||
return new PluginGraylist($plugins, $isWhitelist);
|
||||
}
|
||||
|
||||
/**
|
||||
|
42
src/plugin/PluginLoadTriage.php
Normal file
42
src/plugin/PluginLoadTriage.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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;
|
||||
|
||||
final class PluginLoadTriage{
|
||||
/**
|
||||
* @var PluginLoadTriageEntry[]
|
||||
* @phpstan-var array<string, PluginLoadTriageEntry>
|
||||
*/
|
||||
public $plugins = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, list<string>>
|
||||
*/
|
||||
public $dependencies = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, list<string>>
|
||||
*/
|
||||
public $softDependencies = [];
|
||||
}
|
42
src/plugin/PluginLoadTriageEntry.php
Normal file
42
src/plugin/PluginLoadTriageEntry.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class PluginLoadTriageEntry{
|
||||
|
||||
public function __construct(
|
||||
private string $file,
|
||||
private PluginLoader $loader,
|
||||
private PluginDescription $description
|
||||
){}
|
||||
|
||||
public function getFile() : string{ return $this->file; }
|
||||
|
||||
public function getLoader() : PluginLoader{ return $this->loader; }
|
||||
|
||||
public function getDescription() : PluginDescription{ return $this->description; }
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user