and more typehints

This commit is contained in:
Dylan K. Taylor
2017-07-14 10:56:51 +01:00
parent b9355387da
commit c3b8be3f60
119 changed files with 598 additions and 541 deletions

View File

@ -77,7 +77,6 @@ use pocketmine\inventory\BigShapedRecipe;
use pocketmine\inventory\BigShapelessRecipe;
use pocketmine\inventory\FurnaceInventory;
use pocketmine\inventory\Inventory;
use pocketmine\inventory\InventoryHolder;
use pocketmine\inventory\PlayerInventory;
use pocketmine\inventory\ShapedRecipe;
use pocketmine\inventory\ShapelessRecipe;
@ -196,6 +195,7 @@ use pocketmine\network\mcpe\protocol\UseItemPacket;
use pocketmine\network\SourceInterface;
use pocketmine\permission\PermissibleBase;
use pocketmine\permission\PermissionAttachment;
use pocketmine\permission\PermissionAttachmentInfo;
use pocketmine\plugin\Plugin;
use pocketmine\resourcepacks\ResourcePack;
use pocketmine\tile\ItemFrame;
@ -283,7 +283,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
protected $sleeping = null;
protected $clientID = null;
private $loaderId = null;
private $loaderId = 0;
protected $stepHeight = 0.6;
@ -350,11 +350,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
return $this->clientSecret;
}
public function isBanned(){
public function isBanned() : bool{
return $this->server->getNameBans()->isBanned($this->iusername);
}
public function setBanned($value){
public function setBanned(bool $value){
if($value === true){
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
$this->kick("You have been banned");
@ -363,11 +363,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
}
}
public function isWhitelisted(){
public function isWhitelisted() : bool{
return $this->server->isWhitelisted($this->iusername);
}
public function setWhitelisted($value){
public function setWhitelisted(bool $value){
if($value === true){
$this->server->addWhitelist($this->iusername);
}else{
@ -387,12 +387,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
}
public function hasPlayedBefore(){
public function hasPlayedBefore() : bool{
return $this->playedBefore;
}
public function setAllowFlight($value){
$this->allowFlight = (bool) $value;
public function setAllowFlight(bool $value){
$this->allowFlight = $value;
$this->sendSettings();
}
@ -453,7 +453,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
/**
* @return bool
*/
public function getRemoveFormat(){
public function getRemoveFormat() : bool{
return $this->removeFormat;
}
@ -480,7 +480,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return bool
*/
public function canSee(Player $player){
public function canSee(Player $player) : bool{
return !isset($this->hiddenPlayers[$player->getRawUniqueId()]);
}
@ -539,21 +539,21 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
/**
* @return bool
*/
public function isOnline(){
public function isOnline() : bool{
return $this->connected === true and $this->loggedIn === true;
}
/**
* @return bool
*/
public function isOp(){
public function isOp() : bool{
return $this->server->isOp($this->getName());
}
/**
* @param bool $value
*/
public function setOp($value){
public function setOp(bool $value){
if($value === $this->isOp()){
return;
}
@ -572,7 +572,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return bool
*/
public function isPermissionSet($name){
public function isPermissionSet($name) : bool{
return $this->perm->isPermissionSet($name);
}
@ -583,7 +583,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @throws \InvalidStateException if the player is closed
*/
public function hasPermission($name){
public function hasPermission($name) : bool{
if($this->closed){
throw new \InvalidStateException("Trying to get permissions of closed player");
}
@ -629,9 +629,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
}
/**
* @return permission\PermissionAttachmentInfo[]
* @return PermissionAttachmentInfo[]
*/
public function getEffectivePermissions(){
public function getEffectivePermissions() : array{
return $this->perm->getEffectivePermissions();
}
@ -698,7 +698,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return bool
*/
public function hasAchievement($achievementId){
public function hasAchievement(string $achievementId) : bool{
if(!isset(Achievement::$list[$achievementId])){
return false;
}
@ -709,7 +709,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
/**
* @return bool
*/
public function isConnected(){
public function isConnected() : bool{
return $this->connected === true;
}
@ -718,7 +718,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return string
*/
public function getDisplayName(){
public function getDisplayName() : string{
return $this->displayName;
}
@ -744,14 +744,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return string
*/
public function getAddress(){
public function getAddress() : string{
return $this->ip;
}
/**
* @return int
*/
public function getPort(){
public function getPort() : int{
return $this->port;
}
@ -762,7 +762,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
/**
* @return bool
*/
public function isSleeping(){
public function isSleeping() : bool{
return $this->sleeping !== null;
}
@ -1035,7 +1035,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return bool
*/
public function batchDataPacket(DataPacket $packet){
public function batchDataPacket(DataPacket $packet) : bool{
if($this->connected === false){
return false;
}
@ -1133,9 +1133,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
/**
* @param Vector3 $pos
*
* @return boolean
* @return bool
*/
public function sleepOn(Vector3 $pos){
public function sleepOn(Vector3 $pos) : bool{
if(!$this->isOnline()){
return false;
}
@ -1209,7 +1209,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return bool
*/
public function awardAchievement($achievementId){
public function awardAchievement(string $achievementId) : bool{
if(isset(Achievement::$list[$achievementId]) and !$this->hasAchievement($achievementId)){
foreach(Achievement::$list[$achievementId]["requires"] as $requirementId){
if(!$this->hasAchievement($requirementId)){
@ -1233,7 +1233,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
/**
* @return int
*/
public function getGamemode(){
public function getGamemode() : int{
return $this->gamemode;
}
@ -1265,7 +1265,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
*
* @return bool
*/
public function setGamemode(int $gm, bool $client = false){
public function setGamemode(int $gm, bool $client = false) : bool{
if($gm < 0 or $gm > 3 or $this->gamemode === $gm){
return false;
}
@ -1402,7 +1402,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
return $this->isCreative();
}
public function getDrops(){
public function getDrops() : array{
if(!$this->isCreative()){
return parent::getDrops();
}
@ -3477,11 +3477,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
* Kicks a player from the server
*
* @param string $reason
* @param bool $isAdmin
* @param bool $isAdmin
*
* @return bool
*/
public function kick($reason = "", $isAdmin = true){
public function kick($reason = "", bool $isAdmin = true) : bool{
$this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage()));
if(!$ev->isCancelled()){
if($isAdmin){
@ -4137,11 +4137,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer, Netwo
}
public function getLoaderId(){
public function getLoaderId() : int{
return $this->loaderId;
}
public function isLoaderActive(){
public function isLoaderActive() : bool{
return $this->isConnected();
}
}