mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Merge branch 'next-major' into modern-world-support
This commit is contained in:
commit
0326c4964b
@ -1 +1 @@
|
||||
Subproject commit 1fae6b8d4ab89757316e7e70e77cadfd4fd26b3e
|
||||
Subproject commit 7b357f8cf9b2d2ee3a9ad247cdc76c8ad62337f9
|
@ -12,3 +12,10 @@ Released 20th April 2022.
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.18.30.
|
||||
- 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.
|
||||
|
@ -54,9 +54,9 @@
|
||||
"webmozart/path-util": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "1.5.6",
|
||||
"phpstan/phpstan": "1.6.3",
|
||||
"phpstan/phpstan-phpunit": "^1.1.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.0.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.2.0",
|
||||
"phpunit/phpunit": "^9.2"
|
||||
},
|
||||
"autoload": {
|
||||
|
61
composer.lock
generated
61
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "90fd504df83303dbc46c7834a312f3b0",
|
||||
"content-hash": "f28b4d0dae7984a204a5538b7f614ee4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -302,16 +302,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-protocol",
|
||||
"version": "9.0.0+bedrock-1.18.30",
|
||||
"version": "9.0.1+bedrock-1.18.30",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
||||
"reference": "76cf00af0070dbb3f63a3e7fe74039d011a5475e"
|
||||
"reference": "9d3cc87c4d26c002dd42aa9af20c0cd47a72018e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/76cf00af0070dbb3f63a3e7fe74039d011a5475e",
|
||||
"reference": "76cf00af0070dbb3f63a3e7fe74039d011a5475e",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/9d3cc87c4d26c002dd42aa9af20c0cd47a72018e",
|
||||
"reference": "9d3cc87c4d26c002dd42aa9af20c0cd47a72018e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -325,7 +325,7 @@
|
||||
"ramsey/uuid": "^4.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "1.5.4",
|
||||
"phpstan/phpstan": "1.5.7",
|
||||
"phpstan/phpstan-phpunit": "^1.0.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.0.0",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
@ -343,9 +343,9 @@
|
||||
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
|
||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/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",
|
||||
@ -1846,16 +1846,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.5.6",
|
||||
"version": "1.6.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "799dd8c2d2c9c704bb55d2078078cb970cf0f6d1"
|
||||
"reference": "6128620b98292e0b69ea6d799871d77163681c8e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/799dd8c2d2c9c704bb55d2078078cb970cf0f6d1",
|
||||
"reference": "799dd8c2d2c9c704bb55d2078078cb970cf0f6d1",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/6128620b98292e0b69ea6d799871d77163681c8e",
|
||||
"reference": "6128620b98292e0b69ea6d799871d77163681c8e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1881,7 +1881,7 @@
|
||||
"description": "PHPStan - PHP Static Analysis Tool",
|
||||
"support": {
|
||||
"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": [
|
||||
{
|
||||
@ -1901,20 +1901,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-04-15T11:13:37+00:00"
|
||||
"time": "2022-04-28T11:27:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan-phpunit.git",
|
||||
"reference": "09133ce914f1388a8bb8c7f8573aaa3723cff52a"
|
||||
"reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/09133ce914f1388a8bb8c7f8573aaa3723cff52a",
|
||||
"reference": "09133ce914f1388a8bb8c7f8573aaa3723cff52a",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4a3c437c09075736285d1cabb5c75bf27ed0bc84",
|
||||
"reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1951,27 +1951,27 @@
|
||||
"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.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",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan-strict-rules.git",
|
||||
"reference": "e12d55f74a8cca18c6e684c6450767e055ba7717"
|
||||
"reference": "f3ca6464eae640a556c69a02b3b77a2507475d2f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/e12d55f74a8cca18c6e684c6450767e055ba7717",
|
||||
"reference": "e12d55f74a8cca18c6e684c6450767e055ba7717",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/f3ca6464eae640a556c69a02b3b77a2507475d2f",
|
||||
"reference": "f3ca6464eae640a556c69a02b3b77a2507475d2f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"phpstan/phpstan": "^1.2.0"
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpstan/phpstan": "^1.6.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"nikic/php-parser": "^4.13.0",
|
||||
@ -1981,9 +1981,6 @@
|
||||
},
|
||||
"type": "phpstan-extension",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
},
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
"rules.neon"
|
||||
@ -2002,9 +1999,9 @@
|
||||
"description": "Extra strict and opinionated rules for PHPStan",
|
||||
"support": {
|
||||
"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",
|
||||
@ -3481,5 +3478,5 @@
|
||||
"platform-overrides": {
|
||||
"php": "8.0.0"
|
||||
},
|
||||
"plugin-api-version": "2.2.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
@ -33,16 +33,14 @@ use function strtolower;
|
||||
|
||||
final class ServerConfigGroup{
|
||||
|
||||
/** @var Config */
|
||||
private $pocketmineYml;
|
||||
/** @var Config */
|
||||
private $serverProperties;
|
||||
private Config $pocketmineYml;
|
||||
private Config $serverProperties;
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
* @phpstan-var array<string, mixed>
|
||||
*/
|
||||
private $propertyCache = [];
|
||||
private array $propertyCache = [];
|
||||
|
||||
public function __construct(Config $pocketmineYml, Config $serverProperties){
|
||||
$this->pocketmineYml = $pocketmineYml;
|
||||
|
@ -39,8 +39,7 @@ final class VersionInfo{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
/** @var string|null */
|
||||
private static $gitHash = null;
|
||||
private static ?string $gitHash = null;
|
||||
|
||||
public static function GIT_HASH() : string{
|
||||
if(self::$gitHash === null){
|
||||
@ -79,8 +78,7 @@ final class VersionInfo{
|
||||
return self::$buildNumber;
|
||||
}
|
||||
|
||||
/** @var VersionString|null */
|
||||
private static $fullVersion = null;
|
||||
private static ?VersionString $fullVersion = null;
|
||||
|
||||
public static function VERSION() : VersionString{
|
||||
if(self::$fullVersion === null){
|
||||
|
@ -152,7 +152,7 @@ class Block{
|
||||
$oldTile->close();
|
||||
$oldTile = null;
|
||||
}elseif($oldTile instanceof Spawnable){
|
||||
$oldTile->setDirty(); //destroy old network cache
|
||||
$oldTile->clearSpawnCompoundCache(); //destroy old network cache
|
||||
}
|
||||
}
|
||||
if($oldTile === null && $tileType !== null){
|
||||
|
@ -33,10 +33,8 @@ use pocketmine\world\sound\Sound;
|
||||
class DoubleChestInventory extends BaseInventory implements BlockInventory, InventoryHolder{
|
||||
use AnimatedBlockInventoryTrait;
|
||||
|
||||
/** @var ChestInventory */
|
||||
private $left;
|
||||
/** @var ChestInventory */
|
||||
private $right;
|
||||
private ChestInventory $left;
|
||||
private ChestInventory $right;
|
||||
|
||||
public function __construct(ChestInventory $left, ChestInventory $right){
|
||||
$this->left = $left;
|
||||
|
@ -44,14 +44,13 @@ class Banner extends Spawnable{
|
||||
public const TAG_PATTERN_COLOR = "Color";
|
||||
public const TAG_PATTERN_NAME = "Pattern";
|
||||
|
||||
/** @var DyeColor */
|
||||
private $baseColor;
|
||||
private DyeColor $baseColor;
|
||||
|
||||
/**
|
||||
* @var BannerPatternLayer[]
|
||||
* @phpstan-var list<BannerPatternLayer>
|
||||
*/
|
||||
private $patterns = [];
|
||||
private array $patterns = [];
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->baseColor = DyeColor::BLACK();
|
||||
|
@ -29,10 +29,8 @@ final class Beacon extends Spawnable{
|
||||
private const TAG_PRIMARY = "primary"; //TAG_Int
|
||||
private const TAG_SECONDARY = "secondary"; //TAG_Int
|
||||
|
||||
/** @var int */
|
||||
private $primaryEffect = 0;
|
||||
/** @var int */
|
||||
private $secondaryEffect = 0;
|
||||
private int $primaryEffect = 0;
|
||||
private int $secondaryEffect = 0;
|
||||
|
||||
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||
$nbt->setInt(self::TAG_PRIMARY, $this->primaryEffect);
|
||||
|
@ -32,8 +32,8 @@ use pocketmine\world\World;
|
||||
|
||||
class Bed extends Spawnable{
|
||||
public const TAG_COLOR = "color";
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
|
||||
private DyeColor $color;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->color = DyeColor::RED();
|
||||
|
@ -49,10 +49,8 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
/** @var DoubleChestInventory|null */
|
||||
protected $doubleInventory = null;
|
||||
|
||||
/** @var int|null */
|
||||
private $pairX;
|
||||
/** @var int|null */
|
||||
private $pairZ;
|
||||
private ?int $pairX = null;
|
||||
private ?int $pairZ = null;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
@ -188,8 +186,8 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
|
||||
$this->createPair($tile);
|
||||
|
||||
$this->setDirty();
|
||||
$tile->setDirty();
|
||||
$this->clearSpawnCompoundCache();
|
||||
$tile->clearSpawnCompoundCache();
|
||||
$this->checkPairing();
|
||||
|
||||
return true;
|
||||
@ -211,12 +209,12 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
$tile = $this->getPair();
|
||||
$this->pairX = $this->pairZ = null;
|
||||
|
||||
$this->setDirty();
|
||||
$this->clearSpawnCompoundCache();
|
||||
|
||||
if($tile instanceof Chest){
|
||||
$tile->pairX = $tile->pairZ = null;
|
||||
$tile->checkPairing();
|
||||
$tile->setDirty();
|
||||
$tile->clearSpawnCompoundCache();
|
||||
}
|
||||
$this->checkPairing();
|
||||
|
||||
|
@ -38,8 +38,7 @@ class FlowerPot extends Spawnable{
|
||||
private const TAG_ITEM = "item";
|
||||
private const TAG_ITEM_DATA = "mData";
|
||||
|
||||
/** @var Block|null */
|
||||
private $plant = null;
|
||||
private ?Block $plant = null;
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
if(($itemIdTag = $nbt->getTag(self::TAG_ITEM)) instanceof ShortTag && ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){
|
||||
|
@ -50,12 +50,9 @@ abstract class Furnace extends Spawnable implements Container, Nameable{
|
||||
|
||||
/** @var FurnaceInventory */
|
||||
protected $inventory;
|
||||
/** @var int */
|
||||
private $remainingFuelTime = 0;
|
||||
/** @var int */
|
||||
private $cookTime = 0;
|
||||
/** @var int */
|
||||
private $maxFuelTime = 0;
|
||||
private int $remainingFuelTime = 0;
|
||||
private int $cookTime = 0;
|
||||
private int $maxFuelTime = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
|
@ -35,11 +35,8 @@ class Hopper extends Spawnable implements Container, Nameable{
|
||||
|
||||
private const TAG_TRANSFER_COOLDOWN = "TransferCooldown";
|
||||
|
||||
/** @var HopperInventory */
|
||||
private $inventory;
|
||||
|
||||
/** @var int */
|
||||
private $transferCooldown = 0;
|
||||
private HopperInventory $inventory;
|
||||
private int $transferCooldown = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
|
@ -38,12 +38,9 @@ class ItemFrame extends Spawnable{
|
||||
public const TAG_ITEM_DROP_CHANCE = "ItemDropChance";
|
||||
public const TAG_ITEM = "Item";
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
/** @var int */
|
||||
private $itemRotation = 0;
|
||||
/** @var float */
|
||||
private $itemDropChance = 1.0;
|
||||
private Item $item;
|
||||
private int $itemRotation = 0;
|
||||
private float $itemDropChance = 1.0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->item = VanillaItems::AIR();
|
||||
|
@ -30,8 +30,7 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
class Jukebox extends Spawnable{
|
||||
private const TAG_RECORD = "RecordItem"; //Item CompoundTag
|
||||
|
||||
/** @var Record|null */
|
||||
private $record = null;
|
||||
private ?Record $record = null;
|
||||
|
||||
public function getRecord() : ?Record{
|
||||
return $this->record;
|
||||
|
@ -56,43 +56,24 @@ class MonsterSpawner extends Spawnable{
|
||||
public const DEFAULT_SPAWN_RANGE = 4; //blocks
|
||||
public const DEFAULT_REQUIRED_PLAYER_RANGE = 16;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* TODO: replace this with a cached entity or something of that nature
|
||||
*/
|
||||
private $entityTypeId = ":";
|
||||
/**
|
||||
* @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;
|
||||
/** TODO: replace this with a cached entity or something of that nature */
|
||||
private string $entityTypeId = ":";
|
||||
/** TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) */
|
||||
private ?ListTag $spawnPotentials = null;
|
||||
/** TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) */
|
||||
private ?CompoundTag $spawnData = null;
|
||||
|
||||
/** @var float */
|
||||
private $displayEntityWidth = 1;
|
||||
/** @var float */
|
||||
private $displayEntityHeight = 1;
|
||||
/** @var float */
|
||||
private $displayEntityScale = 1;
|
||||
private float $displayEntityWidth = 1.0;
|
||||
private float $displayEntityHeight = 1.0;
|
||||
private float $displayEntityScale = 1.0;
|
||||
|
||||
/** @var int */
|
||||
private $spawnDelay = self::DEFAULT_MIN_SPAWN_DELAY;
|
||||
/** @var int */
|
||||
private $minSpawnDelay = self::DEFAULT_MIN_SPAWN_DELAY;
|
||||
/** @var int */
|
||||
private $maxSpawnDelay = self::DEFAULT_MAX_SPAWN_DELAY;
|
||||
/** @var int */
|
||||
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;
|
||||
private int $spawnDelay = self::DEFAULT_MIN_SPAWN_DELAY;
|
||||
private int $minSpawnDelay = self::DEFAULT_MIN_SPAWN_DELAY;
|
||||
private int $maxSpawnDelay = self::DEFAULT_MAX_SPAWN_DELAY;
|
||||
private int $spawnPerAttempt = 1;
|
||||
private int $maxNearbyEntities = self::DEFAULT_MAX_NEARBY_ENTITIES;
|
||||
private int $spawnRange = self::DEFAULT_SPAWN_RANGE;
|
||||
private int $requiredPlayerRange = self::DEFAULT_REQUIRED_PLAYER_RANGE;
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
if(($legacyIdTag = $nbt->getTag(self::TAG_LEGACY_ENTITY_TYPE_ID)) instanceof IntTag){
|
||||
|
@ -30,8 +30,7 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
* @deprecated
|
||||
*/
|
||||
class Note extends Tile{
|
||||
/** @var int */
|
||||
private $pitch = 0;
|
||||
private int $pitch = 0;
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
if(($pitch = $nbt->getByte("note", $this->pitch)) > BlockNote::MIN_PITCH && $pitch <= BlockNote::MAX_PITCH){
|
||||
|
@ -40,10 +40,8 @@ class Skull extends Spawnable{
|
||||
private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte
|
||||
private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int
|
||||
|
||||
/** @var SkullType */
|
||||
private $skullType;
|
||||
/** @var int */
|
||||
private $skullRotation = 0;
|
||||
private SkullType $skullType;
|
||||
private int $skullRotation = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->skullType = SkullType::SKELETON();
|
||||
|
@ -28,26 +28,25 @@ use pocketmine\network\mcpe\protocol\types\CacheableNbt;
|
||||
use function get_class;
|
||||
|
||||
abstract class Spawnable extends Tile{
|
||||
/**
|
||||
* @var CacheableNbt|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
|
||||
/** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */
|
||||
private ?CacheableNbt $spawnCompoundCache = null;
|
||||
|
||||
/**
|
||||
* Returns whether the tile needs to be respawned to viewers.
|
||||
* @deprecated
|
||||
*/
|
||||
public function isDirty() : bool{
|
||||
return $this->dirty;
|
||||
return $this->spawnCompoundCache === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function setDirty(bool $dirty = true) : void{
|
||||
if($dirty){
|
||||
$this->spawnCompoundCache = null;
|
||||
}
|
||||
$this->dirty = $dirty;
|
||||
$this->clearSpawnCompoundCache();
|
||||
}
|
||||
|
||||
public function clearSpawnCompoundCache() : void{
|
||||
$this->spawnCompoundCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,12 +42,12 @@ final class TileFactory{
|
||||
* @var string[] classes that extend Tile
|
||||
* @phpstan-var array<string, class-string<Tile>>
|
||||
*/
|
||||
private $knownTiles = [];
|
||||
private array $knownTiles = [];
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<class-string<Tile>, string>
|
||||
*/
|
||||
private $saveNames = [];
|
||||
private array $saveNames = [];
|
||||
|
||||
public function __construct(){
|
||||
$this->register(Barrel::class, ["Barrel", "minecraft:barrel"]);
|
||||
|
@ -30,14 +30,10 @@ use pocketmine\block\BaseBanner;
|
||||
* @see BaseBanner
|
||||
*/
|
||||
class BannerPatternLayer{
|
||||
private BannerPatternType $type;
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
|
||||
public function __construct(BannerPatternType $type, DyeColor $color){
|
||||
$this->type = $type;
|
||||
$this->color = $color;
|
||||
}
|
||||
public function __construct(
|
||||
private BannerPatternType $type,
|
||||
private DyeColor $color
|
||||
){}
|
||||
|
||||
public function getType() : BannerPatternType{ return $this->type; }
|
||||
|
||||
|
@ -42,9 +42,6 @@ final class CoralType{
|
||||
__construct as Enum___construct;
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $displayName;
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
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->displayName = $displayName;
|
||||
}
|
||||
|
||||
public function getDisplayName() : string{ return $this->displayName; }
|
||||
|
@ -75,15 +75,12 @@ final class DyeColor{
|
||||
);
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $displayName;
|
||||
/** @var Color */
|
||||
private $rgbValue;
|
||||
|
||||
private function __construct(string $enumName, string $displayName, Color $rgbValue){
|
||||
private function __construct(
|
||||
string $enumName,
|
||||
private string $displayName,
|
||||
private Color $rgbValue
|
||||
){
|
||||
$this->Enum___construct($enumName);
|
||||
$this->displayName = $displayName;
|
||||
$this->rgbValue = $rgbValue;
|
||||
}
|
||||
|
||||
public function getDisplayName() : string{
|
||||
|
@ -70,15 +70,13 @@ final class RecordType{
|
||||
);
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $soundName;
|
||||
/** @var int */
|
||||
private $soundId;
|
||||
|
||||
private function __construct(string $enumName, string $soundName, int $soundId, private Translatable $translatableName){
|
||||
private function __construct(
|
||||
string $enumName,
|
||||
private string $soundName,
|
||||
private int $soundId,
|
||||
private Translatable $translatableName
|
||||
){
|
||||
$this->Enum___construct($enumName);
|
||||
$this->soundName = $soundName;
|
||||
$this->soundId = $soundId;
|
||||
}
|
||||
|
||||
public function getSoundName() : string{
|
||||
|
@ -36,7 +36,7 @@ class SignText{
|
||||
public const LINE_COUNT = 4;
|
||||
|
||||
/** @var string[] */
|
||||
private $lines;
|
||||
private array $lines;
|
||||
|
||||
/**
|
||||
* @param string[]|null $lines index-sensitive; omitting an index will leave it unchanged
|
||||
|
@ -45,7 +45,7 @@ final class SkullType{
|
||||
}
|
||||
|
||||
/** @var SkullType[] */
|
||||
private static $numericIdMap = [];
|
||||
private static array $numericIdMap = [];
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
@ -75,15 +75,12 @@ final class SkullType{
|
||||
return self::$numericIdMap[$magicNumber];
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $displayName;
|
||||
/** @var int */
|
||||
private $magicNumber;
|
||||
|
||||
private function __construct(string $enumName, string $displayName, int $magicNumber){
|
||||
private function __construct(
|
||||
string $enumName,
|
||||
private string $displayName,
|
||||
private int $magicNumber
|
||||
){
|
||||
$this->Enum___construct($enumName);
|
||||
$this->displayName = $displayName;
|
||||
$this->magicNumber = $magicNumber;
|
||||
}
|
||||
|
||||
public function getDisplayName() : string{
|
||||
|
@ -45,7 +45,7 @@ final class TreeType{
|
||||
}
|
||||
|
||||
/** @var TreeType[] */
|
||||
private static $numericIdMap = [];
|
||||
private static array $numericIdMap = [];
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
@ -76,15 +76,12 @@ final class TreeType{
|
||||
return self::$numericIdMap[$magicNumber];
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $displayName;
|
||||
/** @var int */
|
||||
private $magicNumber;
|
||||
|
||||
private function __construct(string $enumName, string $displayName, int $magicNumber){
|
||||
private function __construct(
|
||||
string $enumName,
|
||||
private string $displayName,
|
||||
private int $magicNumber
|
||||
){
|
||||
$this->Enum___construct($enumName);
|
||||
$this->displayName = $displayName;
|
||||
$this->magicNumber = $magicNumber;
|
||||
}
|
||||
|
||||
public function getDisplayName() : string{
|
||||
|
@ -40,23 +40,18 @@ use function str_replace;
|
||||
|
||||
abstract class Command{
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
private string $name;
|
||||
|
||||
/** @var string */
|
||||
private $nextLabel;
|
||||
|
||||
/** @var string */
|
||||
private $label;
|
||||
private string $nextLabel;
|
||||
private string $label;
|
||||
|
||||
/** @var string[] */
|
||||
private $aliases = [];
|
||||
private array $aliases = [];
|
||||
|
||||
/** @var string[] */
|
||||
private $activeAliases = [];
|
||||
private array $activeAliases = [];
|
||||
|
||||
/** @var CommandMap|null */
|
||||
private $commandMap = null;
|
||||
private ?CommandMap $commandMap = null;
|
||||
|
||||
/** @var Translatable|string */
|
||||
protected $description = "";
|
||||
@ -64,11 +59,8 @@ abstract class Command{
|
||||
/** @var Translatable|string */
|
||||
protected $usageMessage;
|
||||
|
||||
/** @var string|null */
|
||||
private $permission = null;
|
||||
|
||||
/** @var string|null */
|
||||
private $permissionMessage = null;
|
||||
private ?string $permission = null;
|
||||
private ?string $permissionMessage = null;
|
||||
|
||||
/** @var TimingsHandler|null */
|
||||
public $timings = null;
|
||||
|
@ -33,7 +33,7 @@ use function substr;
|
||||
|
||||
class FormattedCommandAlias extends Command{
|
||||
/** @var string[] */
|
||||
private $formatStrings = [];
|
||||
private array $formatStrings = [];
|
||||
|
||||
/**
|
||||
* @param string[] $formatStrings
|
||||
|
@ -31,8 +31,7 @@ use pocketmine\plugin\PluginOwnedTrait;
|
||||
final class PluginCommand extends Command implements PluginOwned{
|
||||
use PluginOwnedTrait;
|
||||
|
||||
/** @var CommandExecutor */
|
||||
private $executor;
|
||||
private CommandExecutor $executor;
|
||||
|
||||
public function __construct(string $name, Plugin $owner, CommandExecutor $executor){
|
||||
parent::__construct($name);
|
||||
|
@ -84,11 +84,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
/** @var Command[] */
|
||||
protected $knownCommands = [];
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
public function __construct(Server $server){
|
||||
$this->server = $server;
|
||||
public function __construct(private Server $server){
|
||||
$this->setDefaultCommands();
|
||||
}
|
||||
|
||||
|
@ -33,17 +33,12 @@ abstract class CraftingGrid extends SimpleInventory{
|
||||
public const SIZE_SMALL = 2;
|
||||
public const SIZE_BIG = 3;
|
||||
|
||||
/** @var int */
|
||||
private $gridWidth;
|
||||
private int $gridWidth;
|
||||
|
||||
/** @var int|null */
|
||||
private $startX;
|
||||
/** @var int|null */
|
||||
private $xLen;
|
||||
/** @var int|null */
|
||||
private $startY;
|
||||
/** @var int|null */
|
||||
private $yLen;
|
||||
private ?int $startX = null;
|
||||
private ?int $xLen = null;
|
||||
private ?int $startY = null;
|
||||
private ?int $yLen = null;
|
||||
|
||||
public function __construct(int $gridWidth){
|
||||
$this->gridWidth = $gridWidth;
|
||||
|
@ -57,11 +57,8 @@ class CraftingManager{
|
||||
*/
|
||||
protected $potionContainerChangeRecipes = [];
|
||||
|
||||
/**
|
||||
* @var ObjectSet
|
||||
* @phpstan-var ObjectSet<\Closure() : void>
|
||||
*/
|
||||
private $recipeRegisteredCallbacks;
|
||||
/** @phpstan-var ObjectSet<\Closure() : void> */
|
||||
private ObjectSet $recipeRegisteredCallbacks;
|
||||
|
||||
public function __construct(){
|
||||
$this->recipeRegisteredCallbacks = new ObjectSet();
|
||||
|
@ -27,14 +27,11 @@ use pocketmine\item\Item;
|
||||
|
||||
class FurnaceRecipe{
|
||||
|
||||
/** @var Item */
|
||||
private $output;
|
||||
|
||||
/** @var Item */
|
||||
private $ingredient;
|
||||
|
||||
public function __construct(Item $result, Item $ingredient){
|
||||
$this->output = clone $result;
|
||||
public function __construct(
|
||||
private Item $result,
|
||||
private Item $ingredient
|
||||
){
|
||||
$this->result = clone $result;
|
||||
$this->ingredient = clone $ingredient;
|
||||
}
|
||||
|
||||
@ -43,6 +40,6 @@ class FurnaceRecipe{
|
||||
}
|
||||
|
||||
public function getResult() : Item{
|
||||
return clone $this->output;
|
||||
return clone $this->result;
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,8 @@ final class FurnaceRecipeManager{
|
||||
/** @var FurnaceRecipe[] */
|
||||
protected $furnaceRecipes = [];
|
||||
|
||||
/**
|
||||
* @var ObjectSet
|
||||
* @phpstan-var ObjectSet<\Closure(FurnaceRecipe) : void>
|
||||
*/
|
||||
private $recipeRegisteredCallbacks;
|
||||
/** @phpstan-var ObjectSet<\Closure(FurnaceRecipe) : void> */
|
||||
private ObjectSet $recipeRegisteredCallbacks;
|
||||
|
||||
public function __construct(){
|
||||
$this->recipeRegisteredCallbacks = new ObjectSet();
|
||||
|
@ -34,16 +34,14 @@ use function strpos;
|
||||
|
||||
class ShapedRecipe implements CraftingRecipe{
|
||||
/** @var string[] */
|
||||
private $shape = [];
|
||||
private array $shape = [];
|
||||
/** @var Item[] char => Item map */
|
||||
private $ingredientList = [];
|
||||
private array $ingredientList = [];
|
||||
/** @var Item[] */
|
||||
private $results = [];
|
||||
private array $results = [];
|
||||
|
||||
/** @var int */
|
||||
private $height;
|
||||
/** @var int */
|
||||
private $width;
|
||||
private int $height;
|
||||
private int $width;
|
||||
|
||||
/**
|
||||
* Constructs a ShapedRecipe instance.
|
||||
|
@ -29,9 +29,9 @@ use function count;
|
||||
|
||||
class ShapelessRecipe implements CraftingRecipe{
|
||||
/** @var Item[] */
|
||||
private $ingredients = [];
|
||||
private array $ingredients = [];
|
||||
/** @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.
|
||||
|
@ -29,12 +29,8 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class ArmSwingAnimation implements Animation{
|
||||
|
||||
/** @var Living */
|
||||
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(Living $entity){
|
||||
$this->entity = $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 encode() : array{
|
||||
return [
|
||||
|
@ -29,15 +29,10 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
class ArrowShakeAnimation implements Animation{
|
||||
|
||||
/** @var Arrow */
|
||||
private $arrow;
|
||||
/** @var int */
|
||||
private $durationInTicks;
|
||||
|
||||
public function __construct(Arrow $arrow, int $durationInTicks){
|
||||
$this->arrow = $arrow;
|
||||
$this->durationInTicks = $durationInTicks;
|
||||
}
|
||||
public function __construct(
|
||||
private Arrow $arrow,
|
||||
private int $durationInTicks
|
||||
){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -31,16 +31,10 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class ConsumingItemAnimation implements Animation{
|
||||
|
||||
/** @var Human */
|
||||
private $human;
|
||||
/** @var 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 __construct(
|
||||
private Human $human, //TODO: maybe this can be expanded to more than just player entities?
|
||||
private Item $item
|
||||
){}
|
||||
|
||||
public function encode() : array{
|
||||
[$netId, $netData] = ItemTranslator::getInstance()->toNetworkId($this->item->getId(), $this->item->getMeta());
|
||||
|
@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
|
||||
final class CriticalHitAnimation implements Animation{
|
||||
|
||||
/** @var Living */
|
||||
private $entity;
|
||||
|
||||
public function __construct(Living $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
public function __construct(private Living $entity){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class DeathAnimation implements Animation{
|
||||
|
||||
/** @var Living */
|
||||
private $entity;
|
||||
|
||||
public function __construct(Living $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
public function __construct(private Living $entity){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class HurtAnimation implements Animation{
|
||||
|
||||
/** @var Living */
|
||||
private $entity;
|
||||
|
||||
public function __construct(Living $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
public function __construct(private Living $entity){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class RespawnAnimation implements Animation{
|
||||
|
||||
/** @var Living */
|
||||
private $entity;
|
||||
|
||||
public function __construct(Living $entity){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
public function __construct(private Living $entity){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
final class SquidInkCloudAnimation implements Animation{
|
||||
|
||||
/** @var Squid */
|
||||
private $squid;
|
||||
|
||||
public function __construct(Squid $squid){
|
||||
$this->squid = $squid;
|
||||
}
|
||||
public function __construct(private Squid $squid){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -29,13 +29,8 @@ use pocketmine\network\mcpe\protocol\types\ActorEvent;
|
||||
|
||||
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
|
||||
$this->human = $human;
|
||||
}
|
||||
//TODO: check if this can be expanded to more than just humans
|
||||
public function __construct(private Human $human){}
|
||||
|
||||
public function encode() : array{
|
||||
return [
|
||||
|
@ -33,11 +33,11 @@ use pocketmine\event\CancellableTrait;
|
||||
abstract class BaseBlockChangeEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
private Block $newState;
|
||||
|
||||
public function __construct(Block $block, Block $newState){
|
||||
public function __construct(
|
||||
Block $block,
|
||||
private Block $newState
|
||||
){
|
||||
parent::__construct($block);
|
||||
$this->newState = $newState;
|
||||
}
|
||||
|
||||
public function getNewState() : Block{
|
||||
|
@ -33,12 +33,11 @@ use pocketmine\event\CancellableTrait;
|
||||
class BlockBurnEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $causingBlock;
|
||||
|
||||
public function __construct(Block $block, Block $causingBlock){
|
||||
public function __construct(
|
||||
Block $block,
|
||||
private Block $causingBlock
|
||||
){
|
||||
parent::__construct($block);
|
||||
$this->causingBlock = $causingBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,12 +29,13 @@ use pocketmine\block\Block;
|
||||
* Called when a block spreads to another block, such as grass spreading to nearby dirt blocks.
|
||||
*/
|
||||
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);
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
public function getSource() : Block{
|
||||
|
@ -32,12 +32,11 @@ use pocketmine\utils\Utils;
|
||||
class BlockTeleportEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Vector3 */
|
||||
private $to;
|
||||
|
||||
public function __construct(Block $block, Vector3 $to){
|
||||
public function __construct(
|
||||
Block $block,
|
||||
private Vector3 $to
|
||||
){
|
||||
parent::__construct($block);
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getTo() : Vector3{
|
||||
|
@ -35,20 +35,12 @@ use pocketmine\player\Player;
|
||||
class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var BaseSign */
|
||||
private $sign;
|
||||
|
||||
/** @var Player */
|
||||
private $player;
|
||||
|
||||
/** @var SignText */
|
||||
private $text;
|
||||
|
||||
public function __construct(BaseSign $sign, Player $player, SignText $text){
|
||||
public function __construct(
|
||||
private BaseSign $sign,
|
||||
private Player $player,
|
||||
private SignText $text
|
||||
){
|
||||
parent::__construct($sign);
|
||||
$this->sign = $sign;
|
||||
$this->player = $player;
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
public function getSign() : BaseSign{
|
||||
|
@ -17,13 +17,12 @@ use pocketmine\world\BlockTransaction;
|
||||
class StructureGrowEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
private BlockTransaction $transaction;
|
||||
private ?Player $player;
|
||||
|
||||
public function __construct(Block $block, BlockTransaction $transaction, ?Player $player){
|
||||
public function __construct(
|
||||
Block $block,
|
||||
private BlockTransaction $transaction,
|
||||
private ?Player $player
|
||||
){
|
||||
parent::__construct($block);
|
||||
$this->transaction = $transaction;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function getTransaction() : BlockTransaction{
|
||||
|
@ -35,15 +35,12 @@ use pocketmine\event\CancellableTrait;
|
||||
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $from;
|
||||
/** @var Block */
|
||||
private $to;
|
||||
|
||||
public function __construct(Entity $entity, Block $from, Block $to){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
private Block $from,
|
||||
private Block $to
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
|
@ -30,14 +30,11 @@ use pocketmine\entity\Entity;
|
||||
* Called when an entity takes damage from a block.
|
||||
*/
|
||||
class EntityDamageByBlockEvent extends EntityDamageEvent{
|
||||
/** @var Block */
|
||||
private $damager;
|
||||
|
||||
/**
|
||||
* @param float[] $modifiers
|
||||
*/
|
||||
public function __construct(Block $damager, Entity $entity, int $cause, float $damage, array $modifiers = []){
|
||||
$this->damager = $damager;
|
||||
public function __construct(private Block $damager, Entity $entity, int $cause, float $damage, array $modifiers = []){
|
||||
parent::__construct($entity, $cause, $damage, $modifiers);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
|
||||
/** @var int */
|
||||
private $childEntityEid;
|
||||
private int $childEntityEid;
|
||||
|
||||
/**
|
||||
* @param float[] $modifiers
|
||||
|
@ -31,17 +31,13 @@ use pocketmine\entity\Living;
|
||||
* Called when an entity takes damage from another entity.
|
||||
*/
|
||||
class EntityDamageByEntityEvent extends EntityDamageEvent{
|
||||
/** @var int */
|
||||
private $damagerEntityId;
|
||||
/** @var float */
|
||||
private $knockBack;
|
||||
private int $damagerEntityId;
|
||||
|
||||
/**
|
||||
* @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->knockBack = $knockBack;
|
||||
parent::__construct($entity, $cause, $damage, $modifiers);
|
||||
$this->addAttackerModifiers($damager);
|
||||
}
|
||||
|
@ -64,31 +64,25 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
|
||||
public const CAUSE_CUSTOM = 14;
|
||||
public const CAUSE_STARVATION = 15;
|
||||
|
||||
/** @var int */
|
||||
private $cause;
|
||||
/** @var float */
|
||||
private $baseDamage;
|
||||
/** @var float */
|
||||
private $originalBase;
|
||||
private float $baseDamage;
|
||||
private float $originalBase;
|
||||
|
||||
/** @var float[] */
|
||||
private $modifiers;
|
||||
/** @var float[] */
|
||||
private $originals;
|
||||
|
||||
/** @var int */
|
||||
private $attackCooldown = 10;
|
||||
private array $originals;
|
||||
private int $attackCooldown = 10;
|
||||
|
||||
/**
|
||||
* @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->cause = $cause;
|
||||
$this->baseDamage = $this->originalBase = $damage;
|
||||
|
||||
$this->modifiers = $modifiers;
|
||||
$this->originals = $this->modifiers;
|
||||
$this->originals = $modifiers;
|
||||
}
|
||||
|
||||
public function getCause() : int{
|
||||
|
@ -31,18 +31,16 @@ use pocketmine\utils\Utils;
|
||||
* @phpstan-extends EntityEvent<Living>
|
||||
*/
|
||||
class EntityDeathEvent extends EntityEvent{
|
||||
/** @var Item[] */
|
||||
private $drops = [];
|
||||
/** @var int */
|
||||
private $xp;
|
||||
|
||||
/**
|
||||
* @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->drops = $drops;
|
||||
$this->xp = $xp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,12 +30,8 @@ use pocketmine\entity\Entity;
|
||||
* Called when an effect is added to an Entity.
|
||||
*/
|
||||
class EntityEffectAddEvent extends EntityEffectEvent{
|
||||
/** @var EffectInstance|null */
|
||||
private $oldEffect;
|
||||
|
||||
public function __construct(Entity $entity, EffectInstance $effect, ?EffectInstance $oldEffect = null){
|
||||
public function __construct(Entity $entity, EffectInstance $effect, private ?EffectInstance $oldEffect = null){
|
||||
parent::__construct($entity, $effect);
|
||||
$this->oldEffect = $oldEffect;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\event\CancellableTrait;
|
||||
class EntityEffectEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var EffectInstance */
|
||||
private $effect;
|
||||
|
||||
public function __construct(Entity $entity, EffectInstance $effect){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
private EffectInstance $effect
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->effect = $effect;
|
||||
}
|
||||
|
||||
public function getEffect() : EffectInstance{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\math\Vector3;
|
||||
class EntityMotionEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Vector3 */
|
||||
private $mot;
|
||||
|
||||
public function __construct(Entity $entity, Vector3 $mot){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
private Vector3 $mot
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->mot = $mot;
|
||||
}
|
||||
|
||||
public function getVector() : Vector3{
|
||||
|
@ -39,15 +39,12 @@ class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
|
||||
public const CAUSE_CUSTOM = 3;
|
||||
public const CAUSE_SATURATION = 4;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
/** @var int */
|
||||
private $reason;
|
||||
|
||||
public function __construct(Entity $entity, float $amount, int $regainReason){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
private float $amount,
|
||||
private int $regainReason
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->amount = $amount;
|
||||
$this->reason = $regainReason;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
public function getRegainReason() : int{
|
||||
return $this->reason;
|
||||
return $this->regainReason;
|
||||
}
|
||||
}
|
||||
|
@ -37,18 +37,16 @@ use function count;
|
||||
class EntityShootBowEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $bow;
|
||||
/** @var Entity */
|
||||
private $projectile;
|
||||
/** @var float */
|
||||
private $force;
|
||||
private Entity $projectile;
|
||||
|
||||
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->bow = $bow;
|
||||
$this->projectile = $projectile;
|
||||
$this->force = $force;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,15 +35,12 @@ use pocketmine\world\Position;
|
||||
class EntityTeleportEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Position */
|
||||
private $from;
|
||||
/** @var Position */
|
||||
private $to;
|
||||
|
||||
public function __construct(Entity $entity, Position $from, Position $to){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
private Position $from,
|
||||
private Position $to
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getFrom() : Position{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\event\CancellableTrait;
|
||||
class EntityTrampleFarmlandEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $block;
|
||||
|
||||
public function __construct(Living $entity, Block $block){
|
||||
public function __construct(
|
||||
Living $entity,
|
||||
private Block $block
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->block = $block;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
|
@ -36,13 +36,11 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
/** @var float */
|
||||
protected $force;
|
||||
/** @var bool */
|
||||
private $blockBreaking;
|
||||
private bool $blockBreaking = true;
|
||||
|
||||
public function __construct(Entity $entity, float $force){
|
||||
$this->entity = $entity;
|
||||
$this->force = $force;
|
||||
$this->blockBreaking = true;
|
||||
}
|
||||
|
||||
public function getForce() : float{
|
||||
|
@ -28,12 +28,12 @@ use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
|
||||
class ProjectileHitBlockEvent extends ProjectileHitEvent{
|
||||
/** @var Block */
|
||||
private $blockHit;
|
||||
|
||||
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult, Block $blockHit){
|
||||
public function __construct(
|
||||
Projectile $entity,
|
||||
RayTraceResult $rayTraceResult,
|
||||
private Block $blockHit
|
||||
){
|
||||
parent::__construct($entity, $rayTraceResult);
|
||||
$this->blockHit = $blockHit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,12 +28,12 @@ use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
|
||||
class ProjectileHitEntityEvent extends ProjectileHitEvent{
|
||||
/** @var Entity */
|
||||
private $entityHit;
|
||||
|
||||
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult, Entity $entityHit){
|
||||
public function __construct(
|
||||
Projectile $entity,
|
||||
RayTraceResult $rayTraceResult,
|
||||
private Entity $entityHit
|
||||
){
|
||||
parent::__construct($entity, $rayTraceResult);
|
||||
$this->entityHit = $entityHit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,12 +31,11 @@ use pocketmine\math\RayTraceResult;
|
||||
* @phpstan-extends EntityEvent<Projectile>
|
||||
*/
|
||||
abstract class ProjectileHitEvent extends EntityEvent{
|
||||
/** @var RayTraceResult */
|
||||
private $rayTraceResult;
|
||||
|
||||
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult){
|
||||
public function __construct(
|
||||
Projectile $entity,
|
||||
private RayTraceResult $rayTraceResult
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->rayTraceResult = $rayTraceResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,28 +34,17 @@ use pocketmine\player\Player;
|
||||
class CraftItemEvent extends Event implements Cancellable{
|
||||
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[] $outputs
|
||||
*/
|
||||
public function __construct(CraftingTransaction $transaction, CraftingRecipe $recipe, int $repetitions, array $inputs, array $outputs){
|
||||
$this->transaction = $transaction;
|
||||
$this->recipe = $recipe;
|
||||
$this->repetitions = $repetitions;
|
||||
$this->inputs = $inputs;
|
||||
$this->outputs = $outputs;
|
||||
}
|
||||
public function __construct(
|
||||
private CraftingTransaction $transaction,
|
||||
private CraftingRecipe $recipe,
|
||||
private int $repetitions,
|
||||
private array $inputs,
|
||||
private array $outputs
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the inventory transaction involved in this crafting event.
|
||||
|
@ -35,20 +35,14 @@ use pocketmine\item\Item;
|
||||
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Furnace */
|
||||
private $furnace;
|
||||
/** @var Item */
|
||||
private $fuel;
|
||||
/** @var int */
|
||||
private $burnTime;
|
||||
/** @var bool */
|
||||
private $burning = true;
|
||||
private bool $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());
|
||||
$this->fuel = $fuel;
|
||||
$this->burnTime = $burnTime;
|
||||
$this->furnace = $furnace;
|
||||
}
|
||||
|
||||
public function getFurnace() : Furnace{
|
||||
|
@ -32,19 +32,14 @@ use pocketmine\item\Item;
|
||||
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Furnace */
|
||||
private $furnace;
|
||||
/** @var Item */
|
||||
private $source;
|
||||
/** @var Item */
|
||||
private $result;
|
||||
|
||||
public function __construct(Furnace $furnace, Item $source, Item $result){
|
||||
public function __construct(
|
||||
private Furnace $furnace,
|
||||
private Item $source,
|
||||
private Item $result
|
||||
){
|
||||
parent::__construct($furnace->getBlock());
|
||||
$this->source = clone $source;
|
||||
$this->source->setCount(1);
|
||||
$this->result = $result;
|
||||
$this->furnace = $furnace;
|
||||
}
|
||||
|
||||
public function getFurnace() : Furnace{
|
||||
|
@ -27,11 +27,10 @@ use pocketmine\inventory\Inventory;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class InventoryCloseEvent extends InventoryEvent{
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
||||
public function __construct(Inventory $inventory, Player $who){
|
||||
$this->who = $who;
|
||||
public function __construct(
|
||||
Inventory $inventory,
|
||||
private Player $who
|
||||
){
|
||||
parent::__construct($inventory);
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,10 @@ use pocketmine\player\Player;
|
||||
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
||||
public function __construct(Inventory $inventory, Player $who){
|
||||
$this->who = $who;
|
||||
public function __construct(
|
||||
Inventory $inventory,
|
||||
private Player $who
|
||||
){
|
||||
parent::__construct($inventory);
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,7 @@ use pocketmine\inventory\transaction\InventoryTransaction;
|
||||
class InventoryTransactionEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var InventoryTransaction */
|
||||
private $transaction;
|
||||
|
||||
public function __construct(InventoryTransaction $transaction){
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
public function __construct(private InventoryTransaction $transaction){}
|
||||
|
||||
public function getTransaction() : InventoryTransaction{
|
||||
return $this->transaction;
|
||||
|
@ -31,12 +31,11 @@ use pocketmine\player\Player;
|
||||
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $bed;
|
||||
|
||||
public function __construct(Player $player, Block $bed){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Block $bed
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->bed = $bed;
|
||||
}
|
||||
|
||||
public function getBed() : Block{
|
||||
|
@ -27,12 +27,11 @@ use pocketmine\block\Block;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class PlayerBedLeaveEvent extends PlayerEvent{
|
||||
/** @var Block */
|
||||
private $bed;
|
||||
|
||||
public function __construct(Player $player, Block $bed){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Block $bed
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->bed = $bed;
|
||||
}
|
||||
|
||||
public function getBed() : Block{
|
||||
|
@ -35,15 +35,12 @@ use pocketmine\player\Player;
|
||||
class PlayerBlockPickEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $blockClicked;
|
||||
/** @var Item */
|
||||
private $resultItem;
|
||||
|
||||
public function __construct(Player $player, Block $blockClicked, Item $resultItem){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Block $blockClicked,
|
||||
private Item $resultItem
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->blockClicked = $blockClicked;
|
||||
$this->resultItem = $resultItem;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
|
@ -35,21 +35,14 @@ use pocketmine\player\Player;
|
||||
abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $blockClicked;
|
||||
/** @var int */
|
||||
private $blockFace;
|
||||
/** @var Item */
|
||||
private $bucket;
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
||||
public function __construct(Player $who, Block $blockClicked, int $blockFace, Item $bucket, Item $itemInHand){
|
||||
public function __construct(
|
||||
Player $who,
|
||||
private Block $blockClicked,
|
||||
private int $blockFace,
|
||||
private Item $bucket,
|
||||
private Item $itemInHand
|
||||
){
|
||||
$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
|
||||
*/
|
||||
public function getItem() : Item{
|
||||
return $this->item;
|
||||
return $this->itemInHand;
|
||||
}
|
||||
|
||||
public function setItem(Item $item) : void{
|
||||
$this->item = $item;
|
||||
$this->itemInHand = $item;
|
||||
}
|
||||
|
||||
public function getBlockClicked() : Block{
|
||||
|
@ -34,15 +34,12 @@ use pocketmine\player\Player;
|
||||
class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Skin */
|
||||
private $oldSkin;
|
||||
/** @var Skin */
|
||||
private $newSkin;
|
||||
|
||||
public function __construct(Player $player, Skin $oldSkin, Skin $newSkin){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Skin $oldSkin,
|
||||
private Skin $newSkin
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->oldSkin = $oldSkin;
|
||||
$this->newSkin = $newSkin;
|
||||
}
|
||||
|
||||
public function getOldSkin() : Skin{
|
||||
@ -53,9 +50,6 @@ class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{
|
||||
return $this->newSkin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException if the specified skin is not valid
|
||||
*/
|
||||
public function setNewSkin(Skin $skin) : void{
|
||||
$this->newSkin = $skin;
|
||||
}
|
||||
|
@ -34,23 +34,12 @@ use function is_a;
|
||||
*/
|
||||
class PlayerCreationEvent extends Event{
|
||||
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
/** @phpstan-var class-string<Player> */
|
||||
private string $baseClass = Player::class;
|
||||
/** @phpstan-var class-string<Player> */
|
||||
private string $playerClass = Player::class;
|
||||
|
||||
/**
|
||||
* @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 __construct(private NetworkSession $session){}
|
||||
|
||||
public function getNetworkSession() : NetworkSession{
|
||||
return $this->session;
|
||||
|
@ -39,13 +39,14 @@ class PlayerDataSaveEvent extends Event implements Cancellable{
|
||||
protected $data;
|
||||
/** @var string */
|
||||
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->playerName = $playerName;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,10 +38,8 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
/** @var Player */
|
||||
protected $player;
|
||||
|
||||
/** @var Translatable|string */
|
||||
private $deathMessage;
|
||||
/** @var bool */
|
||||
private $keepInventory = false;
|
||||
private Translatable|string $deathMessage;
|
||||
private bool $keepInventory = false;
|
||||
|
||||
/**
|
||||
* @param Item[] $drops
|
||||
|
@ -27,15 +27,12 @@ use pocketmine\player\Player;
|
||||
|
||||
class PlayerDisplayNameChangeEvent extends PlayerEvent{
|
||||
|
||||
/** @var string */
|
||||
private $oldName;
|
||||
/** @var string */
|
||||
private $newName;
|
||||
|
||||
public function __construct(Player $player, string $oldName, string $newName){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private string $oldName,
|
||||
private string $newName
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->oldName = $oldName;
|
||||
$this->newName = $newName;
|
||||
}
|
||||
|
||||
public function getOldName() : string{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\player\Player;
|
||||
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $drop;
|
||||
|
||||
public function __construct(Player $player, Item $drop){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $drop
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->drop = $drop;
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
|
@ -35,17 +35,12 @@ use pocketmine\network\mcpe\NetworkSession;
|
||||
class PlayerDuplicateLoginEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var NetworkSession */
|
||||
private $connectingSession;
|
||||
/** @var NetworkSession */
|
||||
private $existingSession;
|
||||
/** @var string */
|
||||
private $disconnectMessage = "Logged in from another location";
|
||||
private string $disconnectMessage = "Logged in from another location";
|
||||
|
||||
public function __construct(NetworkSession $connectingSession, NetworkSession $existingSession){
|
||||
$this->connectingSession = $connectingSession;
|
||||
$this->existingSession = $existingSession;
|
||||
}
|
||||
public function __construct(
|
||||
private NetworkSession $connectingSession,
|
||||
private NetworkSession $existingSession
|
||||
){}
|
||||
|
||||
public function getConnectingSession() : NetworkSession{
|
||||
return $this->connectingSession;
|
||||
|
@ -37,24 +37,17 @@ class PlayerEditBookEvent extends PlayerEvent implements Cancellable{
|
||||
public const ACTION_SWAP_PAGES = 3;
|
||||
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
|
||||
*/
|
||||
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->oldBook = $oldBook;
|
||||
$this->newBook = $newBook;
|
||||
$this->action = $action;
|
||||
$this->modifiedPages = $modifiedPages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,19 +46,16 @@ class PlayerExhaustEvent extends EntityEvent implements Cancellable{
|
||||
public const CAUSE_SPRINT_JUMPING = 10;
|
||||
public const CAUSE_CUSTOM = 11;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
/** @var int */
|
||||
private $cause;
|
||||
|
||||
/** @var Human */
|
||||
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->player = $human;
|
||||
$this->amount = $amount;
|
||||
$this->cause = $cause;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,22 +37,15 @@ class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
/** @var Human */
|
||||
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->oldLevel = $oldLevel;
|
||||
$this->oldProgress = $oldProgress;
|
||||
$this->newLevel = $newLevel;
|
||||
$this->newProgress = $newProgress;
|
||||
}
|
||||
|
||||
public function getOldLevel() : int{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\player\Player;
|
||||
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
||||
public function __construct(Player $player, Item $item){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $item
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
|
@ -31,15 +31,12 @@ use pocketmine\player\Player;
|
||||
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
/** @var int */
|
||||
private $hotbarSlot;
|
||||
|
||||
public function __construct(Player $player, Item $item, int $hotbarSlot){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $item,
|
||||
private int $hotbarSlot
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
$this->hotbarSlot = $hotbarSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,15 +35,12 @@ use pocketmine\player\Player;
|
||||
class PlayerItemUseEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
/** @var Vector3 */
|
||||
private $directionVector;
|
||||
|
||||
public function __construct(Player $player, Item $item, Vector3 $directionVector){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $item,
|
||||
private Vector3 $directionVector
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
$this->directionVector = $directionVector;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,15 +32,12 @@ use pocketmine\utils\Utils;
|
||||
class PlayerMoveEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Location */
|
||||
private $from;
|
||||
/** @var Location */
|
||||
private $to;
|
||||
|
||||
public function __construct(Player $player, Location $from, Location $to){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Location $from,
|
||||
private Location $to
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getFrom() : Location{
|
||||
|
@ -52,22 +52,18 @@ class PlayerPreLoginEvent extends Event implements Cancellable{
|
||||
self::KICK_REASON_BANNED
|
||||
];
|
||||
|
||||
/** @var PlayerInfo */
|
||||
private $playerInfo;
|
||||
/** @var string */
|
||||
private $ip;
|
||||
/** @var int */
|
||||
private $port;
|
||||
/** @var bool */
|
||||
protected $authRequired;
|
||||
|
||||
/** @var string[] reason const => associated message */
|
||||
protected $kickReasons = [];
|
||||
|
||||
public function __construct(PlayerInfo $playerInfo, string $ip, int $port, bool $authRequired){
|
||||
$this->playerInfo = $playerInfo;
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
public function __construct(
|
||||
private PlayerInfo $playerInfo,
|
||||
private string $ip,
|
||||
private int $port,
|
||||
bool $authRequired
|
||||
){
|
||||
$this->authRequired = $authRequired;
|
||||
}
|
||||
|
||||
|
@ -30,12 +30,7 @@ use pocketmine\event\Event;
|
||||
use pocketmine\plugin\Plugin;
|
||||
|
||||
abstract class PluginEvent extends Event{
|
||||
/** @var Plugin */
|
||||
private $plugin;
|
||||
|
||||
public function __construct(Plugin $plugin){
|
||||
$this->plugin = $plugin;
|
||||
}
|
||||
public function __construct(private Plugin $plugin){}
|
||||
|
||||
public function getPlugin() : Plugin{
|
||||
return $this->plugin;
|
||||
|
@ -31,15 +31,10 @@ use pocketmine\network\mcpe\protocol\ServerboundPacket;
|
||||
class DataPacketReceiveEvent extends ServerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var ServerboundPacket */
|
||||
private $packet;
|
||||
/** @var NetworkSession */
|
||||
private $origin;
|
||||
|
||||
public function __construct(NetworkSession $origin, ServerboundPacket $packet){
|
||||
$this->packet = $packet;
|
||||
$this->origin = $origin;
|
||||
}
|
||||
public function __construct(
|
||||
private NetworkSession $origin,
|
||||
private ServerboundPacket $packet
|
||||
){}
|
||||
|
||||
public function getPacket() : ServerboundPacket{
|
||||
return $this->packet;
|
||||
|
@ -34,19 +34,14 @@ use pocketmine\network\mcpe\protocol\ClientboundPacket;
|
||||
class DataPacketSendEvent extends ServerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var NetworkSession[] */
|
||||
private $targets;
|
||||
/** @var ClientboundPacket[] */
|
||||
private $packets;
|
||||
|
||||
/**
|
||||
* @param NetworkSession[] $targets
|
||||
* @param ClientboundPacket[] $packets
|
||||
*/
|
||||
public function __construct(array $targets, array $packets){
|
||||
$this->targets = $targets;
|
||||
$this->packets = $packets;
|
||||
}
|
||||
public function __construct(
|
||||
private array $targets,
|
||||
private array $packets
|
||||
){}
|
||||
|
||||
/**
|
||||
* @return NetworkSession[]
|
||||
|
@ -30,21 +30,12 @@ use pocketmine\utils\Process;
|
||||
* Plugins should free caches or other non-essential data.
|
||||
*/
|
||||
class LowMemoryEvent extends ServerEvent{
|
||||
/** @var int */
|
||||
private $memory;
|
||||
/** @var int */
|
||||
private $memoryLimit;
|
||||
/** @var int */
|
||||
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;
|
||||
}
|
||||
public function __construct(
|
||||
private int $memory,
|
||||
private int $memoryLimit,
|
||||
private bool $isGlobal = false,
|
||||
private int $triggerCount = 0
|
||||
){}
|
||||
|
||||
/**
|
||||
* 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{
|
||||
return $this->global;
|
||||
return $this->isGlobal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user