Modernize property type declarations

This commit is contained in:
Dylan K. Taylor
2022-06-04 18:16:32 +01:00
parent 23695fb900
commit 083a35f970
114 changed files with 431 additions and 863 deletions

View File

@ -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{

View File

@ -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{

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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{

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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{

View File

@ -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{

View File

@ -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;
}
/**

View File

@ -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{

View File

@ -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.

View File

@ -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;
}
/**

View File

@ -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{

View File

@ -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{

View File

@ -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{

View File

@ -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{

View File

@ -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;
}
/**