Merge branch 'next-major' into modern-world-support

This commit is contained in:
Dylan K. Taylor 2022-04-28 21:06:44 +01:00
commit 0326c4964b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
173 changed files with 692 additions and 1339 deletions

@ -1 +1 @@
Subproject commit 1fae6b8d4ab89757316e7e70e77cadfd4fd26b3e Subproject commit 7b357f8cf9b2d2ee3a9ad247cdc76c8ad62337f9

View File

@ -12,3 +12,10 @@ Released 20th April 2022.
## General ## General
- Added support for Minecraft: Bedrock Edition 1.18.30. - Added support for Minecraft: Bedrock Edition 1.18.30.
- Removed support for older versions. - Removed support for older versions.
# 4.3.1
Released 23rd April 2022.
## Fixes
- Updated BedrockProtocol dependency to fix incorrect command argument types.
- Creative players no longer die in the void.

View File

@ -54,9 +54,9 @@
"webmozart/path-util": "^2.3" "webmozart/path-util": "^2.3"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "1.5.6", "phpstan/phpstan": "1.6.3",
"phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-phpunit": "^1.1.0",
"phpstan/phpstan-strict-rules": "^1.0.0", "phpstan/phpstan-strict-rules": "^1.2.0",
"phpunit/phpunit": "^9.2" "phpunit/phpunit": "^9.2"
}, },
"autoload": { "autoload": {

61
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "90fd504df83303dbc46c7834a312f3b0", "content-hash": "f28b4d0dae7984a204a5538b7f614ee4",
"packages": [ "packages": [
{ {
"name": "adhocore/json-comment", "name": "adhocore/json-comment",
@ -302,16 +302,16 @@
}, },
{ {
"name": "pocketmine/bedrock-protocol", "name": "pocketmine/bedrock-protocol",
"version": "9.0.0+bedrock-1.18.30", "version": "9.0.1+bedrock-1.18.30",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git", "url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "76cf00af0070dbb3f63a3e7fe74039d011a5475e" "reference": "9d3cc87c4d26c002dd42aa9af20c0cd47a72018e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/76cf00af0070dbb3f63a3e7fe74039d011a5475e", "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/9d3cc87c4d26c002dd42aa9af20c0cd47a72018e",
"reference": "76cf00af0070dbb3f63a3e7fe74039d011a5475e", "reference": "9d3cc87c4d26c002dd42aa9af20c0cd47a72018e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -325,7 +325,7 @@
"ramsey/uuid": "^4.1" "ramsey/uuid": "^4.1"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "1.5.4", "phpstan/phpstan": "1.5.7",
"phpstan/phpstan-phpunit": "^1.0.0", "phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0", "phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5" "phpunit/phpunit": "^9.5"
@ -343,9 +343,9 @@
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP", "description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
"support": { "support": {
"issues": "https://github.com/pmmp/BedrockProtocol/issues", "issues": "https://github.com/pmmp/BedrockProtocol/issues",
"source": "https://github.com/pmmp/BedrockProtocol/tree/9.0.0+bedrock-1.18.30" "source": "https://github.com/pmmp/BedrockProtocol/tree/9.0.1+bedrock-1.18.30"
}, },
"time": "2022-04-20T12:44:11+00:00" "time": "2022-04-23T14:48:16+00:00"
}, },
{ {
"name": "pocketmine/binaryutils", "name": "pocketmine/binaryutils",
@ -1846,16 +1846,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.5.6", "version": "1.6.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "799dd8c2d2c9c704bb55d2078078cb970cf0f6d1" "reference": "6128620b98292e0b69ea6d799871d77163681c8e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/799dd8c2d2c9c704bb55d2078078cb970cf0f6d1", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6128620b98292e0b69ea6d799871d77163681c8e",
"reference": "799dd8c2d2c9c704bb55d2078078cb970cf0f6d1", "reference": "6128620b98292e0b69ea6d799871d77163681c8e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1881,7 +1881,7 @@
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan/issues", "issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.5.6" "source": "https://github.com/phpstan/phpstan/tree/1.6.3"
}, },
"funding": [ "funding": [
{ {
@ -1901,20 +1901,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-04-15T11:13:37+00:00" "time": "2022-04-28T11:27:53+00:00"
}, },
{ {
"name": "phpstan/phpstan-phpunit", "name": "phpstan/phpstan-phpunit",
"version": "1.1.0", "version": "1.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git", "url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "09133ce914f1388a8bb8c7f8573aaa3723cff52a" "reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/09133ce914f1388a8bb8c7f8573aaa3723cff52a", "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4a3c437c09075736285d1cabb5c75bf27ed0bc84",
"reference": "09133ce914f1388a8bb8c7f8573aaa3723cff52a", "reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1951,27 +1951,27 @@
"description": "PHPUnit extensions and rules for PHPStan", "description": "PHPUnit extensions and rules for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues", "issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.1.0" "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.1.1"
}, },
"time": "2022-03-28T09:20:49+00:00" "time": "2022-04-20T15:24:25+00:00"
}, },
{ {
"name": "phpstan/phpstan-strict-rules", "name": "phpstan/phpstan-strict-rules",
"version": "1.1.0", "version": "1.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-strict-rules.git", "url": "https://github.com/phpstan/phpstan-strict-rules.git",
"reference": "e12d55f74a8cca18c6e684c6450767e055ba7717" "reference": "f3ca6464eae640a556c69a02b3b77a2507475d2f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/e12d55f74a8cca18c6e684c6450767e055ba7717", "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/f3ca6464eae640a556c69a02b3b77a2507475d2f",
"reference": "e12d55f74a8cca18c6e684c6450767e055ba7717", "reference": "f3ca6464eae640a556c69a02b3b77a2507475d2f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.2.0" "phpstan/phpstan": "^1.6.3"
}, },
"require-dev": { "require-dev": {
"nikic/php-parser": "^4.13.0", "nikic/php-parser": "^4.13.0",
@ -1981,9 +1981,6 @@
}, },
"type": "phpstan-extension", "type": "phpstan-extension",
"extra": { "extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"phpstan": { "phpstan": {
"includes": [ "includes": [
"rules.neon" "rules.neon"
@ -2002,9 +1999,9 @@
"description": "Extra strict and opinionated rules for PHPStan", "description": "Extra strict and opinionated rules for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-strict-rules/issues", "issues": "https://github.com/phpstan/phpstan-strict-rules/issues",
"source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.1.0" "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.2.1"
}, },
"time": "2021-11-18T09:30:29+00:00" "time": "2022-04-28T07:20:18+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -3481,5 +3478,5 @@
"platform-overrides": { "platform-overrides": {
"php": "8.0.0" "php": "8.0.0"
}, },
"plugin-api-version": "2.2.0" "plugin-api-version": "2.3.0"
} }

View File

@ -33,16 +33,14 @@ use function strtolower;
final class ServerConfigGroup{ final class ServerConfigGroup{
/** @var Config */ private Config $pocketmineYml;
private $pocketmineYml; private Config $serverProperties;
/** @var Config */
private $serverProperties;
/** /**
* @var mixed[] * @var mixed[]
* @phpstan-var array<string, mixed> * @phpstan-var array<string, mixed>
*/ */
private $propertyCache = []; private array $propertyCache = [];
public function __construct(Config $pocketmineYml, Config $serverProperties){ public function __construct(Config $pocketmineYml, Config $serverProperties){
$this->pocketmineYml = $pocketmineYml; $this->pocketmineYml = $pocketmineYml;

View File

@ -39,8 +39,7 @@ final class VersionInfo{
//NOOP //NOOP
} }
/** @var string|null */ private static ?string $gitHash = null;
private static $gitHash = null;
public static function GIT_HASH() : string{ public static function GIT_HASH() : string{
if(self::$gitHash === null){ if(self::$gitHash === null){
@ -79,8 +78,7 @@ final class VersionInfo{
return self::$buildNumber; return self::$buildNumber;
} }
/** @var VersionString|null */ private static ?VersionString $fullVersion = null;
private static $fullVersion = null;
public static function VERSION() : VersionString{ public static function VERSION() : VersionString{
if(self::$fullVersion === null){ if(self::$fullVersion === null){

View File

@ -152,7 +152,7 @@ class Block{
$oldTile->close(); $oldTile->close();
$oldTile = null; $oldTile = null;
}elseif($oldTile instanceof Spawnable){ }elseif($oldTile instanceof Spawnable){
$oldTile->setDirty(); //destroy old network cache $oldTile->clearSpawnCompoundCache(); //destroy old network cache
} }
} }
if($oldTile === null && $tileType !== null){ if($oldTile === null && $tileType !== null){

View File

@ -33,10 +33,8 @@ use pocketmine\world\sound\Sound;
class DoubleChestInventory extends BaseInventory implements BlockInventory, InventoryHolder{ class DoubleChestInventory extends BaseInventory implements BlockInventory, InventoryHolder{
use AnimatedBlockInventoryTrait; use AnimatedBlockInventoryTrait;
/** @var ChestInventory */ private ChestInventory $left;
private $left; private ChestInventory $right;
/** @var ChestInventory */
private $right;
public function __construct(ChestInventory $left, ChestInventory $right){ public function __construct(ChestInventory $left, ChestInventory $right){
$this->left = $left; $this->left = $left;

View File

@ -44,14 +44,13 @@ class Banner extends Spawnable{
public const TAG_PATTERN_COLOR = "Color"; public const TAG_PATTERN_COLOR = "Color";
public const TAG_PATTERN_NAME = "Pattern"; public const TAG_PATTERN_NAME = "Pattern";
/** @var DyeColor */ private DyeColor $baseColor;
private $baseColor;
/** /**
* @var BannerPatternLayer[] * @var BannerPatternLayer[]
* @phpstan-var list<BannerPatternLayer> * @phpstan-var list<BannerPatternLayer>
*/ */
private $patterns = []; private array $patterns = [];
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
$this->baseColor = DyeColor::BLACK(); $this->baseColor = DyeColor::BLACK();

View File

@ -29,10 +29,8 @@ final class Beacon extends Spawnable{
private const TAG_PRIMARY = "primary"; //TAG_Int private const TAG_PRIMARY = "primary"; //TAG_Int
private const TAG_SECONDARY = "secondary"; //TAG_Int private const TAG_SECONDARY = "secondary"; //TAG_Int
/** @var int */ private int $primaryEffect = 0;
private $primaryEffect = 0; private int $secondaryEffect = 0;
/** @var int */
private $secondaryEffect = 0;
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{ protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
$nbt->setInt(self::TAG_PRIMARY, $this->primaryEffect); $nbt->setInt(self::TAG_PRIMARY, $this->primaryEffect);

View File

@ -32,8 +32,8 @@ use pocketmine\world\World;
class Bed extends Spawnable{ class Bed extends Spawnable{
public const TAG_COLOR = "color"; public const TAG_COLOR = "color";
/** @var DyeColor */
private $color; private DyeColor $color;
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
$this->color = DyeColor::RED(); $this->color = DyeColor::RED();

View File

@ -49,10 +49,8 @@ class Chest extends Spawnable implements Container, Nameable{
/** @var DoubleChestInventory|null */ /** @var DoubleChestInventory|null */
protected $doubleInventory = null; protected $doubleInventory = null;
/** @var int|null */ private ?int $pairX = null;
private $pairX; private ?int $pairZ = null;
/** @var int|null */
private $pairZ;
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
parent::__construct($world, $pos); parent::__construct($world, $pos);
@ -188,8 +186,8 @@ class Chest extends Spawnable implements Container, Nameable{
$this->createPair($tile); $this->createPair($tile);
$this->setDirty(); $this->clearSpawnCompoundCache();
$tile->setDirty(); $tile->clearSpawnCompoundCache();
$this->checkPairing(); $this->checkPairing();
return true; return true;
@ -211,12 +209,12 @@ class Chest extends Spawnable implements Container, Nameable{
$tile = $this->getPair(); $tile = $this->getPair();
$this->pairX = $this->pairZ = null; $this->pairX = $this->pairZ = null;
$this->setDirty(); $this->clearSpawnCompoundCache();
if($tile instanceof Chest){ if($tile instanceof Chest){
$tile->pairX = $tile->pairZ = null; $tile->pairX = $tile->pairZ = null;
$tile->checkPairing(); $tile->checkPairing();
$tile->setDirty(); $tile->clearSpawnCompoundCache();
} }
$this->checkPairing(); $this->checkPairing();

View File

@ -38,8 +38,7 @@ class FlowerPot extends Spawnable{
private const TAG_ITEM = "item"; private const TAG_ITEM = "item";
private const TAG_ITEM_DATA = "mData"; private const TAG_ITEM_DATA = "mData";
/** @var Block|null */ private ?Block $plant = null;
private $plant = null;
public function readSaveData(CompoundTag $nbt) : void{ public function readSaveData(CompoundTag $nbt) : void{
if(($itemIdTag = $nbt->getTag(self::TAG_ITEM)) instanceof ShortTag && ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){ if(($itemIdTag = $nbt->getTag(self::TAG_ITEM)) instanceof ShortTag && ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){

View File

@ -50,12 +50,9 @@ abstract class Furnace extends Spawnable implements Container, Nameable{
/** @var FurnaceInventory */ /** @var FurnaceInventory */
protected $inventory; protected $inventory;
/** @var int */ private int $remainingFuelTime = 0;
private $remainingFuelTime = 0; private int $cookTime = 0;
/** @var int */ private int $maxFuelTime = 0;
private $cookTime = 0;
/** @var int */
private $maxFuelTime = 0;
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
parent::__construct($world, $pos); parent::__construct($world, $pos);

View File

@ -35,11 +35,8 @@ class Hopper extends Spawnable implements Container, Nameable{
private const TAG_TRANSFER_COOLDOWN = "TransferCooldown"; private const TAG_TRANSFER_COOLDOWN = "TransferCooldown";
/** @var HopperInventory */ private HopperInventory $inventory;
private $inventory; private int $transferCooldown = 0;
/** @var int */
private $transferCooldown = 0;
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
parent::__construct($world, $pos); parent::__construct($world, $pos);

View File

@ -38,12 +38,9 @@ class ItemFrame extends Spawnable{
public const TAG_ITEM_DROP_CHANCE = "ItemDropChance"; public const TAG_ITEM_DROP_CHANCE = "ItemDropChance";
public const TAG_ITEM = "Item"; public const TAG_ITEM = "Item";
/** @var Item */ private Item $item;
private $item; private int $itemRotation = 0;
/** @var int */ private float $itemDropChance = 1.0;
private $itemRotation = 0;
/** @var float */
private $itemDropChance = 1.0;
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
$this->item = VanillaItems::AIR(); $this->item = VanillaItems::AIR();

View File

@ -30,8 +30,7 @@ use pocketmine\nbt\tag\CompoundTag;
class Jukebox extends Spawnable{ class Jukebox extends Spawnable{
private const TAG_RECORD = "RecordItem"; //Item CompoundTag private const TAG_RECORD = "RecordItem"; //Item CompoundTag
/** @var Record|null */ private ?Record $record = null;
private $record = null;
public function getRecord() : ?Record{ public function getRecord() : ?Record{
return $this->record; return $this->record;

View File

@ -56,43 +56,24 @@ class MonsterSpawner extends Spawnable{
public const DEFAULT_SPAWN_RANGE = 4; //blocks public const DEFAULT_SPAWN_RANGE = 4; //blocks
public const DEFAULT_REQUIRED_PLAYER_RANGE = 16; public const DEFAULT_REQUIRED_PLAYER_RANGE = 16;
/** /** TODO: replace this with a cached entity or something of that nature */
* @var string private string $entityTypeId = ":";
* TODO: replace this with a cached entity or something of that nature /** TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) */
*/ private ?ListTag $spawnPotentials = null;
private $entityTypeId = ":"; /** TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) */
/** private ?CompoundTag $spawnData = null;
* @var ListTag|null
* TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun)
*/
private $spawnPotentials = null;
/**
* @var CompoundTag|null
* TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun)
*/
private $spawnData = null;
/** @var float */ private float $displayEntityWidth = 1.0;
private $displayEntityWidth = 1; private float $displayEntityHeight = 1.0;
/** @var float */ private float $displayEntityScale = 1.0;
private $displayEntityHeight = 1;
/** @var float */
private $displayEntityScale = 1;
/** @var int */ private int $spawnDelay = self::DEFAULT_MIN_SPAWN_DELAY;
private $spawnDelay = self::DEFAULT_MIN_SPAWN_DELAY; private int $minSpawnDelay = self::DEFAULT_MIN_SPAWN_DELAY;
/** @var int */ private int $maxSpawnDelay = self::DEFAULT_MAX_SPAWN_DELAY;
private $minSpawnDelay = self::DEFAULT_MIN_SPAWN_DELAY; private int $spawnPerAttempt = 1;
/** @var int */ private int $maxNearbyEntities = self::DEFAULT_MAX_NEARBY_ENTITIES;
private $maxSpawnDelay = self::DEFAULT_MAX_SPAWN_DELAY; private int $spawnRange = self::DEFAULT_SPAWN_RANGE;
/** @var int */ private int $requiredPlayerRange = self::DEFAULT_REQUIRED_PLAYER_RANGE;
private $spawnPerAttempt = 1;
/** @var int */
private $maxNearbyEntities = self::DEFAULT_MAX_NEARBY_ENTITIES;
/** @var int */
private $spawnRange = self::DEFAULT_SPAWN_RANGE;
/** @var int */
private $requiredPlayerRange = self::DEFAULT_REQUIRED_PLAYER_RANGE;
public function readSaveData(CompoundTag $nbt) : void{ public function readSaveData(CompoundTag $nbt) : void{
if(($legacyIdTag = $nbt->getTag(self::TAG_LEGACY_ENTITY_TYPE_ID)) instanceof IntTag){ if(($legacyIdTag = $nbt->getTag(self::TAG_LEGACY_ENTITY_TYPE_ID)) instanceof IntTag){

View File

@ -30,8 +30,7 @@ use pocketmine\nbt\tag\CompoundTag;
* @deprecated * @deprecated
*/ */
class Note extends Tile{ class Note extends Tile{
/** @var int */ private int $pitch = 0;
private $pitch = 0;
public function readSaveData(CompoundTag $nbt) : void{ public function readSaveData(CompoundTag $nbt) : void{
if(($pitch = $nbt->getByte("note", $this->pitch)) > BlockNote::MIN_PITCH && $pitch <= BlockNote::MAX_PITCH){ if(($pitch = $nbt->getByte("note", $this->pitch)) > BlockNote::MIN_PITCH && $pitch <= BlockNote::MAX_PITCH){

View File

@ -40,10 +40,8 @@ class Skull extends Spawnable{
private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte
private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int
/** @var SkullType */ private SkullType $skullType;
private $skullType; private int $skullRotation = 0;
/** @var int */
private $skullRotation = 0;
public function __construct(World $world, Vector3 $pos){ public function __construct(World $world, Vector3 $pos){
$this->skullType = SkullType::SKELETON(); $this->skullType = SkullType::SKELETON();

View File

@ -28,26 +28,25 @@ use pocketmine\network\mcpe\protocol\types\CacheableNbt;
use function get_class; use function get_class;
abstract class Spawnable extends Tile{ abstract class Spawnable extends Tile{
/** /** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */
* @var CacheableNbt|null private ?CacheableNbt $spawnCompoundCache = null;
* @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null
*/
private $spawnCompoundCache = null;
/** @var bool */
private $dirty = true; //default dirty, until it's been spawned appropriately on the world
/** /**
* Returns whether the tile needs to be respawned to viewers. * @deprecated
*/ */
public function isDirty() : bool{ public function isDirty() : bool{
return $this->dirty; return $this->spawnCompoundCache === null;
} }
/**
* @deprecated
*/
public function setDirty(bool $dirty = true) : void{ public function setDirty(bool $dirty = true) : void{
if($dirty){ $this->clearSpawnCompoundCache();
$this->spawnCompoundCache = null;
} }
$this->dirty = $dirty;
public function clearSpawnCompoundCache() : void{
$this->spawnCompoundCache = null;
} }
/** /**

View File

@ -42,12 +42,12 @@ final class TileFactory{
* @var string[] classes that extend Tile * @var string[] classes that extend Tile
* @phpstan-var array<string, class-string<Tile>> * @phpstan-var array<string, class-string<Tile>>
*/ */
private $knownTiles = []; private array $knownTiles = [];
/** /**
* @var string[] * @var string[]
* @phpstan-var array<class-string<Tile>, string> * @phpstan-var array<class-string<Tile>, string>
*/ */
private $saveNames = []; private array $saveNames = [];
public function __construct(){ public function __construct(){
$this->register(Barrel::class, ["Barrel", "minecraft:barrel"]); $this->register(Barrel::class, ["Barrel", "minecraft:barrel"]);

View File

@ -30,14 +30,10 @@ use pocketmine\block\BaseBanner;
* @see BaseBanner * @see BaseBanner
*/ */
class BannerPatternLayer{ class BannerPatternLayer{
private BannerPatternType $type; public function __construct(
/** @var DyeColor */ private BannerPatternType $type,
private $color; private DyeColor $color
){}
public function __construct(BannerPatternType $type, DyeColor $color){
$this->type = $type;
$this->color = $color;
}
public function getType() : BannerPatternType{ return $this->type; } public function getType() : BannerPatternType{ return $this->type; }

View File

@ -42,9 +42,6 @@ final class CoralType{
__construct as Enum___construct; __construct as Enum___construct;
} }
/** @var string */
private $displayName;
protected static function setup() : void{ protected static function setup() : void{
self::registerAll( self::registerAll(
new self("tube", "Tube"), new self("tube", "Tube"),
@ -55,9 +52,11 @@ final class CoralType{
); );
} }
private function __construct(string $name, string $displayName){ private function __construct(
string $name,
private string $displayName
){
$this->Enum___construct($name); $this->Enum___construct($name);
$this->displayName = $displayName;
} }
public function getDisplayName() : string{ return $this->displayName; } public function getDisplayName() : string{ return $this->displayName; }

View File

@ -75,15 +75,12 @@ final class DyeColor{
); );
} }
/** @var string */ private function __construct(
private $displayName; string $enumName,
/** @var Color */ private string $displayName,
private $rgbValue; private Color $rgbValue
){
private function __construct(string $enumName, string $displayName, Color $rgbValue){
$this->Enum___construct($enumName); $this->Enum___construct($enumName);
$this->displayName = $displayName;
$this->rgbValue = $rgbValue;
} }
public function getDisplayName() : string{ public function getDisplayName() : string{

View File

@ -70,15 +70,13 @@ final class RecordType{
); );
} }
/** @var string */ private function __construct(
private $soundName; string $enumName,
/** @var int */ private string $soundName,
private $soundId; private int $soundId,
private Translatable $translatableName
private function __construct(string $enumName, string $soundName, int $soundId, private Translatable $translatableName){ ){
$this->Enum___construct($enumName); $this->Enum___construct($enumName);
$this->soundName = $soundName;
$this->soundId = $soundId;
} }
public function getSoundName() : string{ public function getSoundName() : string{

View File

@ -36,7 +36,7 @@ class SignText{
public const LINE_COUNT = 4; public const LINE_COUNT = 4;
/** @var string[] */ /** @var string[] */
private $lines; private array $lines;
/** /**
* @param string[]|null $lines index-sensitive; omitting an index will leave it unchanged * @param string[]|null $lines index-sensitive; omitting an index will leave it unchanged

View File

@ -45,7 +45,7 @@ final class SkullType{
} }
/** @var SkullType[] */ /** @var SkullType[] */
private static $numericIdMap = []; private static array $numericIdMap = [];
protected static function setup() : void{ protected static function setup() : void{
self::registerAll( self::registerAll(
@ -75,15 +75,12 @@ final class SkullType{
return self::$numericIdMap[$magicNumber]; return self::$numericIdMap[$magicNumber];
} }
/** @var string */ private function __construct(
private $displayName; string $enumName,
/** @var int */ private string $displayName,
private $magicNumber; private int $magicNumber
){
private function __construct(string $enumName, string $displayName, int $magicNumber){
$this->Enum___construct($enumName); $this->Enum___construct($enumName);
$this->displayName = $displayName;
$this->magicNumber = $magicNumber;
} }
public function getDisplayName() : string{ public function getDisplayName() : string{

View File

@ -45,7 +45,7 @@ final class TreeType{
} }
/** @var TreeType[] */ /** @var TreeType[] */
private static $numericIdMap = []; private static array $numericIdMap = [];
protected static function setup() : void{ protected static function setup() : void{
self::registerAll( self::registerAll(
@ -76,15 +76,12 @@ final class TreeType{
return self::$numericIdMap[$magicNumber]; return self::$numericIdMap[$magicNumber];
} }
/** @var string */ private function __construct(
private $displayName; string $enumName,
/** @var int */ private string $displayName,
private $magicNumber; private int $magicNumber
){
private function __construct(string $enumName, string $displayName, int $magicNumber){
$this->Enum___construct($enumName); $this->Enum___construct($enumName);
$this->displayName = $displayName;
$this->magicNumber = $magicNumber;
} }
public function getDisplayName() : string{ public function getDisplayName() : string{

View File

@ -40,23 +40,18 @@ use function str_replace;
abstract class Command{ abstract class Command{
/** @var string */ private string $name;
private $name;
/** @var string */ private string $nextLabel;
private $nextLabel; private string $label;
/** @var string */
private $label;
/** @var string[] */ /** @var string[] */
private $aliases = []; private array $aliases = [];
/** @var string[] */ /** @var string[] */
private $activeAliases = []; private array $activeAliases = [];
/** @var CommandMap|null */ private ?CommandMap $commandMap = null;
private $commandMap = null;
/** @var Translatable|string */ /** @var Translatable|string */
protected $description = ""; protected $description = "";
@ -64,11 +59,8 @@ abstract class Command{
/** @var Translatable|string */ /** @var Translatable|string */
protected $usageMessage; protected $usageMessage;
/** @var string|null */ private ?string $permission = null;
private $permission = null; private ?string $permissionMessage = null;
/** @var string|null */
private $permissionMessage = null;
/** @var TimingsHandler|null */ /** @var TimingsHandler|null */
public $timings = null; public $timings = null;

View File

@ -33,7 +33,7 @@ use function substr;
class FormattedCommandAlias extends Command{ class FormattedCommandAlias extends Command{
/** @var string[] */ /** @var string[] */
private $formatStrings = []; private array $formatStrings = [];
/** /**
* @param string[] $formatStrings * @param string[] $formatStrings

View File

@ -31,8 +31,7 @@ use pocketmine\plugin\PluginOwnedTrait;
final class PluginCommand extends Command implements PluginOwned{ final class PluginCommand extends Command implements PluginOwned{
use PluginOwnedTrait; use PluginOwnedTrait;
/** @var CommandExecutor */ private CommandExecutor $executor;
private $executor;
public function __construct(string $name, Plugin $owner, CommandExecutor $executor){ public function __construct(string $name, Plugin $owner, CommandExecutor $executor){
parent::__construct($name); parent::__construct($name);

View File

@ -84,11 +84,7 @@ class SimpleCommandMap implements CommandMap{
/** @var Command[] */ /** @var Command[] */
protected $knownCommands = []; protected $knownCommands = [];
/** @var Server */ public function __construct(private Server $server){
private $server;
public function __construct(Server $server){
$this->server = $server;
$this->setDefaultCommands(); $this->setDefaultCommands();
} }

View File

@ -33,17 +33,12 @@ abstract class CraftingGrid extends SimpleInventory{
public const SIZE_SMALL = 2; public const SIZE_SMALL = 2;
public const SIZE_BIG = 3; public const SIZE_BIG = 3;
/** @var int */ private int $gridWidth;
private $gridWidth;
/** @var int|null */ private ?int $startX = null;
private $startX; private ?int $xLen = null;
/** @var int|null */ private ?int $startY = null;
private $xLen; private ?int $yLen = null;
/** @var int|null */
private $startY;
/** @var int|null */
private $yLen;
public function __construct(int $gridWidth){ public function __construct(int $gridWidth){
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;

View File

@ -57,11 +57,8 @@ class CraftingManager{
*/ */
protected $potionContainerChangeRecipes = []; protected $potionContainerChangeRecipes = [];
/** /** @phpstan-var ObjectSet<\Closure() : void> */
* @var ObjectSet private ObjectSet $recipeRegisteredCallbacks;
* @phpstan-var ObjectSet<\Closure() : void>
*/
private $recipeRegisteredCallbacks;
public function __construct(){ public function __construct(){
$this->recipeRegisteredCallbacks = new ObjectSet(); $this->recipeRegisteredCallbacks = new ObjectSet();

View File

@ -27,14 +27,11 @@ use pocketmine\item\Item;
class FurnaceRecipe{ class FurnaceRecipe{
/** @var Item */ public function __construct(
private $output; private Item $result,
private Item $ingredient
/** @var Item */ ){
private $ingredient; $this->result = clone $result;
public function __construct(Item $result, Item $ingredient){
$this->output = clone $result;
$this->ingredient = clone $ingredient; $this->ingredient = clone $ingredient;
} }
@ -43,6 +40,6 @@ class FurnaceRecipe{
} }
public function getResult() : Item{ public function getResult() : Item{
return clone $this->output; return clone $this->result;
} }
} }

View File

@ -30,11 +30,8 @@ final class FurnaceRecipeManager{
/** @var FurnaceRecipe[] */ /** @var FurnaceRecipe[] */
protected $furnaceRecipes = []; protected $furnaceRecipes = [];
/** /** @phpstan-var ObjectSet<\Closure(FurnaceRecipe) : void> */
* @var ObjectSet private ObjectSet $recipeRegisteredCallbacks;
* @phpstan-var ObjectSet<\Closure(FurnaceRecipe) : void>
*/
private $recipeRegisteredCallbacks;
public function __construct(){ public function __construct(){
$this->recipeRegisteredCallbacks = new ObjectSet(); $this->recipeRegisteredCallbacks = new ObjectSet();

View File

@ -34,16 +34,14 @@ use function strpos;
class ShapedRecipe implements CraftingRecipe{ class ShapedRecipe implements CraftingRecipe{
/** @var string[] */ /** @var string[] */
private $shape = []; private array $shape = [];
/** @var Item[] char => Item map */ /** @var Item[] char => Item map */
private $ingredientList = []; private array $ingredientList = [];
/** @var Item[] */ /** @var Item[] */
private $results = []; private array $results = [];
/** @var int */ private int $height;
private $height; private int $width;
/** @var int */
private $width;
/** /**
* Constructs a ShapedRecipe instance. * Constructs a ShapedRecipe instance.

View File

@ -29,9 +29,9 @@ use function count;
class ShapelessRecipe implements CraftingRecipe{ class ShapelessRecipe implements CraftingRecipe{
/** @var Item[] */ /** @var Item[] */
private $ingredients = []; private array $ingredients = [];
/** @var Item[] */ /** @var Item[] */
private $results; private array $results;
/** /**
* @param Item[] $ingredients No more than 9 total. This applies to sum of item stack counts, not count of array. * @param Item[] $ingredients No more than 9 total. This applies to sum of item stack counts, not count of array.

View File

@ -29,12 +29,8 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class ArmSwingAnimation implements Animation{ final class ArmSwingAnimation implements Animation{
/** @var Living */ //TODO: not sure if this should be constrained to humanoids, but we don't have any concept of that right now
private $entity; //TODO: not sure if this should be constrained to humanoids, but we don't have any concept of that right now public function __construct(private Living $entity){}
public function __construct(Living $entity){
$this->entity = $entity;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -29,15 +29,10 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
class ArrowShakeAnimation implements Animation{ class ArrowShakeAnimation implements Animation{
/** @var Arrow */ public function __construct(
private $arrow; private Arrow $arrow,
/** @var int */ private int $durationInTicks
private $durationInTicks; ){}
public function __construct(Arrow $arrow, int $durationInTicks){
$this->arrow = $arrow;
$this->durationInTicks = $durationInTicks;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -31,16 +31,10 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class ConsumingItemAnimation implements Animation{ final class ConsumingItemAnimation implements Animation{
/** @var Human */ public function __construct(
private $human; private Human $human, //TODO: maybe this can be expanded to more than just player entities?
/** @var Item */ private Item $item
private $item; ){}
public function __construct(Human $human, Item $item){
//TODO: maybe this can be expanded to more than just player entities?
$this->human = $human;
$this->item = $item;
}
public function encode() : array{ public function encode() : array{
[$netId, $netData] = ItemTranslator::getInstance()->toNetworkId($this->item->getId(), $this->item->getMeta()); [$netId, $netData] = ItemTranslator::getInstance()->toNetworkId($this->item->getId(), $this->item->getMeta());

View File

@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\AnimatePacket;
final class CriticalHitAnimation implements Animation{ final class CriticalHitAnimation implements Animation{
/** @var Living */ public function __construct(private Living $entity){}
private $entity;
public function __construct(Living $entity){
$this->entity = $entity;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class DeathAnimation implements Animation{ final class DeathAnimation implements Animation{
/** @var Living */ public function __construct(private Living $entity){}
private $entity;
public function __construct(Living $entity){
$this->entity = $entity;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class HurtAnimation implements Animation{ final class HurtAnimation implements Animation{
/** @var Living */ public function __construct(private Living $entity){}
private $entity;
public function __construct(Living $entity){
$this->entity = $entity;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class RespawnAnimation implements Animation{ final class RespawnAnimation implements Animation{
/** @var Living */ public function __construct(private Living $entity){}
private $entity;
public function __construct(Living $entity){
$this->entity = $entity;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class SquidInkCloudAnimation implements Animation{ final class SquidInkCloudAnimation implements Animation{
/** @var Squid */ public function __construct(private Squid $squid){}
private $squid;
public function __construct(Squid $squid){
$this->squid = $squid;
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -29,13 +29,8 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
final class TotemUseAnimation implements Animation{ final class TotemUseAnimation implements Animation{
/** @var Human */
private $human;
public function __construct(Human $human){
//TODO: check if this can be expanded to more than just humans //TODO: check if this can be expanded to more than just humans
$this->human = $human; public function __construct(private Human $human){}
}
public function encode() : array{ public function encode() : array{
return [ return [

View File

@ -33,11 +33,11 @@ use pocketmine\event\CancellableTrait;
abstract class BaseBlockChangeEvent extends BlockEvent implements Cancellable{ abstract class BaseBlockChangeEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
private Block $newState; public function __construct(
Block $block,
public function __construct(Block $block, Block $newState){ private Block $newState
){
parent::__construct($block); parent::__construct($block);
$this->newState = $newState;
} }
public function getNewState() : Block{ public function getNewState() : Block{

View File

@ -33,12 +33,11 @@ use pocketmine\event\CancellableTrait;
class BlockBurnEvent extends BlockEvent implements Cancellable{ class BlockBurnEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Block */ public function __construct(
private $causingBlock; Block $block,
private Block $causingBlock
public function __construct(Block $block, Block $causingBlock){ ){
parent::__construct($block); parent::__construct($block);
$this->causingBlock = $causingBlock;
} }
/** /**

View File

@ -29,12 +29,13 @@ use pocketmine\block\Block;
* Called when a block spreads to another block, such as grass spreading to nearby dirt blocks. * Called when a block spreads to another block, such as grass spreading to nearby dirt blocks.
*/ */
class BlockSpreadEvent extends BaseBlockChangeEvent{ class BlockSpreadEvent extends BaseBlockChangeEvent{
/** @var Block */
private $source;
public function __construct(Block $block, Block $source, Block $newState){ public function __construct(
Block $block,
private Block $source,
Block $newState
){
parent::__construct($block, $newState); parent::__construct($block, $newState);
$this->source = $source;
} }
public function getSource() : Block{ public function getSource() : Block{

View File

@ -32,12 +32,11 @@ use pocketmine\utils\Utils;
class BlockTeleportEvent extends BlockEvent implements Cancellable{ class BlockTeleportEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Vector3 */ public function __construct(
private $to; Block $block,
private Vector3 $to
public function __construct(Block $block, Vector3 $to){ ){
parent::__construct($block); parent::__construct($block);
$this->to = $to;
} }
public function getTo() : Vector3{ public function getTo() : Vector3{

View File

@ -35,20 +35,12 @@ use pocketmine\player\Player;
class SignChangeEvent extends BlockEvent implements Cancellable{ class SignChangeEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var BaseSign */ public function __construct(
private $sign; private BaseSign $sign,
private Player $player,
/** @var Player */ private SignText $text
private $player; ){
/** @var SignText */
private $text;
public function __construct(BaseSign $sign, Player $player, SignText $text){
parent::__construct($sign); parent::__construct($sign);
$this->sign = $sign;
$this->player = $player;
$this->text = $text;
} }
public function getSign() : BaseSign{ public function getSign() : BaseSign{

View File

@ -17,13 +17,12 @@ use pocketmine\world\BlockTransaction;
class StructureGrowEvent extends BlockEvent implements Cancellable{ class StructureGrowEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
private BlockTransaction $transaction; public function __construct(
private ?Player $player; Block $block,
private BlockTransaction $transaction,
public function __construct(Block $block, BlockTransaction $transaction, ?Player $player){ private ?Player $player
){
parent::__construct($block); parent::__construct($block);
$this->transaction = $transaction;
$this->player = $player;
} }
public function getTransaction() : BlockTransaction{ public function getTransaction() : BlockTransaction{

View File

@ -35,15 +35,12 @@ use pocketmine\event\CancellableTrait;
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{ class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Block */ public function __construct(
private $from; Entity $entity,
/** @var Block */ private Block $from,
private $to; private Block $to
){
public function __construct(Entity $entity, Block $from, Block $to){
$this->entity = $entity; $this->entity = $entity;
$this->from = $from;
$this->to = $to;
} }
public function getBlock() : Block{ public function getBlock() : Block{

View File

@ -30,14 +30,11 @@ use pocketmine\entity\Entity;
* Called when an entity takes damage from a block. * Called when an entity takes damage from a block.
*/ */
class EntityDamageByBlockEvent extends EntityDamageEvent{ class EntityDamageByBlockEvent extends EntityDamageEvent{
/** @var Block */
private $damager;
/** /**
* @param float[] $modifiers * @param float[] $modifiers
*/ */
public function __construct(Block $damager, Entity $entity, int $cause, float $damage, array $modifiers = []){ public function __construct(private Block $damager, Entity $entity, int $cause, float $damage, array $modifiers = []){
$this->damager = $damager;
parent::__construct($entity, $cause, $damage, $modifiers); parent::__construct($entity, $cause, $damage, $modifiers);
} }

View File

@ -29,8 +29,7 @@ use pocketmine\entity\Entity;
* Called when an entity takes damage from an entity sourced from another entity, for example being hit by a snowball thrown by a Player. * Called when an entity takes damage from an entity sourced from another entity, for example being hit by a snowball thrown by a Player.
*/ */
class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{ class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
/** @var int */ private int $childEntityEid;
private $childEntityEid;
/** /**
* @param float[] $modifiers * @param float[] $modifiers

View File

@ -31,17 +31,13 @@ use pocketmine\entity\Living;
* Called when an entity takes damage from another entity. * Called when an entity takes damage from another entity.
*/ */
class EntityDamageByEntityEvent extends EntityDamageEvent{ class EntityDamageByEntityEvent extends EntityDamageEvent{
/** @var int */ private int $damagerEntityId;
private $damagerEntityId;
/** @var float */
private $knockBack;
/** /**
* @param float[] $modifiers * @param float[] $modifiers
*/ */
public function __construct(Entity $damager, Entity $entity, int $cause, float $damage, array $modifiers = [], float $knockBack = 0.4){ public function __construct(Entity $damager, Entity $entity, int $cause, float $damage, array $modifiers = [], private float $knockBack = 0.4){
$this->damagerEntityId = $damager->getId(); $this->damagerEntityId = $damager->getId();
$this->knockBack = $knockBack;
parent::__construct($entity, $cause, $damage, $modifiers); parent::__construct($entity, $cause, $damage, $modifiers);
$this->addAttackerModifiers($damager); $this->addAttackerModifiers($damager);
} }

View File

@ -64,31 +64,25 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
public const CAUSE_CUSTOM = 14; public const CAUSE_CUSTOM = 14;
public const CAUSE_STARVATION = 15; public const CAUSE_STARVATION = 15;
/** @var int */ private float $baseDamage;
private $cause; private float $originalBase;
/** @var float */
private $baseDamage;
/** @var float */
private $originalBase;
/** @var float[] */ /** @var float[] */
private $modifiers; private array $originals;
/** @var float[] */ private int $attackCooldown = 10;
private $originals;
/** @var int */
private $attackCooldown = 10;
/** /**
* @param float[] $modifiers * @param float[] $modifiers
*/ */
public function __construct(Entity $entity, int $cause, float $damage, array $modifiers = []){ public function __construct(
Entity $entity,
private int $cause,
float $damage,
private array $modifiers = []
){
$this->entity = $entity; $this->entity = $entity;
$this->cause = $cause;
$this->baseDamage = $this->originalBase = $damage; $this->baseDamage = $this->originalBase = $damage;
$this->originals = $modifiers;
$this->modifiers = $modifiers;
$this->originals = $this->modifiers;
} }
public function getCause() : int{ public function getCause() : int{

View File

@ -31,18 +31,16 @@ use pocketmine\utils\Utils;
* @phpstan-extends EntityEvent<Living> * @phpstan-extends EntityEvent<Living>
*/ */
class EntityDeathEvent extends EntityEvent{ class EntityDeathEvent extends EntityEvent{
/** @var Item[] */
private $drops = [];
/** @var int */
private $xp;
/** /**
* @param Item[] $drops * @param Item[] $drops
*/ */
public function __construct(Living $entity, array $drops = [], int $xp = 0){ public function __construct(
Living $entity,
private array $drops = [],
private int $xp = 0
){
$this->entity = $entity; $this->entity = $entity;
$this->drops = $drops;
$this->xp = $xp;
} }
/** /**

View File

@ -30,12 +30,8 @@ use pocketmine\entity\Entity;
* Called when an effect is added to an Entity. * Called when an effect is added to an Entity.
*/ */
class EntityEffectAddEvent extends EntityEffectEvent{ class EntityEffectAddEvent extends EntityEffectEvent{
/** @var EffectInstance|null */ public function __construct(Entity $entity, EffectInstance $effect, private ?EffectInstance $oldEffect = null){
private $oldEffect;
public function __construct(Entity $entity, EffectInstance $effect, ?EffectInstance $oldEffect = null){
parent::__construct($entity, $effect); parent::__construct($entity, $effect);
$this->oldEffect = $oldEffect;
} }
/** /**

View File

@ -34,12 +34,11 @@ use pocketmine\event\CancellableTrait;
class EntityEffectEvent extends EntityEvent implements Cancellable{ class EntityEffectEvent extends EntityEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var EffectInstance */ public function __construct(
private $effect; Entity $entity,
private EffectInstance $effect
public function __construct(Entity $entity, EffectInstance $effect){ ){
$this->entity = $entity; $this->entity = $entity;
$this->effect = $effect;
} }
public function getEffect() : EffectInstance{ public function getEffect() : EffectInstance{

View File

@ -34,12 +34,11 @@ use pocketmine\math\Vector3;
class EntityMotionEvent extends EntityEvent implements Cancellable{ class EntityMotionEvent extends EntityEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Vector3 */ public function __construct(
private $mot; Entity $entity,
private Vector3 $mot
public function __construct(Entity $entity, Vector3 $mot){ ){
$this->entity = $entity; $this->entity = $entity;
$this->mot = $mot;
} }
public function getVector() : Vector3{ public function getVector() : Vector3{

View File

@ -39,15 +39,12 @@ class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
public const CAUSE_CUSTOM = 3; public const CAUSE_CUSTOM = 3;
public const CAUSE_SATURATION = 4; public const CAUSE_SATURATION = 4;
/** @var float */ public function __construct(
private $amount; Entity $entity,
/** @var int */ private float $amount,
private $reason; private int $regainReason
){
public function __construct(Entity $entity, float $amount, int $regainReason){
$this->entity = $entity; $this->entity = $entity;
$this->amount = $amount;
$this->reason = $regainReason;
} }
public function getAmount() : float{ public function getAmount() : float{
@ -62,6 +59,6 @@ class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
* Returns one of the CAUSE_* constants to indicate why this regeneration occurred. * Returns one of the CAUSE_* constants to indicate why this regeneration occurred.
*/ */
public function getRegainReason() : int{ public function getRegainReason() : int{
return $this->reason; return $this->regainReason;
} }
} }

View File

@ -37,18 +37,16 @@ use function count;
class EntityShootBowEvent extends EntityEvent implements Cancellable{ class EntityShootBowEvent extends EntityEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Item */ private Entity $projectile;
private $bow;
/** @var Entity */
private $projectile;
/** @var float */
private $force;
public function __construct(Living $shooter, Item $bow, Projectile $projectile, float $force){ public function __construct(
Living $shooter,
private Item $bow,
Projectile $projectile,
private float $force
){
$this->entity = $shooter; $this->entity = $shooter;
$this->bow = $bow;
$this->projectile = $projectile; $this->projectile = $projectile;
$this->force = $force;
} }
/** /**

View File

@ -35,15 +35,12 @@ use pocketmine\world\Position;
class EntityTeleportEvent extends EntityEvent implements Cancellable{ class EntityTeleportEvent extends EntityEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Position */ public function __construct(
private $from; Entity $entity,
/** @var Position */ private Position $from,
private $to; private Position $to
){
public function __construct(Entity $entity, Position $from, Position $to){
$this->entity = $entity; $this->entity = $entity;
$this->from = $from;
$this->to = $to;
} }
public function getFrom() : Position{ public function getFrom() : Position{

View File

@ -34,12 +34,11 @@ use pocketmine\event\CancellableTrait;
class EntityTrampleFarmlandEvent extends EntityEvent implements Cancellable{ class EntityTrampleFarmlandEvent extends EntityEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Block */ public function __construct(
private $block; Living $entity,
private Block $block
public function __construct(Living $entity, Block $block){ ){
$this->entity = $entity; $this->entity = $entity;
$this->block = $block;
} }
public function getBlock() : Block{ public function getBlock() : Block{

View File

@ -36,13 +36,11 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
/** @var float */ /** @var float */
protected $force; protected $force;
/** @var bool */ private bool $blockBreaking = true;
private $blockBreaking;
public function __construct(Entity $entity, float $force){ public function __construct(Entity $entity, float $force){
$this->entity = $entity; $this->entity = $entity;
$this->force = $force; $this->force = $force;
$this->blockBreaking = true;
} }
public function getForce() : float{ public function getForce() : float{

View File

@ -28,12 +28,12 @@ use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult; use pocketmine\math\RayTraceResult;
class ProjectileHitBlockEvent extends ProjectileHitEvent{ class ProjectileHitBlockEvent extends ProjectileHitEvent{
/** @var Block */ public function __construct(
private $blockHit; Projectile $entity,
RayTraceResult $rayTraceResult,
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult, Block $blockHit){ private Block $blockHit
){
parent::__construct($entity, $rayTraceResult); parent::__construct($entity, $rayTraceResult);
$this->blockHit = $blockHit;
} }
/** /**

View File

@ -28,12 +28,12 @@ use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult; use pocketmine\math\RayTraceResult;
class ProjectileHitEntityEvent extends ProjectileHitEvent{ class ProjectileHitEntityEvent extends ProjectileHitEvent{
/** @var Entity */ public function __construct(
private $entityHit; Projectile $entity,
RayTraceResult $rayTraceResult,
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult, Entity $entityHit){ private Entity $entityHit
){
parent::__construct($entity, $rayTraceResult); parent::__construct($entity, $rayTraceResult);
$this->entityHit = $entityHit;
} }
/** /**

View File

@ -31,12 +31,11 @@ use pocketmine\math\RayTraceResult;
* @phpstan-extends EntityEvent<Projectile> * @phpstan-extends EntityEvent<Projectile>
*/ */
abstract class ProjectileHitEvent extends EntityEvent{ abstract class ProjectileHitEvent extends EntityEvent{
/** @var RayTraceResult */ public function __construct(
private $rayTraceResult; Projectile $entity,
private RayTraceResult $rayTraceResult
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult){ ){
$this->entity = $entity; $this->entity = $entity;
$this->rayTraceResult = $rayTraceResult;
} }
/** /**

View File

@ -34,28 +34,17 @@ use pocketmine\player\Player;
class CraftItemEvent extends Event implements Cancellable{ class CraftItemEvent extends Event implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var CraftingTransaction */
private $transaction;
/** @var CraftingRecipe */
private $recipe;
/** @var int */
private $repetitions;
/** @var Item[] */
private $inputs;
/** @var Item[] */
private $outputs;
/** /**
* @param Item[] $inputs * @param Item[] $inputs
* @param Item[] $outputs * @param Item[] $outputs
*/ */
public function __construct(CraftingTransaction $transaction, CraftingRecipe $recipe, int $repetitions, array $inputs, array $outputs){ public function __construct(
$this->transaction = $transaction; private CraftingTransaction $transaction,
$this->recipe = $recipe; private CraftingRecipe $recipe,
$this->repetitions = $repetitions; private int $repetitions,
$this->inputs = $inputs; private array $inputs,
$this->outputs = $outputs; private array $outputs
} ){}
/** /**
* Returns the inventory transaction involved in this crafting event. * Returns the inventory transaction involved in this crafting event.

View File

@ -35,20 +35,14 @@ use pocketmine\item\Item;
class FurnaceBurnEvent extends BlockEvent implements Cancellable{ class FurnaceBurnEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Furnace */ private bool $burning = true;
private $furnace;
/** @var Item */
private $fuel;
/** @var int */
private $burnTime;
/** @var bool */
private $burning = true;
public function __construct(Furnace $furnace, Item $fuel, int $burnTime){ public function __construct(
private Furnace $furnace,
private Item $fuel,
private int $burnTime
){
parent::__construct($furnace->getBlock()); parent::__construct($furnace->getBlock());
$this->fuel = $fuel;
$this->burnTime = $burnTime;
$this->furnace = $furnace;
} }
public function getFurnace() : Furnace{ public function getFurnace() : Furnace{

View File

@ -32,19 +32,14 @@ use pocketmine\item\Item;
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{ class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Furnace */ public function __construct(
private $furnace; private Furnace $furnace,
/** @var Item */ private Item $source,
private $source; private Item $result
/** @var Item */ ){
private $result;
public function __construct(Furnace $furnace, Item $source, Item $result){
parent::__construct($furnace->getBlock()); parent::__construct($furnace->getBlock());
$this->source = clone $source; $this->source = clone $source;
$this->source->setCount(1); $this->source->setCount(1);
$this->result = $result;
$this->furnace = $furnace;
} }
public function getFurnace() : Furnace{ public function getFurnace() : Furnace{

View File

@ -27,11 +27,10 @@ use pocketmine\inventory\Inventory;
use pocketmine\player\Player; use pocketmine\player\Player;
class InventoryCloseEvent extends InventoryEvent{ class InventoryCloseEvent extends InventoryEvent{
/** @var Player */ public function __construct(
private $who; Inventory $inventory,
private Player $who
public function __construct(Inventory $inventory, Player $who){ ){
$this->who = $who;
parent::__construct($inventory); parent::__construct($inventory);
} }

View File

@ -31,11 +31,10 @@ use pocketmine\player\Player;
class InventoryOpenEvent extends InventoryEvent implements Cancellable{ class InventoryOpenEvent extends InventoryEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Player */ public function __construct(
private $who; Inventory $inventory,
private Player $who
public function __construct(Inventory $inventory, Player $who){ ){
$this->who = $who;
parent::__construct($inventory); parent::__construct($inventory);
} }

View File

@ -35,12 +35,7 @@ use pocketmine\inventory\transaction\InventoryTransaction;
class InventoryTransactionEvent extends Event implements Cancellable{ class InventoryTransactionEvent extends Event implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var InventoryTransaction */ public function __construct(private InventoryTransaction $transaction){}
private $transaction;
public function __construct(InventoryTransaction $transaction){
$this->transaction = $transaction;
}
public function getTransaction() : InventoryTransaction{ public function getTransaction() : InventoryTransaction{
return $this->transaction; return $this->transaction;

View File

@ -31,12 +31,11 @@ use pocketmine\player\Player;
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{ class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Block */ public function __construct(
private $bed; Player $player,
private Block $bed
public function __construct(Player $player, Block $bed){ ){
$this->player = $player; $this->player = $player;
$this->bed = $bed;
} }
public function getBed() : Block{ public function getBed() : Block{

View File

@ -27,12 +27,11 @@ use pocketmine\block\Block;
use pocketmine\player\Player; use pocketmine\player\Player;
class PlayerBedLeaveEvent extends PlayerEvent{ class PlayerBedLeaveEvent extends PlayerEvent{
/** @var Block */ public function __construct(
private $bed; Player $player,
private Block $bed
public function __construct(Player $player, Block $bed){ ){
$this->player = $player; $this->player = $player;
$this->bed = $bed;
} }
public function getBed() : Block{ public function getBed() : Block{

View File

@ -35,15 +35,12 @@ use pocketmine\player\Player;
class PlayerBlockPickEvent extends PlayerEvent implements Cancellable{ class PlayerBlockPickEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Block */ public function __construct(
private $blockClicked; Player $player,
/** @var Item */ private Block $blockClicked,
private $resultItem; private Item $resultItem
){
public function __construct(Player $player, Block $blockClicked, Item $resultItem){
$this->player = $player; $this->player = $player;
$this->blockClicked = $blockClicked;
$this->resultItem = $resultItem;
} }
public function getBlock() : Block{ public function getBlock() : Block{

View File

@ -35,21 +35,14 @@ use pocketmine\player\Player;
abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Block */ public function __construct(
private $blockClicked; Player $who,
/** @var int */ private Block $blockClicked,
private $blockFace; private int $blockFace,
/** @var Item */ private Item $bucket,
private $bucket; private Item $itemInHand
/** @var Item */ ){
private $item;
public function __construct(Player $who, Block $blockClicked, int $blockFace, Item $bucket, Item $itemInHand){
$this->player = $who; $this->player = $who;
$this->blockClicked = $blockClicked;
$this->blockFace = $blockFace;
$this->item = $itemInHand;
$this->bucket = $bucket;
} }
/** /**
@ -63,11 +56,11 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
* Returns the item in hand after the event * Returns the item in hand after the event
*/ */
public function getItem() : Item{ public function getItem() : Item{
return $this->item; return $this->itemInHand;
} }
public function setItem(Item $item) : void{ public function setItem(Item $item) : void{
$this->item = $item; $this->itemInHand = $item;
} }
public function getBlockClicked() : Block{ public function getBlockClicked() : Block{

View File

@ -34,15 +34,12 @@ use pocketmine\player\Player;
class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{ class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Skin */ public function __construct(
private $oldSkin; Player $player,
/** @var Skin */ private Skin $oldSkin,
private $newSkin; private Skin $newSkin
){
public function __construct(Player $player, Skin $oldSkin, Skin $newSkin){
$this->player = $player; $this->player = $player;
$this->oldSkin = $oldSkin;
$this->newSkin = $newSkin;
} }
public function getOldSkin() : Skin{ public function getOldSkin() : Skin{
@ -53,9 +50,6 @@ class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{
return $this->newSkin; return $this->newSkin;
} }
/**
* @throws \InvalidArgumentException if the specified skin is not valid
*/
public function setNewSkin(Skin $skin) : void{ public function setNewSkin(Skin $skin) : void{
$this->newSkin = $skin; $this->newSkin = $skin;
} }

View File

@ -34,23 +34,12 @@ use function is_a;
*/ */
class PlayerCreationEvent extends Event{ class PlayerCreationEvent extends Event{
/** @var NetworkSession */ /** @phpstan-var class-string<Player> */
private $session; private string $baseClass = Player::class;
/** @phpstan-var class-string<Player> */
private string $playerClass = Player::class;
/** public function __construct(private NetworkSession $session){}
* @var string
* @phpstan-var class-string<Player>
*/
private $baseClass = Player::class;
/**
* @var string
* @phpstan-var class-string<Player>
*/
private $playerClass = Player::class;
public function __construct(NetworkSession $session){
$this->session = $session;
}
public function getNetworkSession() : NetworkSession{ public function getNetworkSession() : NetworkSession{
return $this->session; return $this->session;

View File

@ -39,13 +39,14 @@ class PlayerDataSaveEvent extends Event implements Cancellable{
protected $data; protected $data;
/** @var string */ /** @var string */
protected $playerName; protected $playerName;
/** @var Player|null */
private $player;
public function __construct(CompoundTag $nbt, string $playerName, ?Player $player){ public function __construct(
CompoundTag $nbt,
string $playerName,
private ?Player $player
){
$this->data = $nbt; $this->data = $nbt;
$this->playerName = $playerName; $this->playerName = $playerName;
$this->player = $player;
} }
/** /**

View File

@ -38,10 +38,8 @@ class PlayerDeathEvent extends EntityDeathEvent{
/** @var Player */ /** @var Player */
protected $player; protected $player;
/** @var Translatable|string */ private Translatable|string $deathMessage;
private $deathMessage; private bool $keepInventory = false;
/** @var bool */
private $keepInventory = false;
/** /**
* @param Item[] $drops * @param Item[] $drops

View File

@ -27,15 +27,12 @@ use pocketmine\player\Player;
class PlayerDisplayNameChangeEvent extends PlayerEvent{ class PlayerDisplayNameChangeEvent extends PlayerEvent{
/** @var string */ public function __construct(
private $oldName; Player $player,
/** @var string */ private string $oldName,
private $newName; private string $newName
){
public function __construct(Player $player, string $oldName, string $newName){
$this->player = $player; $this->player = $player;
$this->oldName = $oldName;
$this->newName = $newName;
} }
public function getOldName() : string{ public function getOldName() : string{

View File

@ -34,12 +34,11 @@ use pocketmine\player\Player;
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{ class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Item */ public function __construct(
private $drop; Player $player,
private Item $drop
public function __construct(Player $player, Item $drop){ ){
$this->player = $player; $this->player = $player;
$this->drop = $drop;
} }
public function getItem() : Item{ public function getItem() : Item{

View File

@ -35,17 +35,12 @@ use pocketmine\network\mcpe\NetworkSession;
class PlayerDuplicateLoginEvent extends Event implements Cancellable{ class PlayerDuplicateLoginEvent extends Event implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var NetworkSession */ private string $disconnectMessage = "Logged in from another location";
private $connectingSession;
/** @var NetworkSession */
private $existingSession;
/** @var string */
private $disconnectMessage = "Logged in from another location";
public function __construct(NetworkSession $connectingSession, NetworkSession $existingSession){ public function __construct(
$this->connectingSession = $connectingSession; private NetworkSession $connectingSession,
$this->existingSession = $existingSession; private NetworkSession $existingSession
} ){}
public function getConnectingSession() : NetworkSession{ public function getConnectingSession() : NetworkSession{
return $this->connectingSession; return $this->connectingSession;

View File

@ -37,24 +37,17 @@ class PlayerEditBookEvent extends PlayerEvent implements Cancellable{
public const ACTION_SWAP_PAGES = 3; public const ACTION_SWAP_PAGES = 3;
public const ACTION_SIGN_BOOK = 4; public const ACTION_SIGN_BOOK = 4;
/** @var WritableBookBase */
private $oldBook;
/** @var int */
private $action;
/** @var WritableBookBase */
private $newBook;
/** @var int[] */
private $modifiedPages;
/** /**
* @param int[] $modifiedPages * @param int[] $modifiedPages
*/ */
public function __construct(Player $player, WritableBookBase $oldBook, WritableBookBase $newBook, int $action, array $modifiedPages){ public function __construct(
Player $player,
private WritableBookBase $oldBook,
private WritableBookBase $newBook,
private int $action,
private array $modifiedPages
){
$this->player = $player; $this->player = $player;
$this->oldBook = $oldBook;
$this->newBook = $newBook;
$this->action = $action;
$this->modifiedPages = $modifiedPages;
} }
/** /**

View File

@ -46,19 +46,16 @@ class PlayerExhaustEvent extends EntityEvent implements Cancellable{
public const CAUSE_SPRINT_JUMPING = 10; public const CAUSE_SPRINT_JUMPING = 10;
public const CAUSE_CUSTOM = 11; public const CAUSE_CUSTOM = 11;
/** @var float */
private $amount;
/** @var int */
private $cause;
/** @var Human */ /** @var Human */
protected $player; protected $player;
public function __construct(Human $human, float $amount, int $cause){ public function __construct(
Human $human,
private float $amount,
private int $cause
){
$this->entity = $human; $this->entity = $human;
$this->player = $human; $this->player = $human;
$this->amount = $amount;
$this->cause = $cause;
} }
/** /**

View File

@ -37,22 +37,15 @@ class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{
/** @var Human */ /** @var Human */
protected $entity; protected $entity;
/** @var int */
private $oldLevel;
/** @var float */
private $oldProgress;
/** @var int|null */
private $newLevel;
/** @var float|null */
private $newProgress;
public function __construct(Human $player, int $oldLevel, float $oldProgress, ?int $newLevel, ?float $newProgress){ public function __construct(
Human $player,
private int $oldLevel,
private float $oldProgress,
private ?int $newLevel,
private ?float $newProgress
){
$this->entity = $player; $this->entity = $player;
$this->oldLevel = $oldLevel;
$this->oldProgress = $oldProgress;
$this->newLevel = $newLevel;
$this->newProgress = $newProgress;
} }
public function getOldLevel() : int{ public function getOldLevel() : int{

View File

@ -34,12 +34,11 @@ use pocketmine\player\Player;
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{ class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Item */ public function __construct(
private $item; Player $player,
private Item $item
public function __construct(Player $player, Item $item){ ){
$this->player = $player; $this->player = $player;
$this->item = $item;
} }
public function getItem() : Item{ public function getItem() : Item{

View File

@ -31,15 +31,12 @@ use pocketmine\player\Player;
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{ class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Item */ public function __construct(
private $item; Player $player,
/** @var int */ private Item $item,
private $hotbarSlot; private int $hotbarSlot
){
public function __construct(Player $player, Item $item, int $hotbarSlot){
$this->player = $player; $this->player = $player;
$this->item = $item;
$this->hotbarSlot = $hotbarSlot;
} }
/** /**

View File

@ -35,15 +35,12 @@ use pocketmine\player\Player;
class PlayerItemUseEvent extends PlayerEvent implements Cancellable{ class PlayerItemUseEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Item */ public function __construct(
private $item; Player $player,
/** @var Vector3 */ private Item $item,
private $directionVector; private Vector3 $directionVector
){
public function __construct(Player $player, Item $item, Vector3 $directionVector){
$this->player = $player; $this->player = $player;
$this->item = $item;
$this->directionVector = $directionVector;
} }
/** /**

View File

@ -32,15 +32,12 @@ use pocketmine\utils\Utils;
class PlayerMoveEvent extends PlayerEvent implements Cancellable{ class PlayerMoveEvent extends PlayerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var Location */ public function __construct(
private $from; Player $player,
/** @var Location */ private Location $from,
private $to; private Location $to
){
public function __construct(Player $player, Location $from, Location $to){
$this->player = $player; $this->player = $player;
$this->from = $from;
$this->to = $to;
} }
public function getFrom() : Location{ public function getFrom() : Location{

View File

@ -52,22 +52,18 @@ class PlayerPreLoginEvent extends Event implements Cancellable{
self::KICK_REASON_BANNED self::KICK_REASON_BANNED
]; ];
/** @var PlayerInfo */
private $playerInfo;
/** @var string */
private $ip;
/** @var int */
private $port;
/** @var bool */ /** @var bool */
protected $authRequired; protected $authRequired;
/** @var string[] reason const => associated message */ /** @var string[] reason const => associated message */
protected $kickReasons = []; protected $kickReasons = [];
public function __construct(PlayerInfo $playerInfo, string $ip, int $port, bool $authRequired){ public function __construct(
$this->playerInfo = $playerInfo; private PlayerInfo $playerInfo,
$this->ip = $ip; private string $ip,
$this->port = $port; private int $port,
bool $authRequired
){
$this->authRequired = $authRequired; $this->authRequired = $authRequired;
} }

View File

@ -30,12 +30,7 @@ use pocketmine\event\Event;
use pocketmine\plugin\Plugin; use pocketmine\plugin\Plugin;
abstract class PluginEvent extends Event{ abstract class PluginEvent extends Event{
/** @var Plugin */ public function __construct(private Plugin $plugin){}
private $plugin;
public function __construct(Plugin $plugin){
$this->plugin = $plugin;
}
public function getPlugin() : Plugin{ public function getPlugin() : Plugin{
return $this->plugin; return $this->plugin;

View File

@ -31,15 +31,10 @@ use pocketmine\network\mcpe\protocol\ServerboundPacket;
class DataPacketReceiveEvent extends ServerEvent implements Cancellable{ class DataPacketReceiveEvent extends ServerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var ServerboundPacket */ public function __construct(
private $packet; private NetworkSession $origin,
/** @var NetworkSession */ private ServerboundPacket $packet
private $origin; ){}
public function __construct(NetworkSession $origin, ServerboundPacket $packet){
$this->packet = $packet;
$this->origin = $origin;
}
public function getPacket() : ServerboundPacket{ public function getPacket() : ServerboundPacket{
return $this->packet; return $this->packet;

View File

@ -34,19 +34,14 @@ use pocketmine\network\mcpe\protocol\ClientboundPacket;
class DataPacketSendEvent extends ServerEvent implements Cancellable{ class DataPacketSendEvent extends ServerEvent implements Cancellable{
use CancellableTrait; use CancellableTrait;
/** @var NetworkSession[] */
private $targets;
/** @var ClientboundPacket[] */
private $packets;
/** /**
* @param NetworkSession[] $targets * @param NetworkSession[] $targets
* @param ClientboundPacket[] $packets * @param ClientboundPacket[] $packets
*/ */
public function __construct(array $targets, array $packets){ public function __construct(
$this->targets = $targets; private array $targets,
$this->packets = $packets; private array $packets
} ){}
/** /**
* @return NetworkSession[] * @return NetworkSession[]

View File

@ -30,21 +30,12 @@ use pocketmine\utils\Process;
* Plugins should free caches or other non-essential data. * Plugins should free caches or other non-essential data.
*/ */
class LowMemoryEvent extends ServerEvent{ class LowMemoryEvent extends ServerEvent{
/** @var int */ public function __construct(
private $memory; private int $memory,
/** @var int */ private int $memoryLimit,
private $memoryLimit; private bool $isGlobal = false,
/** @var int */ private int $triggerCount = 0
private $triggerCount; ){}
/** @var bool */
private $global;
public function __construct(int $memory, int $memoryLimit, bool $isGlobal = false, int $triggerCount = 0){
$this->memory = $memory;
$this->memoryLimit = $memoryLimit;
$this->global = $isGlobal;
$this->triggerCount = $triggerCount;
}
/** /**
* Returns the memory usage at the time of the event call (in bytes) * Returns the memory usage at the time of the event call (in bytes)
@ -68,7 +59,7 @@ class LowMemoryEvent extends ServerEvent{
} }
public function isGlobal() : bool{ public function isGlobal() : bool{
return $this->global; return $this->isGlobal;
} }
/** /**

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