mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
Merge branch 'next-major' into modern-world-support
This commit is contained in:
commit
dab7686656
@ -32,8 +32,7 @@ class Barrel extends Spawnable implements Container, Nameable{
|
||||
use NameableTrait;
|
||||
use ContainerTrait;
|
||||
|
||||
/** @var BarrelInventory */
|
||||
protected $inventory;
|
||||
protected BarrelInventory $inventory;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
|
@ -44,10 +44,8 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
public const TAG_PAIRZ = "pairz";
|
||||
public const TAG_PAIR_LEAD = "pairlead";
|
||||
|
||||
/** @var ChestInventory */
|
||||
protected $inventory;
|
||||
/** @var DoubleChestInventory|null */
|
||||
protected $doubleInventory = null;
|
||||
protected ChestInventory $inventory;
|
||||
protected ?DoubleChestInventory $doubleInventory = null;
|
||||
|
||||
private ?int $pairX = null;
|
||||
private ?int $pairZ = null;
|
||||
|
@ -33,8 +33,7 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
class Comparator extends Tile{
|
||||
private const TAG_OUTPUT_SIGNAL = "OutputSignal"; //int
|
||||
|
||||
/** @var int */
|
||||
protected $signalStrength = 0;
|
||||
protected int $signalStrength = 0;
|
||||
|
||||
public function getSignalStrength() : int{
|
||||
return $this->signalStrength;
|
||||
|
@ -48,8 +48,7 @@ abstract class Furnace extends Spawnable implements Container, Nameable{
|
||||
public const TAG_COOK_TIME = "CookTime";
|
||||
public const TAG_MAX_TIME = "MaxTime";
|
||||
|
||||
/** @var FurnaceInventory */
|
||||
protected $inventory;
|
||||
protected FurnaceInventory $inventory;
|
||||
private int $remainingFuelTime = 0;
|
||||
private int $cookTime = 0;
|
||||
private int $maxFuelTime = 0;
|
||||
|
@ -38,11 +38,9 @@ class ShulkerBox extends Spawnable implements Container, Nameable{
|
||||
|
||||
public const TAG_FACING = "facing";
|
||||
|
||||
/** @var int */
|
||||
protected $facing = Facing::NORTH;
|
||||
protected int $facing = Facing::NORTH;
|
||||
|
||||
/** @var ShulkerBoxInventory */
|
||||
protected $inventory;
|
||||
protected ShulkerBoxInventory $inventory;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
|
@ -50,11 +50,8 @@ class Sign extends Spawnable{
|
||||
return array_slice(array_pad(explode("\n", $blob), 4, ""), 0, 4);
|
||||
}
|
||||
|
||||
/** @var SignText */
|
||||
protected $text;
|
||||
|
||||
/** @var int|null */
|
||||
protected $editorEntityRuntimeId = null;
|
||||
protected SignText $text;
|
||||
protected ?int $editorEntityRuntimeId = null;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->text = new SignText();
|
||||
|
@ -45,12 +45,9 @@ abstract class Tile{
|
||||
public const TAG_Y = "y";
|
||||
public const TAG_Z = "z";
|
||||
|
||||
/** @var Position */
|
||||
protected $position;
|
||||
/** @var bool */
|
||||
public $closed = false;
|
||||
/** @var TimingsHandler */
|
||||
protected $timings;
|
||||
protected Position $position;
|
||||
public bool $closed = false;
|
||||
protected TimingsHandler $timings;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->position = Position::fromObject($pos, $world);
|
||||
|
@ -26,8 +26,7 @@ namespace pocketmine\block\utils;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
trait AnyFacingTrait{
|
||||
/** @var int */
|
||||
protected $facing = Facing::DOWN;
|
||||
protected int $facing = Facing::DOWN;
|
||||
|
||||
public function getFacing() : int{ return $this->facing; }
|
||||
|
||||
|
@ -27,8 +27,7 @@ use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
trait HorizontalFacingTrait{
|
||||
/** @var int */
|
||||
protected $facing = Facing::NORTH;
|
||||
protected int $facing = Facing::NORTH;
|
||||
|
||||
public function getFacing() : int{ return $this->facing; }
|
||||
|
||||
|
@ -32,9 +32,7 @@ use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
trait PillarRotationTrait{
|
||||
|
||||
/** @var int */
|
||||
protected $axis = Axis::Y;
|
||||
protected int $axis = Axis::Y;
|
||||
|
||||
/** @see Axis */
|
||||
public function getAxis() : int{ return $this->axis; }
|
||||
|
@ -53,17 +53,14 @@ abstract class Command{
|
||||
|
||||
private ?CommandMap $commandMap = null;
|
||||
|
||||
/** @var Translatable|string */
|
||||
protected $description = "";
|
||||
protected Translatable|string $description = "";
|
||||
|
||||
/** @var Translatable|string */
|
||||
protected $usageMessage;
|
||||
protected Translatable|string $usageMessage;
|
||||
|
||||
private ?string $permission = null;
|
||||
private ?string $permissionMessage = null;
|
||||
|
||||
/** @var TimingsHandler|null */
|
||||
public $timings = null;
|
||||
public ?TimingsHandler $timings = null;
|
||||
|
||||
/**
|
||||
* @param string[] $aliases
|
||||
|
@ -80,7 +80,7 @@ use function trim;
|
||||
class SimpleCommandMap implements CommandMap{
|
||||
|
||||
/** @var Command[] */
|
||||
protected $knownCommands = [];
|
||||
protected array $knownCommands = [];
|
||||
|
||||
public function __construct(private Server $server){
|
||||
$this->setDefaultCommands();
|
||||
|
@ -37,11 +37,8 @@ use const PHP_INT_MAX;
|
||||
class ConsoleCommandSender implements CommandSender{
|
||||
use PermissibleDelegateTrait;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
* @phpstan-var positive-int|null
|
||||
*/
|
||||
protected $lineHeight = null;
|
||||
/** @phpstan-var positive-int|null */
|
||||
protected ?int $lineHeight = null;
|
||||
|
||||
public function __construct(
|
||||
private Server $server,
|
||||
|
@ -35,27 +35,27 @@ class CraftingManager{
|
||||
use DestructorCallbackTrait;
|
||||
|
||||
/** @var ShapedRecipe[][] */
|
||||
protected $shapedRecipes = [];
|
||||
protected array $shapedRecipes = [];
|
||||
/** @var ShapelessRecipe[][] */
|
||||
protected $shapelessRecipes = [];
|
||||
protected array $shapelessRecipes = [];
|
||||
|
||||
/**
|
||||
* @var FurnaceRecipeManager[]
|
||||
* @phpstan-var array<int, FurnaceRecipeManager>
|
||||
*/
|
||||
protected $furnaceRecipeManagers;
|
||||
protected array $furnaceRecipeManagers;
|
||||
|
||||
/**
|
||||
* @var PotionTypeRecipe[][]
|
||||
* @phpstan-var array<string, array<string, PotionTypeRecipe>>
|
||||
*/
|
||||
protected $potionTypeRecipes = [];
|
||||
protected array $potionTypeRecipes = [];
|
||||
|
||||
/**
|
||||
* @var PotionContainerChangeRecipe[][]
|
||||
* @phpstan-var array<int, array<string, PotionContainerChangeRecipe>>
|
||||
*/
|
||||
protected $potionContainerChangeRecipes = [];
|
||||
protected array $potionContainerChangeRecipes = [];
|
||||
|
||||
/** @phpstan-var ObjectSet<\Closure() : void> */
|
||||
private ObjectSet $recipeRegisteredCallbacks;
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\utils\ObjectSet;
|
||||
|
||||
final class FurnaceRecipeManager{
|
||||
/** @var FurnaceRecipe[] */
|
||||
protected $furnaceRecipes = [];
|
||||
protected array $furnaceRecipes = [];
|
||||
|
||||
/** @phpstan-var ObjectSet<\Closure(FurnaceRecipe) : void> */
|
||||
private ObjectSet $recipeRegisteredCallbacks;
|
||||
|
@ -48,32 +48,19 @@ class Attribute{
|
||||
public const ZOMBIE_SPAWN_REINFORCEMENTS = self::MC_PREFIX . "zombie.spawn_reinforcements";
|
||||
public const LAVA_MOVEMENT = self::MC_PREFIX . "lava_movement";
|
||||
|
||||
/** @var string */
|
||||
protected $id;
|
||||
/** @var float */
|
||||
protected $minValue;
|
||||
/** @var float */
|
||||
protected $maxValue;
|
||||
/** @var float */
|
||||
protected $defaultValue;
|
||||
/** @var float */
|
||||
protected $currentValue;
|
||||
/** @var bool */
|
||||
protected $shouldSend;
|
||||
protected float $currentValue;
|
||||
protected bool $desynchronized = true;
|
||||
|
||||
/** @var bool */
|
||||
protected $desynchronized = true;
|
||||
|
||||
public function __construct(string $id, float $minValue, float $maxValue, float $defaultValue, bool $shouldSend = true){
|
||||
public function __construct(
|
||||
protected string $id,
|
||||
protected float $minValue,
|
||||
protected float $maxValue,
|
||||
protected float $defaultValue,
|
||||
protected bool $shouldSend = true
|
||||
){
|
||||
if($minValue > $maxValue || $defaultValue > $maxValue || $defaultValue < $minValue){
|
||||
throw new \InvalidArgumentException("Invalid ranges: min value: $minValue, max value: $maxValue, $defaultValue: $defaultValue");
|
||||
}
|
||||
$this->id = $id;
|
||||
$this->minValue = $minValue;
|
||||
$this->maxValue = $maxValue;
|
||||
$this->defaultValue = $defaultValue;
|
||||
$this->shouldSend = $shouldSend;
|
||||
|
||||
$this->currentValue = $this->defaultValue;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class PaintingMotive{
|
||||
private static bool $initialized = false;
|
||||
|
||||
/** @var PaintingMotive[] */
|
||||
protected static $motives = [];
|
||||
protected static array $motives = [];
|
||||
|
||||
public static function init() : void{
|
||||
foreach([
|
||||
|
@ -33,8 +33,7 @@ abstract class Event{
|
||||
|
||||
private static int $eventCallDepth = 1;
|
||||
|
||||
/** @var string|null */
|
||||
protected $eventName = null;
|
||||
protected ?string $eventName = null;
|
||||
|
||||
final public function getEventName() : string{
|
||||
return $this->eventName ?? get_class($this);
|
||||
|
@ -35,30 +35,22 @@ use pocketmine\player\Player;
|
||||
class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Player */
|
||||
protected $player;
|
||||
|
||||
/** @var Item */
|
||||
protected $item;
|
||||
|
||||
/** @var bool */
|
||||
protected $instaBreak = false;
|
||||
/** @var Item[] */
|
||||
protected $blockDrops = [];
|
||||
/** @var int */
|
||||
protected $xpDrops;
|
||||
protected array $blockDrops = [];
|
||||
|
||||
/**
|
||||
* @param Item[] $drops
|
||||
*/
|
||||
public function __construct(Player $player, Block $block, Item $item, bool $instaBreak = false, array $drops = [], int $xpDrops = 0){
|
||||
public function __construct(
|
||||
protected Player $player,
|
||||
Block $block,
|
||||
protected Item $item,
|
||||
protected bool $instaBreak = false,
|
||||
array $drops = [],
|
||||
protected int $xpDrops = 0
|
||||
){
|
||||
parent::__construct($block);
|
||||
$this->item = $item;
|
||||
$this->player = $player;
|
||||
|
||||
$this->instaBreak = $instaBreak;
|
||||
$this->setDrops($drops);
|
||||
$this->xpDrops = $xpDrops;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,12 +30,9 @@ use pocketmine\block\Block;
|
||||
use pocketmine\event\Event;
|
||||
|
||||
abstract class BlockEvent extends Event{
|
||||
/** @var Block */
|
||||
protected $block;
|
||||
|
||||
public function __construct(Block $block){
|
||||
$this->block = $block;
|
||||
}
|
||||
public function __construct(
|
||||
protected Block $block
|
||||
){}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return $this->block;
|
||||
|
@ -35,23 +35,14 @@ use pocketmine\player\Player;
|
||||
class BlockPlaceEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Player */
|
||||
protected $player;
|
||||
|
||||
/** @var Item */
|
||||
protected $item;
|
||||
|
||||
/** @var Block */
|
||||
protected $blockReplace;
|
||||
/** @var Block */
|
||||
protected $blockAgainst;
|
||||
|
||||
public function __construct(Player $player, Block $blockPlace, Block $blockReplace, Block $blockAgainst, Item $item){
|
||||
public function __construct(
|
||||
protected Player $player,
|
||||
Block $blockPlace,
|
||||
protected Block $blockReplace,
|
||||
protected Block $blockAgainst,
|
||||
protected Item $item
|
||||
){
|
||||
parent::__construct($blockPlace);
|
||||
$this->blockReplace = $blockReplace;
|
||||
$this->blockAgainst = $blockAgainst;
|
||||
$this->item = $item;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,8 +27,7 @@ use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityCombustByBlockEvent extends EntityCombustEvent{
|
||||
/** @var Block */
|
||||
protected $combuster;
|
||||
protected Block $combuster;
|
||||
|
||||
public function __construct(Block $combuster, Entity $combustee, int $duration){
|
||||
parent::__construct($combustee, $duration);
|
||||
|
@ -26,8 +26,7 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityCombustByEntityEvent extends EntityCombustEvent{
|
||||
/** @var Entity */
|
||||
protected $combuster;
|
||||
protected Entity $combuster;
|
||||
|
||||
public function __construct(Entity $combuster, Entity $combustee, int $duration){
|
||||
parent::__construct($combustee, $duration);
|
||||
|
@ -33,8 +33,7 @@ use pocketmine\event\CancellableTrait;
|
||||
class EntityCombustEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var int */
|
||||
protected $duration;
|
||||
protected int $duration;
|
||||
|
||||
public function __construct(Entity $combustee, int $duration){
|
||||
$this->entity = $combustee;
|
||||
|
@ -33,11 +33,8 @@ use pocketmine\event\Event;
|
||||
* @phpstan-template TEntity of Entity
|
||||
*/
|
||||
abstract class EntityEvent extends Event{
|
||||
/**
|
||||
* @var Entity
|
||||
* @phpstan-var TEntity
|
||||
*/
|
||||
protected $entity;
|
||||
/** @phpstan-var TEntity */
|
||||
protected Entity $entity;
|
||||
|
||||
/**
|
||||
* @return Entity
|
||||
|
@ -41,27 +41,20 @@ use pocketmine\world\Position;
|
||||
class EntityExplodeEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Position */
|
||||
protected $position;
|
||||
|
||||
/** @var Block[] */
|
||||
protected $blocks;
|
||||
|
||||
/** @var float */
|
||||
protected $yield;
|
||||
|
||||
/**
|
||||
* @param Block[] $blocks
|
||||
* @param float $yield 0-100
|
||||
*/
|
||||
public function __construct(Entity $entity, Position $position, array $blocks, float $yield){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
protected Position $position,
|
||||
protected array $blocks,
|
||||
protected float $yield
|
||||
){
|
||||
$this->entity = $entity;
|
||||
$this->position = $position;
|
||||
$this->blocks = $blocks;
|
||||
if($yield < 0.0 || $yield > 100.0){
|
||||
throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");
|
||||
}
|
||||
$this->yield = $yield;
|
||||
}
|
||||
|
||||
public function getPosition() : Position{
|
||||
|
@ -38,16 +38,16 @@ use pocketmine\event\CancellableTrait;
|
||||
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var float */
|
||||
protected $force;
|
||||
private bool $blockBreaking = true;
|
||||
|
||||
public function __construct(Entity $entity, float $force){
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
protected float $force
|
||||
){
|
||||
if($force <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be positive");
|
||||
}
|
||||
$this->entity = $entity;
|
||||
$this->force = $force;
|
||||
}
|
||||
|
||||
public function getForce() : float{
|
||||
|
@ -31,12 +31,9 @@ use pocketmine\inventory\Inventory;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
abstract class InventoryEvent extends Event{
|
||||
/** @var Inventory */
|
||||
protected $inventory;
|
||||
|
||||
public function __construct(Inventory $inventory){
|
||||
$this->inventory = $inventory;
|
||||
}
|
||||
public function __construct(
|
||||
protected Inventory $inventory
|
||||
){}
|
||||
|
||||
public function getInventory() : Inventory{
|
||||
return $this->inventory;
|
||||
|
@ -35,25 +35,16 @@ use pocketmine\utils\Utils;
|
||||
class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
||||
/** @var string */
|
||||
protected $format;
|
||||
|
||||
/** @var CommandSender[] */
|
||||
protected $recipients = [];
|
||||
|
||||
/**
|
||||
* @param CommandSender[] $recipients
|
||||
*/
|
||||
public function __construct(Player $player, string $message, array $recipients, string $format = "chat.type.text"){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected string $message,
|
||||
protected array $recipients,
|
||||
protected string $format = "chat.type.text"
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->message = $message;
|
||||
|
||||
$this->format = $format;
|
||||
|
||||
$this->recipients = $recipients;
|
||||
}
|
||||
|
||||
public function getMessage() : string{
|
||||
|
@ -41,12 +41,11 @@ use pocketmine\player\Player;
|
||||
class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
||||
public function __construct(Player $player, string $message){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected string $message
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function getMessage() : string{
|
||||
|
@ -35,19 +35,11 @@ use pocketmine\player\Player;
|
||||
class PlayerDataSaveEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var CompoundTag */
|
||||
protected $data;
|
||||
/** @var string */
|
||||
protected $playerName;
|
||||
|
||||
public function __construct(
|
||||
CompoundTag $nbt,
|
||||
string $playerName,
|
||||
protected CompoundTag $data,
|
||||
protected string $playerName,
|
||||
private ?Player $player
|
||||
){
|
||||
$this->data = $nbt;
|
||||
$this->playerName = $playerName;
|
||||
}
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the data to be written to disk as a CompoundTag
|
||||
|
@ -35,8 +35,7 @@ use pocketmine\lang\Translatable;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class PlayerDeathEvent extends EntityDeathEvent{
|
||||
/** @var Player */
|
||||
protected $player;
|
||||
protected Player $player;
|
||||
|
||||
private Translatable|string $deathMessage;
|
||||
private bool $keepInventory = false;
|
||||
|
@ -30,8 +30,7 @@ use pocketmine\event\Event;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
abstract class PlayerEvent extends Event{
|
||||
/** @var Player */
|
||||
protected $player;
|
||||
protected Player $player;
|
||||
|
||||
public function getPlayer() : Player{
|
||||
return $this->player;
|
||||
|
@ -46,23 +46,19 @@ class PlayerExhaustEvent extends EntityEvent implements Cancellable{
|
||||
public const CAUSE_SPRINT_JUMPING = 10;
|
||||
public const CAUSE_CUSTOM = 11;
|
||||
|
||||
/** @var Human */
|
||||
protected $player;
|
||||
|
||||
public function __construct(
|
||||
Human $human,
|
||||
protected Human $human,
|
||||
private float $amount,
|
||||
private int $cause
|
||||
){
|
||||
$this->entity = $human;
|
||||
$this->player = $human;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Human
|
||||
*/
|
||||
public function getPlayer(){
|
||||
return $this->player;
|
||||
return $this->human;
|
||||
}
|
||||
|
||||
public function getAmount() : float{
|
||||
|
@ -35,9 +35,6 @@ use pocketmine\event\entity\EntityEvent;
|
||||
class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Human */
|
||||
protected $entity;
|
||||
|
||||
public function __construct(
|
||||
Human $player,
|
||||
private int $oldLevel,
|
||||
|
@ -34,15 +34,14 @@ use pocketmine\player\Player;
|
||||
class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var GameMode */
|
||||
protected $gamemode;
|
||||
|
||||
public function __construct(Player $player, GameMode $newGamemode){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected GameMode $newGamemode
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->gamemode = $newGamemode;
|
||||
}
|
||||
|
||||
public function getNewGamemode() : GameMode{
|
||||
return $this->gamemode;
|
||||
return $this->newGamemode;
|
||||
}
|
||||
}
|
||||
|
@ -40,28 +40,18 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{
|
||||
public const LEFT_CLICK_BLOCK = 0;
|
||||
public const RIGHT_CLICK_BLOCK = 1;
|
||||
|
||||
/** @var Block */
|
||||
protected $blockTouched;
|
||||
protected Vector3 $touchVector;
|
||||
|
||||
/** @var Vector3 */
|
||||
protected $touchVector;
|
||||
|
||||
/** @var int */
|
||||
protected $blockFace;
|
||||
|
||||
/** @var Item */
|
||||
protected $item;
|
||||
|
||||
/** @var int */
|
||||
protected $action;
|
||||
|
||||
public function __construct(Player $player, Item $item, Block $block, ?Vector3 $touchVector, int $face, int $action = PlayerInteractEvent::RIGHT_CLICK_BLOCK){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected Item $item,
|
||||
protected Block $blockTouched,
|
||||
?Vector3 $touchVector,
|
||||
protected int $blockFace,
|
||||
protected int $action = PlayerInteractEvent::RIGHT_CLICK_BLOCK
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
$this->blockTouched = $block;
|
||||
$this->touchVector = $touchVector ?? new Vector3(0, 0, 0);
|
||||
$this->blockFace = $face;
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
public function getAction() : int{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\player\Player;
|
||||
* @see PlayerLoginEvent
|
||||
*/
|
||||
class PlayerJoinEvent extends PlayerEvent{
|
||||
/** @var string|Translatable */
|
||||
protected $joinMessage;
|
||||
|
||||
public function __construct(Player $player, Translatable|string $joinMessage){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected Translatable|string $joinMessage
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->joinMessage = $joinMessage;
|
||||
}
|
||||
|
||||
public function setJoinMessage(Translatable|string $joinMessage) : void{
|
||||
|
@ -34,16 +34,12 @@ use pocketmine\player\Player;
|
||||
class PlayerKickEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Translatable|string */
|
||||
protected $quitMessage;
|
||||
|
||||
/** @var string */
|
||||
protected $reason;
|
||||
|
||||
public function __construct(Player $player, string $reason, Translatable|string $quitMessage){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected string $reason,
|
||||
protected Translatable|string $quitMessage
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->quitMessage = $quitMessage;
|
||||
$this->reason = $reason;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,12 +35,11 @@ use pocketmine\player\Player;
|
||||
class PlayerLoginEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var string */
|
||||
protected $kickMessage;
|
||||
|
||||
public function __construct(Player $player, string $kickMessage){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected string $kickMessage
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->kickMessage = $kickMessage;
|
||||
}
|
||||
|
||||
public function setKickMessage(string $kickMessage) : void{
|
||||
|
@ -52,20 +52,15 @@ class PlayerPreLoginEvent extends Event implements Cancellable{
|
||||
self::KICK_REASON_BANNED
|
||||
];
|
||||
|
||||
/** @var bool */
|
||||
protected $authRequired;
|
||||
|
||||
/** @var string[] reason const => associated message */
|
||||
protected $kickReasons = [];
|
||||
protected array $kickReasons = [];
|
||||
|
||||
public function __construct(
|
||||
private PlayerInfo $playerInfo,
|
||||
private string $ip,
|
||||
private int $port,
|
||||
bool $authRequired
|
||||
){
|
||||
$this->authRequired = $authRequired;
|
||||
}
|
||||
protected bool $authRequired
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns an object containing self-proclaimed information about the connecting player.
|
||||
|
@ -37,16 +37,12 @@ use pocketmine\player\Player;
|
||||
* @see PlayerKickEvent
|
||||
*/
|
||||
class PlayerQuitEvent extends PlayerEvent{
|
||||
|
||||
/** @var Translatable|string */
|
||||
protected $quitMessage;
|
||||
/** @var string */
|
||||
protected $quitReason;
|
||||
|
||||
public function __construct(Player $player, Translatable|string $quitMessage, string $quitReason){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected Translatable|string $quitMessage,
|
||||
protected string $quitReason
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->quitMessage = $quitMessage;
|
||||
$this->quitReason = $quitReason;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,12 +31,11 @@ use pocketmine\world\Position;
|
||||
* Called when a player is respawned
|
||||
*/
|
||||
class PlayerRespawnEvent extends PlayerEvent{
|
||||
/** @var Position */
|
||||
protected $position;
|
||||
|
||||
public function __construct(Player $player, Position $position){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected Position $position
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
public function getRespawnPosition() : Position{
|
||||
|
@ -30,12 +30,11 @@ use pocketmine\player\Player;
|
||||
class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var bool */
|
||||
protected $isFlying;
|
||||
|
||||
public function __construct(Player $player, bool $isFlying){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected bool $isFlying
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->isFlying = $isFlying;
|
||||
}
|
||||
|
||||
public function isFlying() : bool{
|
||||
|
@ -30,12 +30,11 @@ use pocketmine\player\Player;
|
||||
class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var bool */
|
||||
protected $isSneaking;
|
||||
|
||||
public function __construct(Player $player, bool $isSneaking){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected bool $isSneaking
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->isSneaking = $isSneaking;
|
||||
}
|
||||
|
||||
public function isSneaking() : bool{
|
||||
|
@ -30,12 +30,11 @@ use pocketmine\player\Player;
|
||||
class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var bool */
|
||||
protected $isSprinting;
|
||||
|
||||
public function __construct(Player $player, bool $isSprinting){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected bool $isSprinting
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->isSprinting = $isSprinting;
|
||||
}
|
||||
|
||||
public function isSprinting() : bool{
|
||||
|
@ -33,18 +33,13 @@ use pocketmine\player\Player;
|
||||
class PlayerTransferEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var string */
|
||||
protected $address;
|
||||
/** @var int */
|
||||
protected $port = 19132;
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
||||
public function __construct(Player $player, string $address, int $port, string $message){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected string $address,
|
||||
protected int $port,
|
||||
protected string $message
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->address = $address;
|
||||
$this->port = $port;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,16 +44,10 @@ use pocketmine\event\CancellableTrait;
|
||||
class CommandEvent extends ServerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var string */
|
||||
protected $command;
|
||||
|
||||
/** @var CommandSender */
|
||||
protected $sender;
|
||||
|
||||
public function __construct(CommandSender $sender, string $command){
|
||||
$this->sender = $sender;
|
||||
$this->command = $command;
|
||||
}
|
||||
public function __construct(
|
||||
protected CommandSender $sender,
|
||||
protected string $command
|
||||
){}
|
||||
|
||||
public function getSender() : CommandSender{
|
||||
return $this->sender;
|
||||
|
@ -26,12 +26,9 @@ namespace pocketmine\event\server;
|
||||
use pocketmine\network\NetworkInterface;
|
||||
|
||||
class NetworkInterfaceEvent extends ServerEvent{
|
||||
/** @var NetworkInterface */
|
||||
protected $interface;
|
||||
|
||||
public function __construct(NetworkInterface $interface){
|
||||
$this->interface = $interface;
|
||||
}
|
||||
public function __construct(
|
||||
protected NetworkInterface $interface
|
||||
){}
|
||||
|
||||
public function getInterface() : NetworkInterface{
|
||||
return $this->interface;
|
||||
|
@ -32,11 +32,9 @@ class ArmorInventory extends SimpleInventory{
|
||||
public const SLOT_LEGS = 2;
|
||||
public const SLOT_FEET = 3;
|
||||
|
||||
/** @var Living */
|
||||
protected $holder;
|
||||
|
||||
public function __construct(Living $holder){
|
||||
$this->holder = $holder;
|
||||
public function __construct(
|
||||
protected Living $holder
|
||||
){
|
||||
parent::__construct(4);
|
||||
}
|
||||
|
||||
|
@ -37,15 +37,14 @@ use function spl_object_id;
|
||||
* This class provides everything needed to implement an inventory, minus the underlying storage system.
|
||||
*/
|
||||
abstract class BaseInventory implements Inventory{
|
||||
/** @var int */
|
||||
protected $maxStackSize = Inventory::MAX_STACK;
|
||||
protected int $maxStackSize = Inventory::MAX_STACK;
|
||||
/** @var Player[] */
|
||||
protected $viewers = [];
|
||||
protected array $viewers = [];
|
||||
/**
|
||||
* @var InventoryListener[]|ObjectSet
|
||||
* @phpstan-var ObjectSet<InventoryListener>
|
||||
*/
|
||||
protected $listeners;
|
||||
protected ObjectSet $listeners;
|
||||
|
||||
public function __construct(){
|
||||
$this->listeners = new ObjectSet();
|
||||
|
@ -26,18 +26,13 @@ namespace pocketmine\inventory;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class PlayerCursorInventory extends SimpleInventory implements TemporaryInventory{
|
||||
/** @var Player */
|
||||
protected $holder;
|
||||
|
||||
public function __construct(Player $holder){
|
||||
$this->holder = $holder;
|
||||
public function __construct(
|
||||
protected Player $holder
|
||||
){
|
||||
parent::__construct(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getHolder(){
|
||||
public function getHolder() : Player{
|
||||
return $this->holder;
|
||||
}
|
||||
}
|
||||
|
@ -30,17 +30,14 @@ use pocketmine\utils\ObjectSet;
|
||||
|
||||
class PlayerInventory extends SimpleInventory{
|
||||
|
||||
/** @var Human */
|
||||
protected $holder;
|
||||
|
||||
/** @var int */
|
||||
protected $itemInHandIndex = 0;
|
||||
protected Human $holder;
|
||||
protected int $itemInHandIndex = 0;
|
||||
|
||||
/**
|
||||
* @var \Closure[]|ObjectSet
|
||||
* @phpstan-var ObjectSet<\Closure(int $oldIndex) : void>
|
||||
*/
|
||||
protected $heldItemIndexChangeListeners;
|
||||
protected ObjectSet $heldItemIndexChangeListeners;
|
||||
|
||||
public function __construct(Human $player){
|
||||
$this->holder = $player;
|
||||
@ -123,10 +120,7 @@ class PlayerInventory extends SimpleInventory{
|
||||
return 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Human|Player
|
||||
*/
|
||||
public function getHolder(){
|
||||
public function getHolder() : Human{
|
||||
return $this->holder;
|
||||
}
|
||||
}
|
||||
|
@ -48,15 +48,13 @@ use function intdiv;
|
||||
* results, with no remainder. Any leftovers are expected to be emitted back to the crafting grid.
|
||||
*/
|
||||
class CraftingTransaction extends InventoryTransaction{
|
||||
/** @var CraftingRecipe|null */
|
||||
protected $recipe;
|
||||
/** @var int|null */
|
||||
protected $repetitions;
|
||||
protected ?CraftingRecipe $recipe;
|
||||
protected ?int $repetitions;
|
||||
|
||||
/** @var Item[] */
|
||||
protected $inputs = [];
|
||||
protected array $inputs = [];
|
||||
/** @var Item[] */
|
||||
protected $outputs = [];
|
||||
protected array $outputs = [];
|
||||
|
||||
private CraftingManager $craftingManager;
|
||||
|
||||
|
@ -55,22 +55,21 @@ use function spl_object_id;
|
||||
* @see InventoryAction
|
||||
*/
|
||||
class InventoryTransaction{
|
||||
/** @var bool */
|
||||
protected $hasExecuted = false;
|
||||
/** @var Player */
|
||||
protected $source;
|
||||
protected bool $hasExecuted = false;
|
||||
|
||||
/** @var Inventory[] */
|
||||
protected $inventories = [];
|
||||
protected array $inventories = [];
|
||||
|
||||
/** @var InventoryAction[] */
|
||||
protected $actions = [];
|
||||
protected array $actions = [];
|
||||
|
||||
/**
|
||||
* @param InventoryAction[] $actions
|
||||
*/
|
||||
public function __construct(Player $source, array $actions = []){
|
||||
$this->source = $source;
|
||||
public function __construct(
|
||||
protected Player $source,
|
||||
array $actions = []
|
||||
){
|
||||
foreach($actions as $action){
|
||||
$this->addAction($action);
|
||||
}
|
||||
|
@ -32,15 +32,10 @@ use pocketmine\player\Player;
|
||||
* Represents an action involving a change that applies in some way to an inventory or other item-source.
|
||||
*/
|
||||
abstract class InventoryAction{
|
||||
/** @var Item */
|
||||
protected $sourceItem;
|
||||
/** @var Item */
|
||||
protected $targetItem;
|
||||
|
||||
public function __construct(Item $sourceItem, Item $targetItem){
|
||||
$this->sourceItem = $sourceItem;
|
||||
$this->targetItem = $targetItem;
|
||||
}
|
||||
public function __construct(
|
||||
protected Item $sourceItem,
|
||||
protected Item $targetItem
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the item that was present before the action took place.
|
||||
|
@ -33,15 +33,13 @@ use pocketmine\player\Player;
|
||||
* Represents an action causing a change in an inventory slot.
|
||||
*/
|
||||
class SlotChangeAction extends InventoryAction{
|
||||
|
||||
/** @var Inventory */
|
||||
protected $inventory;
|
||||
private int $inventorySlot;
|
||||
|
||||
public function __construct(Inventory $inventory, int $inventorySlot, Item $sourceItem, Item $targetItem){
|
||||
public function __construct(
|
||||
protected Inventory $inventory,
|
||||
private int $inventorySlot,
|
||||
Item $sourceItem,
|
||||
Item $targetItem
|
||||
){
|
||||
parent::__construct($sourceItem, $targetItem);
|
||||
$this->inventory = $inventory;
|
||||
$this->inventorySlot = $inventorySlot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,8 +42,7 @@ class Armor extends Durable{
|
||||
|
||||
private ArmorTypeInfo $armorInfo;
|
||||
|
||||
/** @var Color|null */
|
||||
protected $customColor = null;
|
||||
protected ?Color $customColor = null;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, ArmorTypeInfo $info){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -29,9 +29,7 @@ use function lcg_value;
|
||||
use function min;
|
||||
|
||||
abstract class Durable extends Item{
|
||||
|
||||
/** @var int */
|
||||
protected $damage = 0;
|
||||
protected int $damage = 0;
|
||||
private bool $unbreakable = false;
|
||||
|
||||
public function getMeta() : int{
|
||||
|
@ -65,36 +65,28 @@ class Item implements \JsonSerializable{
|
||||
public const TAG_DISPLAY_NAME = "Name";
|
||||
public const TAG_DISPLAY_LORE = "Lore";
|
||||
|
||||
private ItemIdentifier $identifier;
|
||||
private CompoundTag $nbt;
|
||||
|
||||
/** @var int */
|
||||
protected $count = 1;
|
||||
/** @var string */
|
||||
protected $name;
|
||||
protected int $count = 1;
|
||||
|
||||
//TODO: this stuff should be moved to itemstack properties, not mushed in with type properties
|
||||
|
||||
/** @var string */
|
||||
protected $customName = "";
|
||||
protected string $customName = "";
|
||||
/** @var string[] */
|
||||
protected $lore = [];
|
||||
/**
|
||||
* TODO: this needs to die in a fire
|
||||
* @var CompoundTag|null
|
||||
*/
|
||||
protected $blockEntityTag = null;
|
||||
protected array $lore = [];
|
||||
/** TODO: this needs to die in a fire */
|
||||
protected ?CompoundTag $blockEntityTag = null;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
protected $canPlaceOn = [];
|
||||
protected array $canPlaceOn = [];
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
protected $canDestroy;
|
||||
protected array $canDestroy = [];
|
||||
|
||||
/**
|
||||
* Constructs a new Item type. This constructor should ONLY be used when constructing a new item TYPE to register
|
||||
@ -103,12 +95,10 @@ class Item implements \JsonSerializable{
|
||||
* NOTE: This should NOT BE USED for creating items to set into an inventory. Use {@link ItemFactory#get} for that
|
||||
* purpose.
|
||||
*/
|
||||
public function __construct(ItemIdentifier $identifier, string $name = "Unknown"){
|
||||
$this->identifier = $identifier;
|
||||
$this->name = $name;
|
||||
|
||||
$this->canPlaceOn = [];
|
||||
$this->canDestroy = [];
|
||||
public function __construct(
|
||||
private ItemIdentifier $identifier,
|
||||
protected string $name = "Unknown"
|
||||
){
|
||||
$this->nbt = new CompoundTag();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ use function spl_object_id;
|
||||
*/
|
||||
trait ItemEnchantmentHandlingTrait{
|
||||
/** @var EnchantmentInstance[] */
|
||||
protected $enchantments = [];
|
||||
protected array $enchantments = [];
|
||||
|
||||
public function hasEnchantments() : bool{
|
||||
return count($this->enchantments) > 0;
|
||||
|
@ -24,9 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
abstract class TieredTool extends Tool{
|
||||
|
||||
/** @var ToolTier */
|
||||
protected $tier;
|
||||
protected ToolTier $tier;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, ToolTier $tier){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -29,10 +29,9 @@ use function array_flip;
|
||||
use function floor;
|
||||
|
||||
class ProtectionEnchantment extends Enchantment{
|
||||
/** @var float */
|
||||
protected $typeModifier;
|
||||
protected float $typeModifier;
|
||||
/** @var int[]|null */
|
||||
protected $applicableDamageTypes = null;
|
||||
protected ?array $applicableDamageTypes = null;
|
||||
|
||||
/**
|
||||
* ProtectionEnchantment constructor.
|
||||
|
@ -81,19 +81,17 @@ class Language{
|
||||
throw new LanguageNotFoundException("Language directory $path does not exist or is not a directory");
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
protected $langName;
|
||||
|
||||
protected string $langName;
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
protected $lang = [];
|
||||
protected array $lang = [];
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
protected $fallbackLang = [];
|
||||
protected array $fallbackLang = [];
|
||||
|
||||
/**
|
||||
* @throws LanguageNotFoundException
|
||||
|
@ -24,18 +24,16 @@ declare(strict_types=1);
|
||||
namespace pocketmine\lang;
|
||||
|
||||
final class Translatable{
|
||||
|
||||
/** @var string $text */
|
||||
protected $text;
|
||||
/** @var string[]|Translatable[] $params */
|
||||
protected $params = [];
|
||||
protected array $params = [];
|
||||
|
||||
/**
|
||||
* @param (float|int|string|Translatable)[] $params
|
||||
*/
|
||||
public function __construct(string $text, array $params = []){
|
||||
$this->text = $text;
|
||||
|
||||
public function __construct(
|
||||
protected string $text,
|
||||
array $params = []
|
||||
){
|
||||
foreach($params as $k => $param){
|
||||
if(!($param instanceof Translatable)){
|
||||
$this->params[$k] = (string) $param;
|
||||
|
@ -39,16 +39,10 @@ class ChunkRequestTask extends AsyncTask{
|
||||
private const TLS_KEY_PROMISE = "promise";
|
||||
private const TLS_KEY_ERROR_HOOK = "errorHook";
|
||||
|
||||
/** @var string */
|
||||
protected $chunk;
|
||||
/** @var int */
|
||||
protected $chunkX;
|
||||
/** @var int */
|
||||
protected $chunkZ;
|
||||
|
||||
/** @var Compressor */
|
||||
protected $compressor;
|
||||
|
||||
protected string $chunk;
|
||||
protected int $chunkX;
|
||||
protected int $chunkZ;
|
||||
protected Compressor $compressor;
|
||||
private string $tiles;
|
||||
|
||||
/**
|
||||
|
@ -34,8 +34,7 @@ use function substr;
|
||||
class EncryptionContext{
|
||||
private const CHECKSUM_ALGO = "sha256";
|
||||
|
||||
/** @var bool */
|
||||
public static $ENABLED = true;
|
||||
public static bool $ENABLED = true;
|
||||
|
||||
private string $key;
|
||||
|
||||
|
@ -135,16 +135,12 @@ use const JSON_THROW_ON_ERROR;
|
||||
class InGamePacketHandler extends PacketHandler{
|
||||
private const MAX_FORM_RESPONSE_DEPTH = 2; //modal/simple will be 1, custom forms 2 - they will never contain anything other than string|int|float|bool|null
|
||||
|
||||
/** @var CraftingTransaction|null */
|
||||
protected $craftingTransaction = null;
|
||||
protected ?CraftingTransaction $craftingTransaction = null;
|
||||
|
||||
/** @var float */
|
||||
protected $lastRightClickTime = 0.0;
|
||||
/** @var UseItemTransactionData|null */
|
||||
protected $lastRightClickData = null;
|
||||
protected float $lastRightClickTime = 0.0;
|
||||
protected ?UseItemTransactionData $lastRightClickData = null;
|
||||
|
||||
/** @var bool */
|
||||
public $forceMoveSync = false;
|
||||
public bool $forceMoveSync = false;
|
||||
|
||||
public function __construct(
|
||||
private Player $player,
|
||||
|
@ -40,62 +40,22 @@ use function register_shutdown_function;
|
||||
use const PTHREADS_INHERIT_NONE;
|
||||
|
||||
class RakLibServer extends Thread{
|
||||
private InternetAddress $address;
|
||||
|
||||
/** @var \ThreadedLogger */
|
||||
protected $logger;
|
||||
|
||||
/** @var bool */
|
||||
protected $cleanShutdown = false;
|
||||
/** @var bool */
|
||||
protected $ready = false;
|
||||
|
||||
/** @var \Threaded */
|
||||
protected $mainToThreadBuffer;
|
||||
/** @var \Threaded */
|
||||
protected $threadToMainBuffer;
|
||||
|
||||
/** @var string */
|
||||
protected $mainPath;
|
||||
|
||||
/** @var int */
|
||||
protected $serverId;
|
||||
/** @var int */
|
||||
protected $maxMtuSize;
|
||||
|
||||
private int $protocolVersion;
|
||||
|
||||
/** @var SleeperNotifier */
|
||||
protected $mainThreadNotifier;
|
||||
|
||||
/** @var RakLibThreadCrashInfo|null */
|
||||
public $crashInfo = null;
|
||||
protected bool $cleanShutdown = false;
|
||||
protected bool $ready = false;
|
||||
protected string $mainPath;
|
||||
public ?RakLibThreadCrashInfo $crashInfo = null;
|
||||
|
||||
public function __construct(
|
||||
\ThreadedLogger $logger,
|
||||
\Threaded $mainToThreadBuffer,
|
||||
\Threaded $threadToMainBuffer,
|
||||
InternetAddress $address,
|
||||
int $serverId,
|
||||
int $maxMtuSize,
|
||||
int $protocolVersion,
|
||||
SleeperNotifier $sleeper
|
||||
protected \ThreadedLogger $logger,
|
||||
protected \Threaded $mainToThreadBuffer,
|
||||
protected \Threaded $threadToMainBuffer,
|
||||
protected InternetAddress $address,
|
||||
protected int $serverId,
|
||||
protected int $maxMtuSize,
|
||||
protected int $protocolVersion,
|
||||
protected SleeperNotifier $mainThreadNotifier
|
||||
){
|
||||
$this->address = $address;
|
||||
|
||||
$this->serverId = $serverId;
|
||||
$this->maxMtuSize = $maxMtuSize;
|
||||
|
||||
$this->logger = $logger;
|
||||
|
||||
$this->mainToThreadBuffer = $mainToThreadBuffer;
|
||||
$this->threadToMainBuffer = $threadToMainBuffer;
|
||||
|
||||
$this->mainPath = \pocketmine\PATH;
|
||||
|
||||
$this->protocolVersion = $protocolVersion;
|
||||
|
||||
$this->mainThreadNotifier = $sleeper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,8 +33,7 @@ use function strtolower;
|
||||
use function trim;
|
||||
|
||||
class BanEntry{
|
||||
/** @var string */
|
||||
public static $format = "Y-m-d H:i:s O";
|
||||
public static string $format = "Y-m-d H:i:s O";
|
||||
|
||||
private string $name;
|
||||
private \DateTime $creationDate;
|
||||
|
@ -38,9 +38,9 @@ class PermissionManager{
|
||||
}
|
||||
|
||||
/** @var Permission[] */
|
||||
protected $permissions = [];
|
||||
protected array $permissions = [];
|
||||
/** @var PermissibleInternal[][] */
|
||||
protected $permSubs = [];
|
||||
protected array $permSubs = [];
|
||||
|
||||
public function getPermission(string $name) : ?Permission{
|
||||
return $this->permissions[$name] ?? null;
|
||||
|
@ -46,7 +46,7 @@ final class GameMode{
|
||||
}
|
||||
|
||||
/** @var self[] */
|
||||
protected static $aliasMap = [];
|
||||
protected static array $aliasMap = [];
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
|
@ -28,15 +28,15 @@ final class PluginLoadTriage{
|
||||
* @var PluginLoadTriageEntry[]
|
||||
* @phpstan-var array<string, PluginLoadTriageEntry>
|
||||
*/
|
||||
public $plugins = [];
|
||||
public array $plugins = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, list<string>>
|
||||
*/
|
||||
public $dependencies = [];
|
||||
public array $dependencies = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, list<string>>
|
||||
*/
|
||||
public $softDependencies = [];
|
||||
public array $softDependencies = [];
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ use function strtolower;
|
||||
*/
|
||||
class PluginManager{
|
||||
/** @var Plugin[] */
|
||||
protected $plugins = [];
|
||||
protected array $plugins = [];
|
||||
|
||||
/** @var Plugin[] */
|
||||
protected $enabledPlugins = [];
|
||||
protected array $enabledPlugins = [];
|
||||
|
||||
private bool $loadPluginsGuard = false;
|
||||
|
||||
@ -81,7 +81,7 @@ class PluginManager{
|
||||
* @var PluginLoader[]
|
||||
* @phpstan-var array<class-string<PluginLoader>, PluginLoader>
|
||||
*/
|
||||
protected $fileAssociations = [];
|
||||
protected array $fileAssociations = [];
|
||||
|
||||
public function __construct(
|
||||
private Server $server,
|
||||
|
@ -43,9 +43,6 @@ final class PromiseSharedData{
|
||||
|
||||
public bool $resolved = false;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @phpstan-var TValue|null
|
||||
*/
|
||||
public $result = null;
|
||||
/** @phpstan-var TValue|null */
|
||||
public mixed $result = null;
|
||||
}
|
||||
|
@ -41,15 +41,9 @@ use function preg_match;
|
||||
use function strlen;
|
||||
|
||||
class ZippedResourcePack implements ResourcePack{
|
||||
|
||||
/** @var string */
|
||||
protected $path;
|
||||
|
||||
/** @var Manifest */
|
||||
protected $manifest;
|
||||
|
||||
/** @var string|null */
|
||||
protected $sha256 = null;
|
||||
protected string $path;
|
||||
protected Manifest $manifest;
|
||||
protected ?string $sha256 = null;
|
||||
|
||||
/** @var resource */
|
||||
protected $fileResource;
|
||||
|
@ -42,9 +42,6 @@ use const PTHREADS_INHERIT_INI;
|
||||
class AsyncPool{
|
||||
private const WORKER_START_OPTIONS = PTHREADS_INHERIT_INI;
|
||||
|
||||
/** @var int */
|
||||
protected $size;
|
||||
|
||||
/**
|
||||
* @var \SplQueue[]|AsyncTask[][]
|
||||
* @phpstan-var array<int, \SplQueue<AsyncTask>>
|
||||
@ -69,14 +66,12 @@ class AsyncPool{
|
||||
private array $workerStartHooks = [];
|
||||
|
||||
public function __construct(
|
||||
int $size,
|
||||
protected int $size,
|
||||
private int $workerMemoryLimit,
|
||||
private \ClassLoader $classLoader,
|
||||
private \ThreadedLogger $logger,
|
||||
private SleeperHandler $eventLoop
|
||||
){
|
||||
$this->size = $size;
|
||||
}
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the maximum size of the pool. Note that there may be less active workers than this number.
|
||||
|
@ -59,8 +59,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
/** @var AsyncWorker|null $worker */
|
||||
public $worker = null;
|
||||
|
||||
/** @var \Threaded */
|
||||
public $progressUpdates;
|
||||
public \Threaded $progressUpdates;
|
||||
|
||||
private string|int|bool|null|float $result = null;
|
||||
private bool $serialized = false;
|
||||
|
@ -27,34 +27,24 @@ use pocketmine\timings\Timings;
|
||||
use pocketmine\timings\TimingsHandler;
|
||||
|
||||
class TaskHandler{
|
||||
protected int $nextRun;
|
||||
|
||||
/** @var Task */
|
||||
protected $task;
|
||||
|
||||
/** @var int */
|
||||
protected $delay;
|
||||
|
||||
/** @var int */
|
||||
protected $period;
|
||||
|
||||
/** @var int */
|
||||
protected $nextRun;
|
||||
|
||||
/** @var bool */
|
||||
protected $cancelled = false;
|
||||
protected bool $cancelled = false;
|
||||
|
||||
private TimingsHandler $timings;
|
||||
|
||||
private string $taskName;
|
||||
private string $ownerName;
|
||||
|
||||
public function __construct(Task $task, int $delay = -1, int $period = -1, ?string $ownerName = null){
|
||||
public function __construct(
|
||||
protected Task $task,
|
||||
protected int $delay = -1,
|
||||
protected int $period = -1,
|
||||
?string $ownerName = null
|
||||
){
|
||||
if($task->getHandler() !== null){
|
||||
throw new \InvalidArgumentException("Cannot assign multiple handlers to the same task");
|
||||
}
|
||||
$this->task = $task;
|
||||
$this->delay = $delay;
|
||||
$this->period = $period;
|
||||
$this->taskName = $task->getName();
|
||||
$this->ownerName = $ownerName ?? "Unknown";
|
||||
$this->timings = Timings::getScheduledTaskTimings($this, $period);
|
||||
|
@ -33,20 +33,16 @@ use pocketmine\utils\ReversePriorityQueue;
|
||||
class TaskScheduler{
|
||||
private bool $enabled = true;
|
||||
|
||||
/**
|
||||
* @var ReversePriorityQueue
|
||||
* @phpstan-var ReversePriorityQueue<int, TaskHandler>
|
||||
*/
|
||||
protected $queue;
|
||||
/** @phpstan-var ReversePriorityQueue<int, TaskHandler> */
|
||||
protected ReversePriorityQueue $queue;
|
||||
|
||||
/**
|
||||
* @var ObjectSet|TaskHandler[]
|
||||
* @phpstan-var ObjectSet<TaskHandler>
|
||||
*/
|
||||
protected $tasks;
|
||||
protected ObjectSet $tasks;
|
||||
|
||||
/** @var int */
|
||||
protected $currentTick = 0;
|
||||
protected int $currentTick = 0;
|
||||
|
||||
public function __construct(
|
||||
private ?string $owner = null
|
||||
|
@ -49,10 +49,8 @@ class SendUsageTask extends AsyncTask{
|
||||
public const TYPE_STATUS = 2;
|
||||
public const TYPE_CLOSE = 3;
|
||||
|
||||
/** @var string */
|
||||
public $endpoint;
|
||||
/** @var string */
|
||||
public $data;
|
||||
public string $endpoint;
|
||||
public string $data;
|
||||
|
||||
/**
|
||||
* @param string[] $playerList
|
||||
|
@ -30,11 +30,9 @@ use function error_reporting;
|
||||
trait CommonThreadPartsTrait{
|
||||
/** @var \Threaded|\ClassLoader[]|null */
|
||||
private ?\Threaded $classLoaders = null;
|
||||
/** @var string|null */
|
||||
protected $composerAutoloaderPath;
|
||||
protected ?string $composerAutoloaderPath;
|
||||
|
||||
/** @var bool */
|
||||
protected $isKilled = false;
|
||||
protected bool $isKilled = false;
|
||||
|
||||
/**
|
||||
* @return \ClassLoader[]
|
||||
|
@ -36,96 +36,58 @@ abstract class Timings{
|
||||
|
||||
private static bool $initialized = false;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $fullTick;
|
||||
/** @var TimingsHandler */
|
||||
public static $serverTick;
|
||||
/** @var TimingsHandler */
|
||||
public static $memoryManager;
|
||||
/** @var TimingsHandler */
|
||||
public static $garbageCollector;
|
||||
/** @var TimingsHandler */
|
||||
public static $titleTick;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkSend;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkSendCompress;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkSendEncrypt;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkReceive;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkReceiveDecompress;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkReceiveDecrypt;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerChunkOrder;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerChunkSend;
|
||||
/** @var TimingsHandler */
|
||||
public static $connection;
|
||||
/** @var TimingsHandler */
|
||||
public static $scheduler;
|
||||
/** @var TimingsHandler */
|
||||
public static $serverCommand;
|
||||
/** @var TimingsHandler */
|
||||
public static $worldLoad;
|
||||
/** @var TimingsHandler */
|
||||
public static $worldSave;
|
||||
/** @var TimingsHandler */
|
||||
public static $population;
|
||||
/** @var TimingsHandler */
|
||||
public static $generationCallback;
|
||||
/** @var TimingsHandler */
|
||||
public static $permissibleCalculation;
|
||||
/** @var TimingsHandler */
|
||||
public static $permissibleCalculationDiff;
|
||||
/** @var TimingsHandler */
|
||||
public static $permissibleCalculationCallback;
|
||||
public static TimingsHandler $fullTick;
|
||||
public static TimingsHandler $serverTick;
|
||||
public static TimingsHandler $memoryManager;
|
||||
public static TimingsHandler $garbageCollector;
|
||||
public static TimingsHandler $titleTick;
|
||||
public static TimingsHandler $playerNetworkSend;
|
||||
public static TimingsHandler $playerNetworkSendCompress;
|
||||
public static TimingsHandler $playerNetworkSendEncrypt;
|
||||
public static TimingsHandler $playerNetworkReceive;
|
||||
public static TimingsHandler $playerNetworkReceiveDecompress;
|
||||
public static TimingsHandler $playerNetworkReceiveDecrypt;
|
||||
public static TimingsHandler $playerChunkOrder;
|
||||
public static TimingsHandler $playerChunkSend;
|
||||
public static TimingsHandler $connection;
|
||||
public static TimingsHandler $scheduler;
|
||||
public static TimingsHandler $serverCommand;
|
||||
public static TimingsHandler $worldLoad;
|
||||
public static TimingsHandler $worldSave;
|
||||
public static TimingsHandler $population;
|
||||
public static TimingsHandler $generationCallback;
|
||||
public static TimingsHandler $permissibleCalculation;
|
||||
public static TimingsHandler $permissibleCalculationDiff;
|
||||
public static TimingsHandler $permissibleCalculationCallback;
|
||||
public static TimingsHandler $entityMove;
|
||||
public static TimingsHandler $playerCheckNearEntities;
|
||||
public static TimingsHandler $tickEntity;
|
||||
public static TimingsHandler $tickTileEntity;
|
||||
public static TimingsHandler $entityBaseTick;
|
||||
public static TimingsHandler $livingEntityBaseTick;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $entityMove;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerCheckNearEntities;
|
||||
/** @var TimingsHandler */
|
||||
public static $tickEntity;
|
||||
/** @var TimingsHandler */
|
||||
public static $tickTileEntity;
|
||||
public static TimingsHandler $schedulerSync;
|
||||
public static TimingsHandler $schedulerAsync;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $entityBaseTick;
|
||||
/** @var TimingsHandler */
|
||||
public static $livingEntityBaseTick;
|
||||
public static TimingsHandler $playerCommand;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $schedulerSync;
|
||||
/** @var TimingsHandler */
|
||||
public static $schedulerAsync;
|
||||
public static TimingsHandler $craftingDataCacheRebuild;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $playerCommand;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $craftingDataCacheRebuild;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $syncPlayerDataLoad;
|
||||
/** @var TimingsHandler */
|
||||
public static $syncPlayerDataSave;
|
||||
public static TimingsHandler $syncPlayerDataLoad;
|
||||
public static TimingsHandler $syncPlayerDataSave;
|
||||
|
||||
/** @var TimingsHandler[] */
|
||||
public static $entityTypeTimingMap = [];
|
||||
public static array $entityTypeTimingMap = [];
|
||||
/** @var TimingsHandler[] */
|
||||
public static $tileEntityTypeTimingMap = [];
|
||||
public static array $tileEntityTypeTimingMap = [];
|
||||
/** @var TimingsHandler[] */
|
||||
public static $packetReceiveTimingMap = [];
|
||||
public static array $packetReceiveTimingMap = [];
|
||||
/** @var TimingsHandler[] */
|
||||
public static $packetSendTimingMap = [];
|
||||
public static array $packetSendTimingMap = [];
|
||||
/** @var TimingsHandler[] */
|
||||
public static $pluginTaskTimingMap = [];
|
||||
public static array $pluginTaskTimingMap = [];
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $broadcastPackets;
|
||||
public static TimingsHandler $broadcastPackets;
|
||||
|
||||
public static function init() : void{
|
||||
if(self::$initialized){
|
||||
@ -182,6 +144,7 @@ abstract class Timings{
|
||||
}
|
||||
|
||||
public static function getScheduledTaskTimings(TaskHandler $task, int $period) : TimingsHandler{
|
||||
self::init();
|
||||
$name = "Task: " . $task->getOwnerName() . " Runnable: " . $task->getTaskName();
|
||||
|
||||
if($period > 0){
|
||||
@ -198,6 +161,7 @@ abstract class Timings{
|
||||
}
|
||||
|
||||
public static function getEntityTimings(Entity $entity) : TimingsHandler{
|
||||
self::init();
|
||||
$entityType = (new \ReflectionClass($entity))->getShortName();
|
||||
if(!isset(self::$entityTypeTimingMap[$entityType])){
|
||||
if($entity instanceof Player){
|
||||
@ -211,6 +175,7 @@ abstract class Timings{
|
||||
}
|
||||
|
||||
public static function getTileEntityTimings(Tile $tile) : TimingsHandler{
|
||||
self::init();
|
||||
$tileType = (new \ReflectionClass($tile))->getShortName();
|
||||
if(!isset(self::$tileEntityTypeTimingMap[$tileType])){
|
||||
self::$tileEntityTypeTimingMap[$tileType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickTileEntity - " . $tileType, self::$tickTileEntity);
|
||||
@ -220,6 +185,7 @@ abstract class Timings{
|
||||
}
|
||||
|
||||
public static function getReceiveDataPacketTimings(ServerboundPacket $pk) : TimingsHandler{
|
||||
self::init();
|
||||
$pid = $pk->pid();
|
||||
if(!isset(self::$packetReceiveTimingMap[$pid])){
|
||||
$pkName = (new \ReflectionClass($pk))->getShortName();
|
||||
@ -230,6 +196,7 @@ abstract class Timings{
|
||||
}
|
||||
|
||||
public static function getSendDataPacketTimings(ClientboundPacket $pk) : TimingsHandler{
|
||||
self::init();
|
||||
$pid = $pk->pid();
|
||||
if(!isset(self::$packetSendTimingMap[$pid])){
|
||||
$pkName = (new \ReflectionClass($pk))->getShortName();
|
||||
|
@ -33,13 +33,9 @@ use function ucfirst;
|
||||
|
||||
class UpdateChecker{
|
||||
|
||||
/** @var Server */
|
||||
protected $server;
|
||||
/** @var string */
|
||||
protected $endpoint;
|
||||
/** @var UpdateInfo|null */
|
||||
protected $updateInfo = null;
|
||||
|
||||
protected Server $server;
|
||||
protected string $endpoint;
|
||||
protected ?UpdateInfo $updateInfo = null;
|
||||
private \Logger $logger;
|
||||
|
||||
public function __construct(Server $server, string $endpoint){
|
||||
|
@ -89,7 +89,7 @@ class Config{
|
||||
private bool $changed = false;
|
||||
|
||||
/** @var int[] */
|
||||
public static $formats = [
|
||||
public static array $formats = [
|
||||
"properties" => Config::PROPERTIES,
|
||||
"cnf" => Config::CNF,
|
||||
"conf" => Config::CNF,
|
||||
|
@ -64,10 +64,8 @@ use const SOCK_DGRAM;
|
||||
use const SOL_UDP;
|
||||
|
||||
class Internet{
|
||||
/** @var string|false */
|
||||
public static $ip = false;
|
||||
/** @var bool */
|
||||
public static $online = true;
|
||||
public static string|false $ip = false;
|
||||
public static bool $online = true;
|
||||
|
||||
/**
|
||||
* Gets the External IP using an external service, it is cached
|
||||
|
@ -32,8 +32,7 @@ use const PHP_EOL;
|
||||
use const PTHREADS_INHERIT_NONE;
|
||||
|
||||
class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{
|
||||
/** @var bool */
|
||||
protected $logDebug;
|
||||
protected bool $logDebug;
|
||||
|
||||
private string $format = TextFormat::AQUA . "[%s] " . TextFormat::RESET . "%s[%s/%s]: %s" . TextFormat::RESET;
|
||||
private bool $useFormattingCodes = false;
|
||||
|
@ -40,8 +40,7 @@ class Random{
|
||||
private int $z;
|
||||
private int $w;
|
||||
|
||||
/** @var int */
|
||||
protected $seed;
|
||||
protected int $seed;
|
||||
|
||||
/**
|
||||
* @param int $seed Integer to be used as seed.
|
||||
|
@ -27,18 +27,11 @@ use pocketmine\thread\Thread;
|
||||
use function time;
|
||||
|
||||
class ServerKiller extends Thread{
|
||||
|
||||
/** @var int */
|
||||
public $time;
|
||||
|
||||
private bool $stopped = false;
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
*/
|
||||
public function __construct($time = 15){
|
||||
$this->time = $time;
|
||||
}
|
||||
public function __construct(
|
||||
public int $time = 15
|
||||
){}
|
||||
|
||||
protected function onRun() : void{
|
||||
$start = time();
|
||||
|
@ -48,35 +48,27 @@ use function sqrt;
|
||||
|
||||
class Explosion{
|
||||
private int $rays = 16;
|
||||
/** @var World */
|
||||
public $world;
|
||||
/** @var Position */
|
||||
public $source;
|
||||
/** @var float */
|
||||
public $size;
|
||||
public World $world;
|
||||
|
||||
/** @var Block[] */
|
||||
public $affectedBlocks = [];
|
||||
/** @var float */
|
||||
public $stepLen = 0.3;
|
||||
|
||||
private Entity|Block|null $what;
|
||||
public array $affectedBlocks = [];
|
||||
public float $stepLen = 0.3;
|
||||
|
||||
private SubChunkExplorer $subChunkExplorer;
|
||||
|
||||
public function __construct(Position $center, float $size, Entity|Block|null $what = null){
|
||||
if(!$center->isValid()){
|
||||
public function __construct(
|
||||
public Position $source,
|
||||
public float $size,
|
||||
private Entity|Block|null $what = null
|
||||
){
|
||||
if(!$this->source->isValid()){
|
||||
throw new \InvalidArgumentException("Position does not have a valid world");
|
||||
}
|
||||
$this->source = $center;
|
||||
$this->world = $center->getWorld();
|
||||
$this->world = $this->source->getWorld();
|
||||
|
||||
if($size <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $size");
|
||||
}
|
||||
$this->size = $size;
|
||||
|
||||
$this->what = $what;
|
||||
$this->subChunkExplorer = new SubChunkExplorer($this->world);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ use pocketmine\world\format\Chunk;
|
||||
class SimpleChunkManager implements ChunkManager{
|
||||
|
||||
/** @var Chunk[] */
|
||||
protected $chunks = [];
|
||||
protected array $chunks = [];
|
||||
|
||||
public function __construct(
|
||||
private int $minY,
|
||||
|
@ -170,7 +170,7 @@ class World implements ChunkManager{
|
||||
private array $entitiesByChunk = [];
|
||||
|
||||
/** @var Entity[] */
|
||||
public $updateEntities = [];
|
||||
public array $updateEntities = [];
|
||||
/** @var Block[][] */
|
||||
private array $blockCache = [];
|
||||
|
||||
@ -202,8 +202,7 @@ class World implements ChunkManager{
|
||||
private array $unloadQueue = [];
|
||||
|
||||
private int $time;
|
||||
/** @var bool */
|
||||
public $stopTime = false;
|
||||
public bool $stopTime = false;
|
||||
|
||||
private float $sunAnglePercentage = 0.0;
|
||||
private int $skyLightReduction = 0;
|
||||
@ -261,11 +260,9 @@ class World implements ChunkManager{
|
||||
/** @var bool[] */
|
||||
private array $randomTickBlocks = [];
|
||||
|
||||
/** @var WorldTimings */
|
||||
public $timings;
|
||||
public WorldTimings $timings;
|
||||
|
||||
/** @var float */
|
||||
public $tickRateTime = 0;
|
||||
public float $tickRateTime = 0;
|
||||
|
||||
private bool $doingTick = false;
|
||||
|
||||
|
@ -44,10 +44,8 @@ abstract class Biome{
|
||||
/** @var Block[] */
|
||||
private array $groundCover = [];
|
||||
|
||||
/** @var float */
|
||||
protected $rainfall = 0.5;
|
||||
/** @var float */
|
||||
protected $temperature = 0.5;
|
||||
protected float $rainfall = 0.5;
|
||||
protected float $temperature = 0.5;
|
||||
|
||||
public function clearPopulators() : void{
|
||||
$this->populators = [];
|
||||
|
@ -45,25 +45,21 @@ class Chunk{
|
||||
|
||||
private int $terrainDirtyFlags = 0;
|
||||
|
||||
/** @var bool|null */
|
||||
protected $lightPopulated = false;
|
||||
/** @var bool */
|
||||
protected $terrainPopulated = false;
|
||||
protected ?bool $lightPopulated = false;
|
||||
protected bool $terrainPopulated = false;
|
||||
|
||||
/**
|
||||
* @var \SplFixedArray|SubChunk[]
|
||||
* @phpstan-var \SplFixedArray<SubChunk>
|
||||
*/
|
||||
protected $subChunks;
|
||||
protected \SplFixedArray $subChunks;
|
||||
|
||||
/** @var Tile[] */
|
||||
protected $tiles = [];
|
||||
protected array $tiles = [];
|
||||
|
||||
/** @var HeightArray */
|
||||
protected $heightMap;
|
||||
protected HeightArray $heightMap;
|
||||
|
||||
/** @var BiomeArray */
|
||||
protected $biomeIds;
|
||||
protected BiomeArray $biomeIds;
|
||||
|
||||
/**
|
||||
* @param SubChunk[] $subChunks
|
||||
|
@ -33,17 +33,15 @@ use pocketmine\world\WorldException;
|
||||
use function file_exists;
|
||||
|
||||
abstract class BaseWorldProvider implements WorldProvider{
|
||||
/** @var string */
|
||||
protected $path;
|
||||
/** @var WorldData */
|
||||
protected $worldData;
|
||||
protected WorldData $worldData;
|
||||
|
||||
public function __construct(string $path){
|
||||
public function __construct(
|
||||
protected string $path
|
||||
){
|
||||
if(!file_exists($path)){
|
||||
throw new WorldException("World does not exist");
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
$this->worldData = $this->loadLevelData();
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ final class WorldProviderManager{
|
||||
* @var WorldProviderManagerEntry[]
|
||||
* @phpstan-var array<string, WorldProviderManagerEntry>
|
||||
*/
|
||||
protected $providers = [];
|
||||
protected array $providers = [];
|
||||
|
||||
private WritableWorldProviderManagerEntry $default;
|
||||
|
||||
|
@ -32,20 +32,15 @@ use pocketmine\world\format\io\WorldData;
|
||||
use function file_exists;
|
||||
|
||||
abstract class BaseNbtWorldData implements WorldData{
|
||||
|
||||
/** @var string */
|
||||
protected $dataPath;
|
||||
|
||||
/** @var CompoundTag */
|
||||
protected $compoundTag;
|
||||
protected CompoundTag $compoundTag;
|
||||
|
||||
/**
|
||||
* @throws CorruptedWorldException
|
||||
* @throws UnsupportedWorldFormatException
|
||||
*/
|
||||
public function __construct(string $dataPath){
|
||||
$this->dataPath = $dataPath;
|
||||
|
||||
public function __construct(
|
||||
protected string $dataPath
|
||||
){
|
||||
if(!file_exists($this->dataPath)){
|
||||
throw new CorruptedWorldException("World data not found at $dataPath");
|
||||
}
|
||||
|
@ -83,8 +83,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
|
||||
private const CAVES_CLIFFS_EXPERIMENTAL_SUBCHUNK_KEY_OFFSET = 4;
|
||||
|
||||
/** @var \LevelDB */
|
||||
protected $db;
|
||||
protected \LevelDB $db;
|
||||
|
||||
private static function checkForLevelDBExtension() : void{
|
||||
if(!extension_loaded('leveldb')){
|
||||
|
@ -64,24 +64,20 @@ class RegionLoader{
|
||||
|
||||
public const FIRST_SECTOR = 2; //location table occupies 0 and 1
|
||||
|
||||
/** @var string */
|
||||
protected $filePath;
|
||||
/** @var resource */
|
||||
protected $filePointer;
|
||||
/** @var int */
|
||||
protected $nextSector = self::FIRST_SECTOR;
|
||||
protected int $nextSector = self::FIRST_SECTOR;
|
||||
/** @var RegionLocationTableEntry[]|null[] */
|
||||
protected $locationTable = [];
|
||||
/** @var RegionGarbageMap */
|
||||
protected $garbageTable;
|
||||
/** @var int */
|
||||
public $lastUsed = 0;
|
||||
protected array $locationTable = [];
|
||||
protected RegionGarbageMap $garbageTable;
|
||||
public int $lastUsed;
|
||||
|
||||
/**
|
||||
* @throws CorruptedRegionException
|
||||
*/
|
||||
private function __construct(string $filePath){
|
||||
$this->filePath = $filePath;
|
||||
private function __construct(
|
||||
protected string $filePath
|
||||
){
|
||||
$this->garbageTable = new RegionGarbageMap([]);
|
||||
$this->lastUsed = time();
|
||||
|
||||
|
@ -73,7 +73,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
}
|
||||
|
||||
/** @var RegionLoader[] */
|
||||
protected $regions = [];
|
||||
protected array $regions = [];
|
||||
|
||||
protected function loadLevelData() : WorldData{
|
||||
return new JavaWorldData(Path::join($this->getPath(), "level.dat"));
|
||||
|
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