phpdoc armageddon for master, pass 1

This commit is contained in:
Dylan K. Taylor
2020-01-22 11:55:03 +00:00
parent 4bae3baa74
commit 67bcc1c0fb
397 changed files with 0 additions and 5391 deletions

View File

@ -138,8 +138,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* Validates the given username.
*
* @param string $name
*
* @return bool
*/
public static function isValidUserName(?string $name) : bool{
if($name === null){
@ -248,12 +246,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/** @var \Logger */
protected $logger;
/**
* @param Server $server
* @param NetworkSession $session
* @param PlayerInfo $playerInfo
* @param bool $authenticated
*/
public function __construct(Server $server, NetworkSession $session, PlayerInfo $playerInfo, bool $authenticated){
$username = TextFormat::clean($playerInfo->getUsername());
$this->logger = new \PrefixedLogger($server->getLogger(), "Player: $username");
@ -412,8 +404,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* If the player is logged into Xbox Live, returns their Xbox user ID (XUID) as a string. Returns an empty string if
* the player is not logged into Xbox Live.
*
* @return string
*/
public function getXuid() : string{
return $this->xuid;
@ -433,8 +423,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* (In the olden days this method used to return a fake UUID computed by the server, which was used by plugins such
* as SimpleAuth for authentication. This is NOT SAFE anymore as this UUID is now what was given by the client, NOT
* a server-computed UUID.)
*
* @return UUID
*/
public function getUniqueId() : UUID{
return parent::getUniqueId();
@ -446,7 +434,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* TODO: not sure this should be nullable
* @return int|null
*/
public function getFirstPlayed() : ?int{
return $this->firstPlayed;
@ -454,7 +441,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* TODO: not sure this should be nullable
* @return int|null
*/
public function getLastPlayed() : ?int{
return $this->lastPlayed;
@ -494,32 +480,20 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->autoJump;
}
/**
* @param Player $player
*/
public function spawnTo(Player $player) : void{
if($this->isAlive() and $player->isAlive() and $player->getWorld() === $this->getWorld() and $player->canSee($this) and !$this->isSpectator()){
parent::spawnTo($player);
}
}
/**
* @return Server
*/
public function getServer() : Server{
return $this->server;
}
/**
* @return bool
*/
public function getRemoveFormat() : bool{
return $this->removeFormat;
}
/**
* @param bool $remove
*/
public function setRemoveFormat(bool $remove = true) : void{
$this->removeFormat = $remove;
}
@ -535,18 +509,10 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$this->lineHeight = $height;
}
/**
* @param Player $player
*
* @return bool
*/
public function canSee(Player $player) : bool{
return !isset($this->hiddenPlayers[$player->getUniqueId()->toBinary()]);
}
/**
* @param Player $player
*/
public function hidePlayer(Player $player) : void{
if($player === $this){
return;
@ -555,9 +521,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$player->despawnFrom($this);
}
/**
* @param Player $player
*/
public function showPlayer(Player $player) : void{
if($player === $this){
return;
@ -597,23 +560,14 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$this->logger->debug("Setting view distance to " . $this->viewDistance . " (requested " . $distance . ")");
}
/**
* @return bool
*/
public function isOnline() : bool{
return $this->isConnected();
}
/**
* @return bool
*/
public function isOp() : bool{
return $this->server->isOp($this->getName());
}
/**
* @param bool $value
*/
public function setOp(bool $value) : void{
if($value === $this->isOp()){
return;
@ -651,23 +605,16 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
}
/**
* @return bool
*/
public function isConnected() : bool{
return $this->networkSession !== null and $this->networkSession->isConnected();
}
/**
* @return NetworkSession
*/
public function getNetworkSession() : NetworkSession{
return $this->networkSession;
}
/**
* Gets the username
* @return string
*/
public function getName() : string{
return $this->username;
@ -675,23 +622,17 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns the "friendly" display name of this player to use in the chat.
*
* @return string
*/
public function getDisplayName() : string{
return $this->displayName;
}
/**
* @param string $name
*/
public function setDisplayName(string $name) : void{
$this->displayName = $name;
}
/**
* Returns the player's locale, e.g. en_US.
* @return string
*/
public function getLocale() : string{
return $this->locale;
@ -700,12 +641,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Called when a player changes their skin.
* Plugin developers should not use this, use setSkin() and sendSkin() instead.
*
* @param Skin $skin
* @param string $newSkinName
* @param string $oldSkinName
*
* @return bool
*/
public function changeSkin(Skin $skin, string $newSkinName, string $oldSkinName) : bool{
$ev = new PlayerChangeSkinEvent($this, $this->getSkin(), $skin);
@ -732,7 +667,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns whether the player is currently using an item (right-click and hold).
* @return bool
*/
public function isUsingItem() : bool{
return $this->startAction > -1;
@ -745,8 +679,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns how long the player has been using their currently-held item for. Used for determining arrow shoot force
* for bows.
*
* @return int
*/
public function getItemUseDuration() : int{
return $this->startAction === -1 ? -1 : ($this->server->getTick() - $this->startAction);
@ -754,10 +686,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns whether the player has a cooldown period left before it can use the given item again.
*
* @param Item $item
*
* @return bool
*/
public function hasItemCooldown(Item $item) : bool{
$this->checkItemCooldowns();
@ -766,8 +694,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Resets the player's cooldown time for the given item back to the maximum.
*
* @param Item $item
*/
public function resetItemCooldown(Item $item) : void{
$ticks = $item->getCooldownTicks();
@ -1010,9 +936,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
}
/**
* @return bool
*/
public function hasValidSpawnPosition() : bool{
return $this->spawnPosition !== null and $this->spawnPosition->isValid();
}
@ -1033,18 +956,10 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
$this->networkSession->syncPlayerSpawnPoint($this->spawnPosition);
}
/**
* @return bool
*/
public function isSleeping() : bool{
return $this->sleeping !== null;
}
/**
* @param Vector3 $pos
*
* @return bool
*/
public function sleepOn(Vector3 $pos) : bool{
$pos = $pos->floor();
$b = $this->getWorld()->getBlock($pos);
@ -1084,9 +999,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
}
/**
* @return GameMode
*/
public function getGamemode() : GameMode{
return $this->gamemode;
}
@ -1106,10 +1018,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Sets the gamemode, and if needed, kicks the Player.
*
* @param GameMode $gm
*
* @return bool
*/
public function setGamemode(GameMode $gm) : bool{
if($this->gamemode->equals($gm)){
@ -1139,8 +1047,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* in Adventure Mode. Supply the $literal parameter as true to force a literal Survival Mode check.
*
* @param bool $literal whether a literal check should be performed
*
* @return bool
*/
public function isSurvival(bool $literal = false) : bool{
return $this->gamemode->equals(GameMode::SURVIVAL()) or (!$literal and $this->gamemode->equals(GameMode::ADVENTURE()));
@ -1151,8 +1057,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* in Spectator Mode. Supply the $literal parameter as true to force a literal Creative Mode check.
*
* @param bool $literal whether a literal check should be performed
*
* @return bool
*/
public function isCreative(bool $literal = false) : bool{
return $this->gamemode->equals(GameMode::CREATIVE()) or (!$literal and $this->gamemode->equals(GameMode::SPECTATOR()));
@ -1163,24 +1067,17 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* in Spectator Mode. Supply the $literal parameter as true to force a literal Adventure Mode check.
*
* @param bool $literal whether a literal check should be performed
*
* @return bool
*/
public function isAdventure(bool $literal = false) : bool{
return $this->gamemode->equals(GameMode::ADVENTURE()) or (!$literal and $this->gamemode->equals(GameMode::SPECTATOR()));
}
/**
* @return bool
*/
public function isSpectator() : bool{
return $this->gamemode->equals(GameMode::SPECTATOR());
}
/**
* TODO: make this a dynamic ability instead of being hardcoded
*
* @return bool
*/
public function hasFiniteResources() : bool{
return $this->gamemode->equals(GameMode::SURVIVAL()) or $this->gamemode->equals(GameMode::ADVENTURE());
@ -1233,8 +1130,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns the location that the player wants to be in at the end of this tick. Note that this may not be their
* actual result position at the end due to plugin interference or a range of other things.
*
* @return Vector3
*/
public function getNextPosition() : Vector3{
return $this->newPosition !== null ? clone $this->newPosition : $this->location->asVector3();
@ -1438,11 +1333,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns whether the player can interact with the specified position. This checks distance and direction.
*
* @param Vector3 $pos
* @param float $maxDistance
* @param float $maxDiff defaults to half of the 3D diagonal width of a block
*
* @return bool
*/
public function canInteract(Vector3 $pos, float $maxDistance, float $maxDiff = M_SQRT3 / 2) : bool{
$eyePos = $this->getEyePos();
@ -1459,10 +1350,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Sends a chat message as this player. If the message begins with a / (forward-slash) it will be treated
* as a command.
*
* @param string $message
*
* @return bool
*/
public function chat(string $message) : bool{
$this->doCloseInventory();
@ -1654,9 +1541,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Performs a left-click (attack) action on the block.
*
* @param Vector3 $pos
* @param int $face
*
* @return bool if an action took place successfully
*/
public function attackBlock(Vector3 $pos, int $face) : bool{
@ -1708,8 +1592,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Breaks the block at the given position using the currently-held item.
*
* @param Vector3 $pos
*
* @return bool if the block was successfully broken, false if a rollback needs to take place.
*/
public function breakBlock(Vector3 $pos) : bool{
@ -1734,10 +1616,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Touches the block at the given position with the currently-held item.
*
* @param Vector3 $pos
* @param int $face
* @param Vector3 $clickOffset
*
* @return bool if it did something
*/
public function interactBlock(Vector3 $pos, int $face, Vector3 $clickOffset) : bool{
@ -1762,8 +1640,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* Attacks the given entity with the currently-held item.
* TODO: move this up the class hierarchy
*
* @param Entity $entity
*
* @return bool if the entity was dealt damage
*/
public function attackEntity(Entity $entity) : bool{
@ -1831,11 +1707,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Interacts with the given entity using the currently-held item.
*
* @param Entity $entity
* @param Vector3 $clickPos
*
* @return bool
*/
public function interactEntity(Entity $entity, Vector3 $clickPos) : bool{
//TODO
@ -1877,8 +1748,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Drops an item on the ground in front of the player.
*
* @param Item $item
*/
public function dropItem(Item $item) : void{
$this->broadcastEntityEvent(ActorEventPacket::ARM_SWING, null, $this->getViewers());
@ -1888,8 +1757,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Adds a title text to the user's screen, with an optional subtitle.
*
* @param string $title
* @param string $subtitle
* @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
* @param int $stay Duration in ticks to stay on screen for
* @param int $fadeOut Duration in ticks for fade-out.
@ -1904,8 +1771,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Sets the subtitle message, without sending a title.
*
* @param string $subtitle
*/
public function sendSubTitle(string $subtitle) : void{
$this->networkSession->onSubTitle($subtitle);
@ -1913,8 +1778,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Adds small text to the user's screen.
*
* @param string $message
*/
public function sendActionBarMessage(string $message) : void{
$this->networkSession->onActionBar($message);
@ -1965,7 +1828,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
/**
* @param string $message
* @param string[] $parameters
*/
public function sendTranslation(string $message, array $parameters = []) : void{
@ -1983,8 +1845,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* Sends a popup message to the player
*
* TODO: add translation type popups
*
* @param string $message
*/
public function sendPopup(string $message) : void{
$this->networkSession->onPopup($message);
@ -1997,8 +1857,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Sends a Form to the player, or queue to send it if a form is already open.
*
* @param Form $form
*
* @throws \InvalidArgumentException
*/
public function sendForm(Form $form) : void{
@ -2009,10 +1867,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
/**
* @param int $formId
* @param mixed $responseData
*
* @return bool
*/
public function onFormSubmit(int $formId, $responseData) : bool{
if(!isset($this->forms[$formId])){
@ -2055,11 +1910,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Kicks a player from the server
*
* @param string $reason
* @param bool $isAdmin
* @param TextContainer|string $quitMessage
*
* @return bool
*/
public function kick(string $reason = "", bool $isAdmin = true, $quitMessage = null) : bool{
$ev = new PlayerKickEvent($this, $reason, $quitMessage ?? $this->getLeaveMessage());
@ -2093,7 +1944,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
*
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
* @param TextContainer|string $quitMessage Message to broadcast to online players (null will use default)
* @param bool $notify
*/
public function disconnect(string $reason, $quitMessage = null, bool $notify = true) : void{
if(!$this->isConnected()){
@ -2347,11 +2197,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* TODO: remove this
*
* @param Vector3 $pos
* @param float|null $yaw
* @param float|null $pitch
* @param int $mode
*/
public function sendPosition(Vector3 $pos, ?float $yaw = null, ?float $pitch = null, int $mode = MovePlayerPacket::MODE_NORMAL) : void{
$this->networkSession->syncMovement($pos, $yaw, $pitch, $mode);
@ -2407,9 +2252,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->craftingGrid;
}
/**
* @param CraftingGrid $grid
*/
public function setCraftingGrid(CraftingGrid $grid) : void{
$this->craftingGrid = $grid;
}
@ -2440,8 +2282,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Returns the inventory the player is currently viewing. This might be a chest, furnace, or any other container.
*
* @return Inventory|null
*/
public function getCurrentWindow() : ?Inventory{
return $this->currentWindow;
@ -2449,10 +2289,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Opens an inventory window to the player. Returns if it was successful.
*
* @param Inventory $inventory
*
* @return bool
*/
public function setCurrentWindow(Inventory $inventory) : bool{
if($inventory === $this->currentWindow){