mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
event: modernize property declarations where possible
only private fields are modified; protected ones can't be changed in case someone extended the classes
This commit is contained in:
@ -31,12 +31,11 @@ use pocketmine\player\Player;
|
||||
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $bed;
|
||||
|
||||
public function __construct(Player $player, Block $bed){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Block $bed
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->bed = $bed;
|
||||
}
|
||||
|
||||
public function getBed() : Block{
|
||||
|
@ -27,12 +27,11 @@ use pocketmine\block\Block;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class PlayerBedLeaveEvent extends PlayerEvent{
|
||||
/** @var Block */
|
||||
private $bed;
|
||||
|
||||
public function __construct(Player $player, Block $bed){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Block $bed
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->bed = $bed;
|
||||
}
|
||||
|
||||
public function getBed() : Block{
|
||||
|
@ -35,15 +35,12 @@ use pocketmine\player\Player;
|
||||
class PlayerBlockPickEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $blockClicked;
|
||||
/** @var Item */
|
||||
private $resultItem;
|
||||
|
||||
public function __construct(Player $player, Block $blockClicked, Item $resultItem){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Block $blockClicked,
|
||||
private Item $resultItem
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->blockClicked = $blockClicked;
|
||||
$this->resultItem = $resultItem;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
|
@ -35,21 +35,14 @@ use pocketmine\player\Player;
|
||||
abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Block */
|
||||
private $blockClicked;
|
||||
/** @var int */
|
||||
private $blockFace;
|
||||
/** @var Item */
|
||||
private $bucket;
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
||||
public function __construct(Player $who, Block $blockClicked, int $blockFace, Item $bucket, Item $itemInHand){
|
||||
public function __construct(
|
||||
Player $who,
|
||||
private Block $blockClicked,
|
||||
private int $blockFace,
|
||||
private Item $bucket,
|
||||
private Item $itemInHand
|
||||
){
|
||||
$this->player = $who;
|
||||
$this->blockClicked = $blockClicked;
|
||||
$this->blockFace = $blockFace;
|
||||
$this->item = $itemInHand;
|
||||
$this->bucket = $bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,11 +56,11 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
|
||||
* Returns the item in hand after the event
|
||||
*/
|
||||
public function getItem() : Item{
|
||||
return $this->item;
|
||||
return $this->itemInHand;
|
||||
}
|
||||
|
||||
public function setItem(Item $item) : void{
|
||||
$this->item = $item;
|
||||
$this->itemInHand = $item;
|
||||
}
|
||||
|
||||
public function getBlockClicked() : Block{
|
||||
|
@ -34,15 +34,12 @@ use pocketmine\player\Player;
|
||||
class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Skin */
|
||||
private $oldSkin;
|
||||
/** @var Skin */
|
||||
private $newSkin;
|
||||
|
||||
public function __construct(Player $player, Skin $oldSkin, Skin $newSkin){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Skin $oldSkin,
|
||||
private Skin $newSkin
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->oldSkin = $oldSkin;
|
||||
$this->newSkin = $newSkin;
|
||||
}
|
||||
|
||||
public function getOldSkin() : Skin{
|
||||
|
@ -34,23 +34,12 @@ use function is_a;
|
||||
*/
|
||||
class PlayerCreationEvent extends Event{
|
||||
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
/** @phpstan-var class-string<Player> */
|
||||
private string $baseClass = Player::class;
|
||||
/** @phpstan-var class-string<Player> */
|
||||
private string $playerClass = Player::class;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @phpstan-var class-string<Player>
|
||||
*/
|
||||
private $baseClass = Player::class;
|
||||
/**
|
||||
* @var string
|
||||
* @phpstan-var class-string<Player>
|
||||
*/
|
||||
private $playerClass = Player::class;
|
||||
|
||||
public function __construct(NetworkSession $session){
|
||||
$this->session = $session;
|
||||
}
|
||||
public function __construct(private NetworkSession $session){}
|
||||
|
||||
public function getNetworkSession() : NetworkSession{
|
||||
return $this->session;
|
||||
|
@ -39,13 +39,14 @@ class PlayerDataSaveEvent extends Event implements Cancellable{
|
||||
protected $data;
|
||||
/** @var string */
|
||||
protected $playerName;
|
||||
/** @var Player|null */
|
||||
private $player;
|
||||
|
||||
public function __construct(CompoundTag $nbt, string $playerName, ?Player $player){
|
||||
public function __construct(
|
||||
CompoundTag $nbt,
|
||||
string $playerName,
|
||||
private ?Player $player
|
||||
){
|
||||
$this->data = $nbt;
|
||||
$this->playerName = $playerName;
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,10 +38,8 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
/** @var Player */
|
||||
protected $player;
|
||||
|
||||
/** @var Translatable|string */
|
||||
private $deathMessage;
|
||||
/** @var bool */
|
||||
private $keepInventory = false;
|
||||
private Translatable|string $deathMessage;
|
||||
private bool $keepInventory = false;
|
||||
|
||||
/**
|
||||
* @param Item[] $drops
|
||||
|
@ -27,15 +27,12 @@ use pocketmine\player\Player;
|
||||
|
||||
class PlayerDisplayNameChangeEvent extends PlayerEvent{
|
||||
|
||||
/** @var string */
|
||||
private $oldName;
|
||||
/** @var string */
|
||||
private $newName;
|
||||
|
||||
public function __construct(Player $player, string $oldName, string $newName){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private string $oldName,
|
||||
private string $newName
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->oldName = $oldName;
|
||||
$this->newName = $newName;
|
||||
}
|
||||
|
||||
public function getOldName() : string{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\player\Player;
|
||||
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $drop;
|
||||
|
||||
public function __construct(Player $player, Item $drop){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $drop
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->drop = $drop;
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
|
@ -35,17 +35,12 @@ use pocketmine\network\mcpe\NetworkSession;
|
||||
class PlayerDuplicateLoginEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var NetworkSession */
|
||||
private $connectingSession;
|
||||
/** @var NetworkSession */
|
||||
private $existingSession;
|
||||
/** @var string */
|
||||
private $disconnectMessage = "Logged in from another location";
|
||||
private string $disconnectMessage = "Logged in from another location";
|
||||
|
||||
public function __construct(NetworkSession $connectingSession, NetworkSession $existingSession){
|
||||
$this->connectingSession = $connectingSession;
|
||||
$this->existingSession = $existingSession;
|
||||
}
|
||||
public function __construct(
|
||||
private NetworkSession $connectingSession,
|
||||
private NetworkSession $existingSession
|
||||
){}
|
||||
|
||||
public function getConnectingSession() : NetworkSession{
|
||||
return $this->connectingSession;
|
||||
|
@ -37,24 +37,17 @@ class PlayerEditBookEvent extends PlayerEvent implements Cancellable{
|
||||
public const ACTION_SWAP_PAGES = 3;
|
||||
public const ACTION_SIGN_BOOK = 4;
|
||||
|
||||
/** @var WritableBookBase */
|
||||
private $oldBook;
|
||||
/** @var int */
|
||||
private $action;
|
||||
/** @var WritableBookBase */
|
||||
private $newBook;
|
||||
/** @var int[] */
|
||||
private $modifiedPages;
|
||||
|
||||
/**
|
||||
* @param int[] $modifiedPages
|
||||
*/
|
||||
public function __construct(Player $player, WritableBookBase $oldBook, WritableBookBase $newBook, int $action, array $modifiedPages){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private WritableBookBase $oldBook,
|
||||
private WritableBookBase $newBook,
|
||||
private int $action,
|
||||
private array $modifiedPages
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->oldBook = $oldBook;
|
||||
$this->newBook = $newBook;
|
||||
$this->action = $action;
|
||||
$this->modifiedPages = $modifiedPages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,19 +46,16 @@ class PlayerExhaustEvent extends EntityEvent implements Cancellable{
|
||||
public const CAUSE_SPRINT_JUMPING = 10;
|
||||
public const CAUSE_CUSTOM = 11;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
/** @var int */
|
||||
private $cause;
|
||||
|
||||
/** @var Human */
|
||||
protected $player;
|
||||
|
||||
public function __construct(Human $human, float $amount, int $cause){
|
||||
public function __construct(
|
||||
Human $human,
|
||||
private float $amount,
|
||||
private int $cause
|
||||
){
|
||||
$this->entity = $human;
|
||||
$this->player = $human;
|
||||
$this->amount = $amount;
|
||||
$this->cause = $cause;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,22 +37,15 @@ class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
/** @var Human */
|
||||
protected $entity;
|
||||
/** @var int */
|
||||
private $oldLevel;
|
||||
/** @var float */
|
||||
private $oldProgress;
|
||||
/** @var int|null */
|
||||
private $newLevel;
|
||||
/** @var float|null */
|
||||
private $newProgress;
|
||||
|
||||
public function __construct(Human $player, int $oldLevel, float $oldProgress, ?int $newLevel, ?float $newProgress){
|
||||
public function __construct(
|
||||
Human $player,
|
||||
private int $oldLevel,
|
||||
private float $oldProgress,
|
||||
private ?int $newLevel,
|
||||
private ?float $newProgress
|
||||
){
|
||||
$this->entity = $player;
|
||||
|
||||
$this->oldLevel = $oldLevel;
|
||||
$this->oldProgress = $oldProgress;
|
||||
$this->newLevel = $newLevel;
|
||||
$this->newProgress = $newProgress;
|
||||
}
|
||||
|
||||
public function getOldLevel() : int{
|
||||
|
@ -34,12 +34,11 @@ use pocketmine\player\Player;
|
||||
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
||||
public function __construct(Player $player, Item $item){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $item
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
|
@ -31,15 +31,12 @@ use pocketmine\player\Player;
|
||||
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
/** @var int */
|
||||
private $hotbarSlot;
|
||||
|
||||
public function __construct(Player $player, Item $item, int $hotbarSlot){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $item,
|
||||
private int $hotbarSlot
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
$this->hotbarSlot = $hotbarSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,15 +35,12 @@ use pocketmine\player\Player;
|
||||
class PlayerItemUseEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
/** @var Vector3 */
|
||||
private $directionVector;
|
||||
|
||||
public function __construct(Player $player, Item $item, Vector3 $directionVector){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Item $item,
|
||||
private Vector3 $directionVector
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
$this->directionVector = $directionVector;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,15 +32,12 @@ use pocketmine\utils\Utils;
|
||||
class PlayerMoveEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Location */
|
||||
private $from;
|
||||
/** @var Location */
|
||||
private $to;
|
||||
|
||||
public function __construct(Player $player, Location $from, Location $to){
|
||||
public function __construct(
|
||||
Player $player,
|
||||
private Location $from,
|
||||
private Location $to
|
||||
){
|
||||
$this->player = $player;
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getFrom() : Location{
|
||||
|
@ -52,22 +52,18 @@ class PlayerPreLoginEvent extends Event implements Cancellable{
|
||||
self::KICK_REASON_BANNED
|
||||
];
|
||||
|
||||
/** @var PlayerInfo */
|
||||
private $playerInfo;
|
||||
/** @var string */
|
||||
private $ip;
|
||||
/** @var int */
|
||||
private $port;
|
||||
/** @var bool */
|
||||
protected $authRequired;
|
||||
|
||||
/** @var string[] reason const => associated message */
|
||||
protected $kickReasons = [];
|
||||
|
||||
public function __construct(PlayerInfo $playerInfo, string $ip, int $port, bool $authRequired){
|
||||
$this->playerInfo = $playerInfo;
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
public function __construct(
|
||||
private PlayerInfo $playerInfo,
|
||||
private string $ip,
|
||||
private int $port,
|
||||
bool $authRequired
|
||||
){
|
||||
$this->authRequired = $authRequired;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user