mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Modernize property type declarations
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user