mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-03 18:42:37 +00:00
Merge branch 'next-minor' into next-major
This commit is contained in:
commit
4d79aced07
2
.github/workflows/draft-release.yml
vendored
2
.github/workflows/draft-release.yml
vendored
@ -69,7 +69,7 @@ jobs:
|
||||
${{ github.workspace }}/build_info.json
|
||||
|
||||
- name: Create draft release
|
||||
uses: ncipollo/release-action@v1.11.2
|
||||
uses: ncipollo/release-action@v1.12.0
|
||||
with:
|
||||
artifacts: ${{ github.workspace }}/PocketMine-MP.phar,${{ github.workspace }}/start.*,${{ github.workspace }}/build_info.json
|
||||
commit: ${{ github.sha }}
|
||||
|
2
.github/workflows/support.yml
vendored
2
.github/workflows/support.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
||||
support:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/support-requests@v2
|
||||
- uses: dessant/support-requests@v3
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
support-label: "Support request"
|
||||
|
5
.idea/codeStyles/Project.xml
generated
5
.idea/codeStyles/Project.xml
generated
@ -62,6 +62,11 @@
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Shell Script">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="neon">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
|
@ -66,6 +66,9 @@ BODY,
|
||||
],
|
||||
'indentation_type' => true,
|
||||
'logical_operators' => true,
|
||||
'native_constant_invocation' => [
|
||||
'scope' => 'namespaced'
|
||||
],
|
||||
'native_function_invocation' => [
|
||||
'scope' => 'namespaced',
|
||||
'include' => ['@all'],
|
||||
@ -92,6 +95,12 @@ BODY,
|
||||
],
|
||||
'sort_algorithm' => 'alpha'
|
||||
],
|
||||
'phpdoc_align' => [
|
||||
'align' => 'vertical',
|
||||
'tags' => [
|
||||
'param',
|
||||
]
|
||||
],
|
||||
'phpdoc_line_span' => [
|
||||
'property' => 'single',
|
||||
'method' => null,
|
||||
|
@ -48,6 +48,8 @@ use function sort;
|
||||
use function strrpos;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
use const SORT_STRING;
|
||||
use const STDERR;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
|
@ -36,6 +36,8 @@ use function file_get_contents;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function strtoupper;
|
||||
use const SORT_STRING;
|
||||
use const STDERR;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
|
@ -39,6 +39,7 @@ use function sprintf;
|
||||
use function str_replace;
|
||||
use function substr;
|
||||
use const SORT_STRING;
|
||||
use const STDERR;
|
||||
|
||||
if(count($argv) !== 2){
|
||||
fwrite(STDERR, "Provide a path to process\n");
|
||||
|
@ -48,6 +48,7 @@ use function lcfirst;
|
||||
use function log;
|
||||
use function ob_get_clean;
|
||||
use function ob_start;
|
||||
use const SORT_STRING;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
|
@ -40,12 +40,13 @@ use function rtrim;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
use function unlink;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_EOL;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* @param string[] $strings
|
||||
* @param string[] $strings
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
|
38
composer.lock
generated
38
composer.lock
generated
@ -198,16 +198,16 @@
|
||||
},
|
||||
{
|
||||
"name": "netresearch/jsonmapper",
|
||||
"version": "v4.0.0",
|
||||
"version": "v4.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cweiske/jsonmapper.git",
|
||||
"reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d"
|
||||
"reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d",
|
||||
"reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d",
|
||||
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/cfa81ea1d35294d64adb9c68aa4cb9e92400e53f",
|
||||
"reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -243,9 +243,9 @@
|
||||
"support": {
|
||||
"email": "cweiske@cweiske.de",
|
||||
"issues": "https://github.com/cweiske/jsonmapper/issues",
|
||||
"source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0"
|
||||
"source": "https://github.com/cweiske/jsonmapper/tree/v4.1.0"
|
||||
},
|
||||
"time": "2020-12-01T19:48:11+00:00"
|
||||
"time": "2022-12-08T20:46:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-block-upgrade-schema",
|
||||
@ -1824,21 +1824,21 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan-phpunit.git",
|
||||
"reference": "dea1f87344c6964c607d9076dee42d891f3923f0"
|
||||
"reference": "4c06b7e3f2c40081334d86975350dda814bd064a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/dea1f87344c6964c607d9076dee42d891f3923f0",
|
||||
"reference": "dea1f87344c6964c607d9076dee42d891f3923f0",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4c06b7e3f2c40081334d86975350dda814bd064a",
|
||||
"reference": "4c06b7e3f2c40081334d86975350dda814bd064a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpstan/phpstan": "^1.8.11"
|
||||
"phpstan/phpstan": "^1.9.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<7.0"
|
||||
@ -1870,9 +1870,9 @@
|
||||
"description": "PHPUnit extensions and rules for PHPStan",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
|
||||
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.2.2"
|
||||
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.0"
|
||||
},
|
||||
"time": "2022-10-28T10:23:07+00:00"
|
||||
"time": "2022-12-07T15:46:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-strict-rules",
|
||||
@ -2242,16 +2242,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "9.5.26",
|
||||
"version": "9.5.27",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2"
|
||||
"reference": "a2bc7ffdca99f92d959b3f2270529334030bba38"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/851867efcbb6a1b992ec515c71cdcf20d895e9d2",
|
||||
"reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38",
|
||||
"reference": "a2bc7ffdca99f92d959b3f2270529334030bba38",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2324,7 +2324,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.26"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2340,7 +2340,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-10-28T06:00:21+00:00"
|
||||
"time": "2022-12-09T07:31:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
@ -477,7 +477,7 @@ class MemoryManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object[] $objects reference parameter
|
||||
* @param object[] $objects reference parameter
|
||||
* @param int[] $refCounts reference parameter
|
||||
*
|
||||
* @phpstan-param array<string, object> $objects
|
||||
|
@ -39,11 +39,14 @@ namespace pocketmine {
|
||||
use function extension_loaded;
|
||||
use function function_exists;
|
||||
use function getcwd;
|
||||
use function is_dir;
|
||||
use function mkdir;
|
||||
use function phpversion;
|
||||
use function preg_match;
|
||||
use function preg_quote;
|
||||
use function realpath;
|
||||
use function version_compare;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
require_once __DIR__ . '/VersionInfo.php';
|
||||
|
||||
@ -273,25 +276,33 @@ JIT_WARNING
|
||||
$pluginPath = getopt_string("plugins") ?? $cwd . DIRECTORY_SEPARATOR . "plugins";
|
||||
Filesystem::addCleanedPath($pluginPath, Filesystem::CLEAN_PATH_PLUGINS_PREFIX);
|
||||
|
||||
if(!@mkdir($dataPath, 0777, true) && (!is_dir($dataPath) || !is_writable($dataPath))){
|
||||
if(!@mkdir($dataPath, 0777, true) && !is_dir($dataPath)){
|
||||
critical_error("Unable to create/access data directory at $dataPath. Check that the target location is accessible by the current user.");
|
||||
exit(1);
|
||||
}
|
||||
//this has to be done after we're sure the data path exists
|
||||
$dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
|
||||
if(!@mkdir($pluginPath, 0777, true) && (!is_dir($pluginPath) || !is_writable($pluginPath))){
|
||||
critical_error("Unable to create plugin directory at $pluginPath. Check that the target location is accessible by the current user.");
|
||||
exit(1);
|
||||
}
|
||||
$pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$lockFilePath = Path::join($dataPath, 'server.lock');
|
||||
if(($pid = Filesystem::createLockFile($lockFilePath)) !== null){
|
||||
try{
|
||||
$pid = Filesystem::createLockFile($lockFilePath);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
critical_error($e->getMessage());
|
||||
critical_error("Please ensure that there is enough space on the disk and that the current user has read/write permissions to the selected data directory $dataPath.");
|
||||
exit(1);
|
||||
}
|
||||
if($pid !== null){
|
||||
critical_error("Another " . VersionInfo::NAME . " instance (PID $pid) is already using this folder (" . realpath($dataPath) . ").");
|
||||
critical_error("Please stop the other server first before running a new one.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!@mkdir($pluginPath, 0777, true) && !is_dir($pluginPath)){
|
||||
critical_error("Unable to create plugin directory at $pluginPath. Check that the target location is accessible by the current user.");
|
||||
exit(1);
|
||||
}
|
||||
$pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
|
||||
|
||||
//Logger has a dependency on timezone
|
||||
Timezone::init();
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender[]|null $recipients
|
||||
* @param CommandSender[]|null $recipients
|
||||
*/
|
||||
public function broadcastMessage(Translatable|string $message, ?array $recipients = null) : int{
|
||||
$recipients = $recipients ?? $this->getBroadcastChannelSubscribers(self::BROADCAST_CHANNEL_USERS);
|
||||
@ -1318,9 +1318,9 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
|
||||
* @param int $stay Duration in ticks to stay on screen for
|
||||
* @param int $fadeOut Duration in ticks for fade-out.
|
||||
* @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
|
||||
* @param int $stay Duration in ticks to stay on screen for
|
||||
* @param int $fadeOut Duration in ticks for fade-out.
|
||||
* @param Player[]|null $recipients
|
||||
*/
|
||||
public function broadcastTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1, ?array $recipients = null) : int{
|
||||
|
@ -89,7 +89,7 @@ abstract class BaseBanner extends Transparent{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BannerPatternLayer[] $patterns
|
||||
* @param BannerPatternLayer[] $patterns
|
||||
*
|
||||
* @phpstan-param list<BannerPatternLayer> $patterns
|
||||
* @return $this
|
||||
|
@ -63,7 +63,7 @@ class Block{
|
||||
protected ?array $collisionBoxes = null;
|
||||
|
||||
/**
|
||||
* @param string $name English name of the block type (TODO: implement translations)
|
||||
* @param string $name English name of the block type (TODO: implement translations)
|
||||
*/
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
||||
$this->idInfo = $idInfo;
|
||||
|
@ -85,7 +85,7 @@ class BlockFactory{
|
||||
* NOTE: If you are registering a new block type, you will need to add it to the creative inventory yourself - it
|
||||
* will not automatically appear there.
|
||||
*
|
||||
* @param bool $override Whether to override existing registrations
|
||||
* @param bool $override Whether to override existing registrations
|
||||
*
|
||||
* @throws \InvalidArgumentException if something attempted to override an already-registered block without specifying the
|
||||
* $override parameter.
|
||||
|
@ -135,7 +135,7 @@ class Banner extends Spawnable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BannerPatternLayer[] $patterns
|
||||
* @param BannerPatternLayer[] $patterns
|
||||
*
|
||||
* @phpstan-param list<BannerPatternLayer> $patterns
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\command;
|
||||
interface CommandExecutor{
|
||||
|
||||
/**
|
||||
* @param string[] $args
|
||||
* @param string[] $args
|
||||
*/
|
||||
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool;
|
||||
|
||||
|
@ -204,7 +204,7 @@ class CraftingManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item[] $outputs
|
||||
* @param Item[] $outputs
|
||||
*/
|
||||
public function matchRecipe(CraftingGrid $grid, array $outputs) : ?CraftingRecipe{
|
||||
//TODO: try to match special recipes before anything else (first they need to be implemented!)
|
||||
|
@ -45,15 +45,15 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
/**
|
||||
* Constructs a ShapedRecipe instance.
|
||||
*
|
||||
* @param string[] $shape <br>
|
||||
* Array of 1, 2, or 3 strings representing the rows of the recipe.
|
||||
* This accepts an array of 1, 2 or 3 strings. Each string should be of the same length and must be at most 3
|
||||
* characters long. Each character represents a unique type of ingredient. Spaces are interpreted as air.
|
||||
* @param RecipeIngredient[] $ingredients <br>
|
||||
* Char => Item map of items to be set into the shape.
|
||||
* This accepts an array of Items, indexed by character. Every unique character (except space) in the shape
|
||||
* array MUST have a corresponding item in this list. Space character is automatically treated as air.
|
||||
* @param Item[] $results List of items that this recipe produces when crafted.
|
||||
* @param string[] $shape <br>
|
||||
* Array of 1, 2, or 3 strings representing the rows of the recipe.
|
||||
* This accepts an array of 1, 2 or 3 strings. Each string should be of the same length and must be at most 3
|
||||
* characters long. Each character represents a unique type of ingredient. Spaces are interpreted as air.
|
||||
* @param RecipeIngredient[] $ingredients <br>
|
||||
* Char => Item map of items to be set into the shape.
|
||||
* This accepts an array of Items, indexed by character. Every unique character (except space) in the shape
|
||||
* array MUST have a corresponding item in this list. Space character is automatically treated as air.
|
||||
* @param Item[] $results List of items that this recipe produces when crafted.
|
||||
*
|
||||
* Note: Recipes **do not** need to be square. Do NOT add padding for empty rows/columns.
|
||||
*/
|
||||
|
@ -36,7 +36,8 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
|
||||
/**
|
||||
* @param RecipeIngredient[] $ingredients No more than 9 total. This applies to sum of item stack counts, not count of array.
|
||||
* @param Item[] $results List of result items created by this recipe.
|
||||
* @param Item[] $results List of result items created by this recipe.
|
||||
*
|
||||
* TODO: we'll want to make the type parameter mandatory in PM5
|
||||
*/
|
||||
public function __construct(array $ingredients, array $results, ?ShapelessRecipeType $type = null){
|
||||
|
@ -54,9 +54,9 @@ final class ShapedRecipeData{
|
||||
/**
|
||||
* TODO: convert this to use promoted properties - avoiding them for now since it would break JsonMapper
|
||||
*
|
||||
* @param string[] $shape
|
||||
* @param string[] $shape
|
||||
* @param RecipeIngredientData[] $input
|
||||
* @param ItemStackData[] $output
|
||||
* @param ItemStackData[] $output
|
||||
*
|
||||
* @phpstan-param list<string> $shape
|
||||
* @phpstan-param array<string, RecipeIngredientData> $input
|
||||
|
@ -47,7 +47,7 @@ final class ShapelessRecipeData{
|
||||
|
||||
/**
|
||||
* @param RecipeIngredientData[] $input
|
||||
* @param ItemStackData[] $output
|
||||
* @param ItemStackData[] $output
|
||||
*
|
||||
* @phpstan-param list<RecipeIngredientData> $input
|
||||
* @phpstan-param list<ItemStackData> $output
|
||||
|
@ -34,6 +34,7 @@ use function gettype;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const pocketmine\BEDROCK_DATA_PATH;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ use function array_flip;
|
||||
use function file_get_contents;
|
||||
use function is_array;
|
||||
use function json_decode;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const pocketmine\BEDROCK_DATA_PATH;
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\utils\Binary;
|
||||
use function assert;
|
||||
use function ksort;
|
||||
use const SORT_NUMERIC;
|
||||
|
||||
final class ItemDataUpgrader{
|
||||
private const TAG_LEGACY_ID = "id"; //TAG_Short (or TAG_String for Java itemstacks)
|
||||
|
@ -28,7 +28,7 @@ use function mb_strtolower;
|
||||
final class ItemIdMetaUpgradeSchema{
|
||||
|
||||
/**
|
||||
* @param string[] $renamedIds
|
||||
* @param string[] $renamedIds
|
||||
* @param string[][] $remappedMetas
|
||||
* @phpstan-param array<string, string> $renamedIds
|
||||
* @phpstan-param array<string, array<int, string>> $remappedMetas
|
||||
|
@ -31,6 +31,8 @@ use function gettype;
|
||||
use function is_object;
|
||||
use function json_decode;
|
||||
use function ksort;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const SORT_NUMERIC;
|
||||
|
||||
final class ItemIdMetaUpgradeSchemaUtils{
|
||||
|
||||
|
@ -32,6 +32,7 @@ use function is_array;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use function mb_strtolower;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH;
|
||||
|
||||
/**
|
||||
|
@ -1569,7 +1569,7 @@ abstract class Entity{
|
||||
|
||||
/**
|
||||
* @param Player[]|null $targets
|
||||
* @param MetadataProperty[] $data Properly formatted entity data, defaults to everything
|
||||
* @param MetadataProperty[] $data Properly formatted entity data, defaults to everything
|
||||
*
|
||||
* @phpstan-param array<int, MetadataProperty> $data
|
||||
*/
|
||||
|
@ -439,7 +439,9 @@ abstract class Living extends Entity{
|
||||
*/
|
||||
protected function applyPostDamageEffects(EntityDamageEvent $source) : void{
|
||||
$this->setAbsorption(max(0, $this->getAbsorption() + $source->getModifier(EntityDamageEvent::MODIFIER_ABSORPTION)));
|
||||
$this->damageArmor($source->getBaseDamage());
|
||||
if($source->canBeReducedByArmor()){
|
||||
$this->damageArmor($source->getBaseDamage());
|
||||
}
|
||||
|
||||
if($source instanceof EntityDamageByEntityEvent && ($attacker = $source->getDamager()) !== null){
|
||||
$damage = 0;
|
||||
|
@ -35,9 +35,9 @@ class Effect{
|
||||
use NotSerializable;
|
||||
|
||||
/**
|
||||
* @param Translatable|string $name Translation key used for effect name
|
||||
* @param Color $color Color of bubbles given by this effect
|
||||
* @param bool $bad Whether the effect is harmful
|
||||
* @param Translatable|string $name Translation key used for effect name
|
||||
* @param Color $color Color of bubbles given by this effect
|
||||
* @param bool $bad Whether the effect is harmful
|
||||
* @param bool $hasBubbles Whether the effect has potion bubbles. Some do not (e.g. Instant Damage has its own particles instead of bubbles)
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -36,7 +36,7 @@ class EffectInstance{
|
||||
private Color $color;
|
||||
|
||||
/**
|
||||
* @param int|null $duration Passing null will use the effect type's default duration
|
||||
* @param int|null $duration Passing null will use the effect type's default duration
|
||||
*/
|
||||
public function __construct(Effect $effectType, ?int $duration = null, int $amplifier = 0, bool $visible = true, bool $ambient = false, ?Color $overrideColor = null){
|
||||
$this->effectType = $effectType;
|
||||
|
@ -43,7 +43,7 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
/**
|
||||
* @param Block[] $blocks
|
||||
* @param float $yield 0-100
|
||||
* @param float $yield 0-100
|
||||
*/
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
|
@ -35,8 +35,8 @@ class CraftItemEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/**
|
||||
* @param Item[] $inputs
|
||||
* @param Item[] $outputs
|
||||
* @param Item[] $inputs
|
||||
* @param Item[] $outputs
|
||||
*/
|
||||
public function __construct(
|
||||
private CraftingTransaction $transaction,
|
||||
|
73
src/event/world/WorldParticleEvent.php
Normal file
73
src/event/world/WorldParticleEvent.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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\event\world;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\particle\Particle;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class WorldParticleEvent extends WorldEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/**
|
||||
* @param Player[] $recipients
|
||||
*/
|
||||
public function __construct(
|
||||
World $world,
|
||||
private Particle $particle,
|
||||
private Vector3 $position,
|
||||
private array $recipients
|
||||
){
|
||||
parent::__construct($world);
|
||||
}
|
||||
|
||||
public function getParticle() : Particle{
|
||||
return $this->particle;
|
||||
}
|
||||
|
||||
public function setParticle(Particle $particle) : void{
|
||||
$this->particle = $particle;
|
||||
}
|
||||
|
||||
public function getPosition() : Vector3{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getRecipients() : array{
|
||||
return $this->recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $recipients
|
||||
*/
|
||||
public function setRecipients(array $recipients) : void{
|
||||
$this->recipients = $recipients;
|
||||
}
|
||||
}
|
77
src/event/world/WorldSoundEvent.php
Normal file
77
src/event/world/WorldSoundEvent.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?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\event\world;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\Sound;
|
||||
use pocketmine\world\World;
|
||||
|
||||
/**
|
||||
* Called when a sound is played in a world
|
||||
* @see World::addSound()
|
||||
*/
|
||||
class WorldSoundEvent extends WorldEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/**
|
||||
* @param Player[] $recipients
|
||||
*/
|
||||
public function __construct(
|
||||
World $world,
|
||||
private Sound $sound,
|
||||
private Vector3 $position,
|
||||
private array $recipients
|
||||
){
|
||||
parent::__construct($world);
|
||||
}
|
||||
|
||||
public function getSound() : Sound{
|
||||
return $this->sound;
|
||||
}
|
||||
|
||||
public function setSound(Sound $sound) : void{
|
||||
$this->sound = $sound;
|
||||
}
|
||||
|
||||
public function getPosition() : Vector3{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getRecipients() : array{
|
||||
return $this->recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $recipients
|
||||
*/
|
||||
public function setRecipients(array $recipients) : void{
|
||||
$this->recipients = $recipients;
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ interface Form extends \JsonSerializable{
|
||||
/**
|
||||
* Handles a form response from a player.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param mixed $data
|
||||
*
|
||||
* @throws FormValidationException if the data could not be processed
|
||||
*/
|
||||
|
@ -77,7 +77,7 @@ class Banner extends ItemBlockWallOrFloor{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BannerPatternLayer[] $patterns
|
||||
* @param BannerPatternLayer[] $patterns
|
||||
*
|
||||
* @phpstan-param list<BannerPatternLayer> $patterns
|
||||
*
|
||||
|
@ -568,6 +568,16 @@ class Item implements \JsonSerializable{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player uses the item to interact with entity, for example by using a name tag.
|
||||
*
|
||||
* @param Vector3 $clickVector The exact position of the click (absolute coordinates)
|
||||
* @return bool whether some action took place
|
||||
*/
|
||||
public function onInteractEntity(Player $player, Entity $entity, Vector3 $clickVector) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of ticks a player must wait before activating this item again.
|
||||
*/
|
||||
@ -578,7 +588,7 @@ class Item implements \JsonSerializable{
|
||||
/**
|
||||
* Compares an Item to this Item and check if they match.
|
||||
*
|
||||
* @param bool $checkDamage @deprecated
|
||||
* @param bool $checkDamage @deprecated
|
||||
* @param bool $checkCompound Whether to verify that the items' NBT match.
|
||||
*/
|
||||
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
||||
|
@ -35,7 +35,7 @@ interface AdvancedNetworkInterface extends NetworkInterface{
|
||||
/**
|
||||
* Prevents packets received from the IP address getting processed for the given timeout.
|
||||
*
|
||||
* @param int $timeout Seconds
|
||||
* @param int $timeout Seconds
|
||||
*/
|
||||
public function blockAddress(string $address, int $timeout = 300) : void;
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\ClientboundPacket;
|
||||
interface PacketBroadcaster{
|
||||
|
||||
/**
|
||||
* @param NetworkSession[] $recipients
|
||||
* @param NetworkSession[] $recipients
|
||||
* @param ClientboundPacket[] $packets
|
||||
*/
|
||||
public function broadcastPackets(array $recipients, array $packets) : void;
|
||||
|
@ -36,6 +36,7 @@ use function get_debug_type;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
use function json_decode;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
|
||||
/**
|
||||
* Handles translation of network block runtime IDs into blockstate data, and vice versa
|
||||
@ -50,7 +51,7 @@ final class BlockStateDictionary{
|
||||
private ?array $idMetaToStateIdLookupCache = null;
|
||||
|
||||
/**
|
||||
* @param BlockStateDictionaryEntry[] $states
|
||||
* @param BlockStateDictionaryEntry[] $states
|
||||
*
|
||||
* @phpstan-param list<BlockStateDictionaryEntry> $states
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ use function openssl_digest;
|
||||
use function openssl_error_string;
|
||||
use function openssl_pkey_derive;
|
||||
use function str_pad;
|
||||
use const STR_PAD_LEFT;
|
||||
|
||||
final class EncryptionUtils{
|
||||
|
||||
|
@ -306,6 +306,8 @@ class InGamePacketHandler extends PacketHandler{
|
||||
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
|
||||
$result = true;
|
||||
|
||||
$this->inventoryManager->addPredictedSlotChanges($packet->trData->getActions());
|
||||
|
||||
if($packet->trData instanceof NormalTransactionData){
|
||||
$result = $this->handleNormalTransaction($packet->trData);
|
||||
}elseif($packet->trData instanceof MismatchTransactionData){
|
||||
@ -355,7 +357,6 @@ class InGamePacketHandler extends PacketHandler{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->inventoryManager->addPredictedSlotChanges($data->getActions());
|
||||
|
||||
if($isCraftingPart){
|
||||
if($this->craftingTransaction === null){
|
||||
|
@ -52,6 +52,7 @@ use function mt_rand;
|
||||
use function random_bytes;
|
||||
use function rtrim;
|
||||
use function substr;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
|
||||
/**
|
||||
|
@ -40,6 +40,7 @@ use function strlen;
|
||||
use function time;
|
||||
use function trim;
|
||||
use const AF_INET;
|
||||
use const AF_INET6;
|
||||
use const IPPROTO_IPV6;
|
||||
use const IPV6_V6ONLY;
|
||||
use const PHP_INT_MAX;
|
||||
|
@ -73,6 +73,12 @@ use function sprintf;
|
||||
use function strlen;
|
||||
use function trim;
|
||||
use const AF_INET;
|
||||
use const PREG_BACKTRACK_LIMIT_ERROR;
|
||||
use const PREG_BAD_UTF8_ERROR;
|
||||
use const PREG_BAD_UTF8_OFFSET_ERROR;
|
||||
use const PREG_INTERNAL_ERROR;
|
||||
use const PREG_JIT_STACKLIMIT_ERROR;
|
||||
use const PREG_RECURSION_LIMIT_ERROR;
|
||||
use const SO_RCVTIMEO;
|
||||
use const SOCK_DGRAM;
|
||||
use const SOCKET_ETIMEDOUT;
|
||||
|
@ -1392,7 +1392,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
/**
|
||||
* Returns whether the player can interact with the specified position. This checks distance and direction.
|
||||
*
|
||||
* @param float $maxDiff defaults to half of the 3D diagonal width of a block
|
||||
* @param float $maxDiff defaults to half of the 3D diagonal width of a block
|
||||
*/
|
||||
public function canInteract(Vector3 $pos, float $maxDistance, float $maxDiff = M_SQRT3 / 2) : bool{
|
||||
$eyePos = $this->getEyePos();
|
||||
@ -1836,7 +1836,17 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
|
||||
$ev->call();
|
||||
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $item;
|
||||
if(!$ev->isCancelled()){
|
||||
if($item->onInteractEntity($this, $entity, $clickPos)){
|
||||
if($this->hasFiniteResources() && !$item->equalsExact($oldItem) && $oldItem->equalsExact($this->inventory->getItemInHand())){
|
||||
if($item instanceof Durable && $item->isBroken()){
|
||||
$this->broadcastSound(new ItemBreakSound());
|
||||
}
|
||||
$this->inventory->setItemInHand($item);
|
||||
}
|
||||
}
|
||||
return $entity->onInteract($this, $clickPos);
|
||||
}
|
||||
return false;
|
||||
@ -1934,9 +1944,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
/**
|
||||
* Adds a title text to the user's screen, with an optional subtitle.
|
||||
*
|
||||
* @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
|
||||
* @param int $stay Duration in ticks to stay on screen for
|
||||
* @param int $fadeOut Duration in ticks for fade-out.
|
||||
* @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
|
||||
* @param int $stay Duration in ticks to stay on screen for
|
||||
* @param int $fadeOut Duration in ticks for fade-out.
|
||||
*/
|
||||
public function sendTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1) : void{
|
||||
$this->setTitleDuration($fadeIn, $stay, $fadeOut);
|
||||
@ -1977,8 +1987,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
/**
|
||||
* Sets the title duration.
|
||||
*
|
||||
* @param int $fadeIn Title fade-in time in ticks.
|
||||
* @param int $stay Title stay time in ticks.
|
||||
* @param int $fadeIn Title fade-in time in ticks.
|
||||
* @param int $stay Title stay time in ticks.
|
||||
* @param int $fadeOut Title fade-out time in ticks.
|
||||
*/
|
||||
public function setTitleDuration(int $fadeIn, int $stay, int $fadeOut) : void{
|
||||
@ -2076,7 +2086,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
* Transfers a player to another server.
|
||||
*
|
||||
* @param string $address The IP address or hostname of the destination server
|
||||
* @param int $port The destination port, defaults to 19132
|
||||
* @param int $port The destination port, defaults to 19132
|
||||
* @param string $message Message to show in the console when closing the player
|
||||
*
|
||||
* @return bool if transfer was successful.
|
||||
@ -2120,7 +2130,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
*
|
||||
* Note for internals developers: Do not call this from network sessions. It will cause a feedback loop.
|
||||
*
|
||||
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
|
||||
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
|
||||
* @param Translatable|string|null $quitMessage Message to broadcast to online players (null will use default)
|
||||
*/
|
||||
public function disconnect(string $reason, Translatable|string|null $quitMessage = null) : void{
|
||||
@ -2136,7 +2146,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
* @internal
|
||||
* This method executes post-disconnect actions and cleanups.
|
||||
*
|
||||
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
|
||||
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
|
||||
* @param Translatable|string|null $quitMessage Message to broadcast to online players (null will use default)
|
||||
*/
|
||||
public function onPostDisconnect(string $reason, Translatable|string|null $quitMessage) : void{
|
||||
|
@ -45,6 +45,7 @@ use function stream_copy_to_stream;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function trim;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
private bool $isEnabled = false;
|
||||
@ -201,7 +202,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $args
|
||||
* @param string[] $args
|
||||
*/
|
||||
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
|
||||
return false;
|
||||
|
@ -57,7 +57,7 @@ interface ResourcePack{
|
||||
* Note that resource packs must **always** be in zip archive format for sending.
|
||||
* A folder resource loader may need to perform on-the-fly compression for this purpose.
|
||||
*
|
||||
* @param int $start Offset to start reading the chunk from
|
||||
* @param int $start Offset to start reading the chunk from
|
||||
* @param int $length Maximum length of data to return.
|
||||
*
|
||||
* @return string byte-array
|
||||
|
@ -58,7 +58,7 @@ class ResourcePackManager{
|
||||
private array $encryptionKeys = [];
|
||||
|
||||
/**
|
||||
* @param string $path Path to resource-packs directory.
|
||||
* @param string $path Path to resource-packs directory.
|
||||
*/
|
||||
public function __construct(string $path, \Logger $logger){
|
||||
$this->path = $path;
|
||||
|
@ -183,7 +183,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
* {@link AsyncTask::onCompletion} is called.
|
||||
*
|
||||
* @param mixed $progress The parameter passed to {@link AsyncTask#publishProgress}. It is serialize()'ed
|
||||
* and then unserialize()'ed, as if it has been cloned.
|
||||
* and then unserialize()'ed, as if it has been cloned.
|
||||
*/
|
||||
public function onProgressUpdate($progress) : void{
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\scheduler;
|
||||
final class BulkCurlTaskOperation{
|
||||
/**
|
||||
* @param string[] $extraHeaders
|
||||
* @param mixed[] $extraOpts
|
||||
* @param mixed[] $extraOpts
|
||||
* @phpstan-param list<string> $extraHeaders
|
||||
* @phpstan-param array<int, mixed> $extraOpts
|
||||
*/
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\lang\Translatable;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
use pocketmine\permission\PermissibleDelegateTrait;
|
||||
use pocketmine\Server;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* Forwards any messages it receives via sendMessage() to the given logger. Used for forwarding chat messages and
|
||||
|
@ -55,6 +55,7 @@ use const CASE_LOWER;
|
||||
use const JSON_BIGINT_AS_STRING;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const YAML_UTF8_ENCODING;
|
||||
|
||||
/**
|
||||
* Config Class for simple config manipulation of multiple formats.
|
||||
@ -108,8 +109,8 @@ class Config{
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $file Path of the file to be loaded
|
||||
* @param int $type Config type to load, -1 by default (detect)
|
||||
* @param string $file Path of the file to be loaded
|
||||
* @param int $type Config type to load, -1 by default (detect)
|
||||
* @param mixed[] $default Array with the default values that will be written to the file if it did not exist
|
||||
* @phpstan-param array<string, mixed> $default
|
||||
*/
|
||||
@ -469,7 +470,7 @@ class Config{
|
||||
|
||||
/**
|
||||
* @param mixed[] $default
|
||||
* @param mixed[] $data reference parameter
|
||||
* @param mixed[] $data reference parameter
|
||||
* @phpstan-param array<string, mixed> $default
|
||||
* @phpstan-param array<string, mixed> $data
|
||||
* @phpstan-param-out array<string, mixed> $data
|
||||
|
@ -182,9 +182,10 @@ final class Filesystem{
|
||||
* @throws \InvalidArgumentException if the lock file path is invalid (e.g. parent directory doesn't exist, permission denied)
|
||||
*/
|
||||
public static function createLockFile(string $lockFilePath) : ?int{
|
||||
$resource = fopen($lockFilePath, "a+b");
|
||||
if($resource === false){
|
||||
throw new \InvalidArgumentException("Invalid lock file path or read/write permissions denied");
|
||||
try{
|
||||
$resource = ErrorToExceptionHandler::trapAndRemoveFalse(fn() => fopen($lockFilePath, "a+b"));
|
||||
}catch(\ErrorException $e){
|
||||
throw new \InvalidArgumentException("Failed to open lock file: " . $e->getMessage(), 0, $e);
|
||||
}
|
||||
if(!flock($resource, LOCK_EX | LOCK_NB)){
|
||||
//wait for a shared lock to avoid race conditions if two servers started at the same time - this makes sure the
|
||||
|
@ -36,7 +36,7 @@ final class Git{
|
||||
/**
|
||||
* Returns the git hash of the currently checked out head of the given repository, or null on failure.
|
||||
*
|
||||
* @param bool $dirty reference parameter, set to whether the repo has local changes
|
||||
* @param bool $dirty reference parameter, set to whether the repo has local changes
|
||||
*/
|
||||
public static function getRepositoryState(string $dir, bool &$dirty) : ?string{
|
||||
if(Process::execute("git -C \"$dir\" rev-parse HEAD", $out) === 0 && $out !== false && strlen($out = trim($out)) === 40){
|
||||
|
@ -137,9 +137,9 @@ class Internet{
|
||||
*
|
||||
* @phpstan-template TErrorVar of mixed
|
||||
*
|
||||
* @param int $timeout default 10
|
||||
* @param int $timeout default 10
|
||||
* @param string[] $extraHeaders
|
||||
* @param string|null $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
|
||||
* @param string|null $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
|
||||
* @phpstan-param list<string> $extraHeaders
|
||||
* @phpstan-param TErrorVar $err
|
||||
* @phpstan-param-out TErrorVar|string $err
|
||||
@ -161,7 +161,7 @@ class Internet{
|
||||
*
|
||||
* @param string[]|string $args
|
||||
* @param string[] $extraHeaders
|
||||
* @param string|null $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occurred during the operation.
|
||||
* @param string|null $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occurred during the operation.
|
||||
* @phpstan-param string|array<string, string> $args
|
||||
* @phpstan-param list<string> $extraHeaders
|
||||
* @phpstan-param TErrorVar $err
|
||||
@ -183,7 +183,7 @@ class Internet{
|
||||
* General cURL shorthand function.
|
||||
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
|
||||
*
|
||||
* @param float $timeout The maximum connect timeout and timeout in seconds, correct to ms.
|
||||
* @param float $timeout The maximum connect timeout and timeout in seconds, correct to ms.
|
||||
* @param string[] $extraHeaders extra headers to send as a plain string array
|
||||
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
|
||||
* @param \Closure|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
|
||||
|
@ -150,8 +150,8 @@ final class Process{
|
||||
|
||||
/**
|
||||
* @param string $command Command to execute
|
||||
* @param string|null $stdout Reference parameter to write stdout to
|
||||
* @param string|null $stderr Reference parameter to write stderr to
|
||||
* @param string|null $stdout Reference parameter to write stdout to
|
||||
* @param string|null $stderr Reference parameter to write stderr to
|
||||
* @phpstan-param-out string $stdout
|
||||
* @phpstan-param-out string $stderr
|
||||
*
|
||||
|
@ -114,7 +114,7 @@ class Random{
|
||||
* Returns a random integer between $start and $end
|
||||
*
|
||||
* @param int $start default 0
|
||||
* @param int $end default 0x7fffffff
|
||||
* @param int $end default 0x7fffffff
|
||||
*/
|
||||
public function nextRange(int $start = 0, int $end = 0x7fffffff) : int{
|
||||
return $start + ($this->nextInt() % ($end + 1 - $start));
|
||||
|
@ -534,7 +534,7 @@ final class Utils{
|
||||
* incompatible.
|
||||
*
|
||||
* @param callable|CallbackType $signature Dummy callable with the required parameters and return type
|
||||
* @param callable $subject Callable to check the signature of
|
||||
* @param callable $subject Callable to check the signature of
|
||||
* @phpstan-param anyCallable|CallbackType $signature
|
||||
* @phpstan-param anyCallable $subject
|
||||
*
|
||||
|
@ -51,7 +51,9 @@ use pocketmine\event\world\ChunkLoadEvent;
|
||||
use pocketmine\event\world\ChunkPopulateEvent;
|
||||
use pocketmine\event\world\ChunkUnloadEvent;
|
||||
use pocketmine\event\world\SpawnChangeEvent;
|
||||
use pocketmine\event\world\WorldParticleEvent;
|
||||
use pocketmine\event\world\WorldSaveEvent;
|
||||
use pocketmine\event\world\WorldSoundEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemUseResult;
|
||||
use pocketmine\item\LegacyStringToItemParser;
|
||||
@ -647,7 +649,7 @@ class World implements ChunkManager{
|
||||
* Returns a list of players who are in the given filter and also using the chunk containing the target position.
|
||||
* Used for broadcasting sounds and particles with specific targets.
|
||||
*
|
||||
* @param Player[] $allowed
|
||||
* @param Player[] $allowed
|
||||
* @phpstan-param list<Player> $allowed
|
||||
*
|
||||
* @return array<int, Player>
|
||||
@ -669,9 +671,19 @@ class World implements ChunkManager{
|
||||
* @param Player[]|null $players
|
||||
*/
|
||||
public function addSound(Vector3 $pos, Sound $sound, ?array $players = null) : void{
|
||||
$pk = $sound->encode($pos);
|
||||
$players ??= $this->getViewersForPosition($pos);
|
||||
$ev = new WorldSoundEvent($this, $sound, $pos, $players);
|
||||
|
||||
$ev->call();
|
||||
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
$pk = $ev->getSound()->encode($pos);
|
||||
$players = $ev->getRecipients();
|
||||
if(count($pk) > 0){
|
||||
if($players === null){
|
||||
if($players === $this->getViewersForPosition($pos)){
|
||||
foreach($pk as $e){
|
||||
$this->broadcastPacketToViewers($pos, $e);
|
||||
}
|
||||
@ -685,14 +697,24 @@ class World implements ChunkManager{
|
||||
* @param Player[]|null $players
|
||||
*/
|
||||
public function addParticle(Vector3 $pos, Particle $particle, ?array $players = null) : void{
|
||||
$pk = $particle->encode($pos);
|
||||
$players ??= $this->getViewersForPosition($pos);
|
||||
$ev = new WorldParticleEvent($this, $particle, $pos, $players);
|
||||
|
||||
$ev->call();
|
||||
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
$pk = $ev->getParticle()->encode($pos);
|
||||
$players = $ev->getRecipients();
|
||||
if(count($pk) > 0){
|
||||
if($players === null){
|
||||
if($players === $this->getViewersForPosition($pos)){
|
||||
foreach($pk as $e){
|
||||
$this->broadcastPacketToViewers($pos, $e);
|
||||
}
|
||||
}else{
|
||||
$this->server->broadcastPackets($this->filterViewersForPosition($pos, $players), $pk);
|
||||
$this->server->broadcastPackets($this->filterViewersForPosition($pos, $ev->getRecipients()), $pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1657,8 +1679,8 @@ class World implements ChunkManager{
|
||||
* Note: If you're using this for performance-sensitive code, and you're guaranteed to be supplying ints in the
|
||||
* specified vector, consider using {@link getBlockAt} instead for better performance.
|
||||
*
|
||||
* @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate)
|
||||
* @param bool $addToCache Whether to cache the block object created by this method call.
|
||||
* @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate)
|
||||
* @param bool $addToCache Whether to cache the block object created by this method call.
|
||||
*/
|
||||
public function getBlock(Vector3 $pos, bool $cached = true, bool $addToCache = true) : Block{
|
||||
return $this->getBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $cached, $addToCache);
|
||||
@ -1670,7 +1692,7 @@ class World implements ChunkManager{
|
||||
* Note for plugin developers: If you are using this method a lot (thousands of times for many positions for
|
||||
* example), you may want to set addToCache to false to avoid using excessive amounts of memory.
|
||||
*
|
||||
* @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate)
|
||||
* @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate)
|
||||
* @param bool $addToCache Whether to cache the block object created by this method call.
|
||||
*/
|
||||
public function getBlockAt(int $x, int $y, int $z, bool $cached = true, bool $addToCache = true) : Block{
|
||||
@ -1821,7 +1843,7 @@ class World implements ChunkManager{
|
||||
* Tries to break a block using a item, including Player time checks if available
|
||||
* It'll try to lower the durability if Item is a tool, and set it to Air if broken.
|
||||
*
|
||||
* @param Item &$item reference parameter (if null, can break anything)
|
||||
* @param Item &$item reference parameter (if null, can break anything)
|
||||
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full)
|
||||
* @phpstan-param-out Item $item
|
||||
*/
|
||||
@ -1927,8 +1949,8 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Uses a item on a position and face, placing it or activating the block
|
||||
*
|
||||
* @param Player|null $player default null
|
||||
* @param bool $playSound Whether to play a block-place sound if the block was placed successfully.
|
||||
* @param Player|null $player default null
|
||||
* @param bool $playSound Whether to play a block-place sound if the block was placed successfully.
|
||||
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped if the inventory is full)
|
||||
*/
|
||||
public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $clickVector = null, ?Player $player = null, bool $playSound = false, array &$returnedItems = []) : bool{
|
||||
@ -2122,8 +2144,8 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the closest Entity to the specified position, within the given radius.
|
||||
*
|
||||
* @param string $entityType Class of entity to use for instanceof
|
||||
* @param bool $includeDead Whether to include entitites which are dead
|
||||
* @param string $entityType Class of entity to use for instanceof
|
||||
* @param bool $includeDead Whether to include entitites which are dead
|
||||
* @phpstan-template TEntity of Entity
|
||||
* @phpstan-param class-string<TEntity> $entityType
|
||||
*
|
||||
|
@ -166,7 +166,7 @@ class WorldManager{
|
||||
/**
|
||||
* Loads a world from the data directory
|
||||
*
|
||||
* @param bool $autoUpgrade Converts worlds to the default format if the world's format is not writable / deprecated
|
||||
* @param bool $autoUpgrade Converts worlds to the default format if the world's format is not writable / deprecated
|
||||
*
|
||||
* @throws WorldException
|
||||
*/
|
||||
|
@ -160,8 +160,8 @@ class Chunk{
|
||||
/**
|
||||
* Sets the biome ID at the specified X/Z chunk block coordinates
|
||||
*
|
||||
* @param int $x 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $biomeId 0-255
|
||||
*/
|
||||
public function setBiomeId(int $x, int $z, int $biomeId) : void{
|
||||
|
@ -561,7 +561,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompoundTag[] $targets
|
||||
* @param CompoundTag[] $targets
|
||||
*/
|
||||
private function writeTags(array $targets, string $index, \LevelDBWriteBatch $write) : void{
|
||||
if(count($targets) > 0){
|
||||
|
@ -38,7 +38,7 @@ use function preg_match_all;
|
||||
final class FlatGeneratorOptions{
|
||||
|
||||
/**
|
||||
* @param int[] $structure
|
||||
* @param int[] $structure
|
||||
* @param mixed[] $extraOptions
|
||||
* @phpstan-param array<int, int> $structure
|
||||
* @phpstan-param array<string, array<string, string>|true> $extraOptions
|
||||
|
@ -58,10 +58,10 @@ final class GeneratorManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class Fully qualified name of class that extends \pocketmine\world\generator\Generator
|
||||
* @param string $name Alias for this generator type that can be written in configs
|
||||
* @param \Closure $presetValidator Callback to validate generator options for new worlds
|
||||
* @param bool $overwrite Whether to force overwriting any existing registered generator with the same name
|
||||
* @param string $class Fully qualified name of class that extends \pocketmine\world\generator\Generator
|
||||
* @param string $name Alias for this generator type that can be written in configs
|
||||
* @param \Closure $presetValidator Callback to validate generator options for new worlds
|
||||
* @param bool $overwrite Whether to force overwriting any existing registered generator with the same name
|
||||
*
|
||||
* @phpstan-param \Closure(string) : ?InvalidGeneratorOptionsException $presetValidator
|
||||
*
|
||||
|
@ -208,8 +208,8 @@ class SkyLightUpdate extends LightUpdate{
|
||||
/**
|
||||
* Recalculates the heightmap for the block column at the specified X/Z chunk coordinates
|
||||
*
|
||||
* @param int $x 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $z 0-15
|
||||
* @param true[] $directSkyLightBlockers
|
||||
* @phpstan-param array<int, true> $directSkyLightBlockers
|
||||
*
|
||||
|
@ -29,6 +29,7 @@ use function file_get_contents;
|
||||
use function is_array;
|
||||
use function json_decode;
|
||||
use function print_r;
|
||||
use const SORT_STRING;
|
||||
|
||||
class BlockTest extends TestCase{
|
||||
|
||||
|
@ -57,7 +57,7 @@ class StupidJsonDecodeTest extends TestCase{
|
||||
/**
|
||||
* @dataProvider stupidJsonDecodeProvider
|
||||
*
|
||||
* @param mixed $expect
|
||||
* @param mixed $expect
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
|
@ -43,6 +43,10 @@ use function rename;
|
||||
use function round;
|
||||
use function scandir;
|
||||
use function unlink;
|
||||
use const PATHINFO_EXTENSION;
|
||||
use const PHP_BINARY;
|
||||
use const SCANDIR_SORT_NONE;
|
||||
use const SORT_NUMERIC;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
|
@ -37,6 +37,8 @@ use function realpath;
|
||||
use function trim;
|
||||
use function zlib_decode;
|
||||
use const FILE_IGNORE_NEW_LINES;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_UNESCAPED_SLASHES;
|
||||
use const PHP_EOL;
|
||||
use const STDERR;
|
||||
|
||||
|
@ -40,6 +40,9 @@ use function fwrite;
|
||||
use function get_class;
|
||||
use function json_encode;
|
||||
use function ksort;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const SORT_STRING;
|
||||
use const STDERR;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
|
@ -41,6 +41,8 @@ use function file_put_contents;
|
||||
use function fwrite;
|
||||
use function json_encode;
|
||||
use function ksort;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const SORT_STRING;
|
||||
use const STDERR;
|
||||
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
@ -82,7 +84,7 @@ function loadUpgradeTable(string $file, bool $reverse) : array{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param true[] $removedPropertiesCache
|
||||
* @param true[] $removedPropertiesCache
|
||||
* @param Tag[][] $remappedPropertyValuesCache
|
||||
* @phpstan-param array<string, true> $removedPropertiesCache
|
||||
* @phpstan-param array<string, array<string, Tag>> $remappedPropertyValuesCache
|
||||
|
@ -40,6 +40,11 @@ use function json_decode;
|
||||
use function json_encode;
|
||||
use function ksort;
|
||||
use function scandir;
|
||||
use const JSON_FORCE_OBJECT;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const SCANDIR_SORT_ASCENDING;
|
||||
use const SORT_STRING;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
|
@ -49,9 +49,13 @@ use function socket_strerror;
|
||||
use function strlen;
|
||||
use function time;
|
||||
use function trim;
|
||||
use const AF_INET;
|
||||
use const MSG_DONTROUTE;
|
||||
use const PHP_BINARY;
|
||||
use const PHP_INT_MAX;
|
||||
use const SOCK_DGRAM;
|
||||
use const SOL_UDP;
|
||||
use const STDIN;
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user