mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-20 18:06:40 +00:00
Merge branch 'moar-typehints'
This commit is contained in:
commit
24bdf330d5
@ -38,7 +38,9 @@ class CrashDump{
|
||||
private $fp;
|
||||
private $time;
|
||||
private $data = [];
|
||||
private $encodedData = null;
|
||||
/** @var string */
|
||||
private $encodedData = "";
|
||||
/** @var string */
|
||||
private $path;
|
||||
|
||||
public function __construct(Server $server){
|
||||
@ -64,7 +66,7 @@ class CrashDump{
|
||||
$this->encodeData();
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
public function getPath() : string{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ class CrashDump{
|
||||
return $this->encodedData;
|
||||
}
|
||||
|
||||
public function getData(){
|
||||
public function getData() : array{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ interface IPlayer extends ServerOperator{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOnline();
|
||||
public function isOnline() : bool;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
@ -40,22 +40,22 @@ interface IPlayer extends ServerOperator{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBanned();
|
||||
public function isBanned() : bool;
|
||||
|
||||
/**
|
||||
* @param bool $banned
|
||||
*/
|
||||
public function setBanned($banned);
|
||||
public function setBanned(bool $banned);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWhitelisted();
|
||||
public function isWhitelisted() : bool;
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setWhitelisted($value);
|
||||
public function setWhitelisted(bool $value);
|
||||
|
||||
/**
|
||||
* @return Player|null
|
||||
@ -73,8 +73,8 @@ interface IPlayer extends ServerOperator{
|
||||
public function getLastPlayed();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPlayedBefore();
|
||||
public function hasPlayedBefore() : bool;
|
||||
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ class MemoryManager{
|
||||
gc_enable();
|
||||
}
|
||||
|
||||
public function isLowMemory(){
|
||||
public function isLowMemory() : bool{
|
||||
return $this->lowMemory;
|
||||
}
|
||||
|
||||
public function canUseChunkCache(){
|
||||
public function canUseChunkCache() : bool{
|
||||
return !($this->lowMemory and $this->chunkTrigger);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function isOnline(){
|
||||
public function isOnline() : bool{
|
||||
return $this->getPlayer() !== null;
|
||||
}
|
||||
|
||||
@ -60,11 +60,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
public function isOp(){
|
||||
public function isOp() : bool{
|
||||
return $this->server->isOp(strtolower($this->getName()));
|
||||
}
|
||||
|
||||
public function setOp($value){
|
||||
public function setOp(bool $value){
|
||||
if($value === $this->isOp()){
|
||||
return;
|
||||
}
|
||||
@ -76,11 +76,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function isBanned(){
|
||||
public function isBanned() : bool{
|
||||
return $this->server->getNameBans()->isBanned(strtolower($this->getName()));
|
||||
}
|
||||
|
||||
public function setBanned($value){
|
||||
public function setBanned(bool $value){
|
||||
if($value === true){
|
||||
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
|
||||
}else{
|
||||
@ -88,11 +88,11 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function isWhitelisted(){
|
||||
public function isWhitelisted() : bool{
|
||||
return $this->server->isWhitelisted(strtolower($this->getName()));
|
||||
}
|
||||
|
||||
public function setWhitelisted($value){
|
||||
public function setWhitelisted(bool $value){
|
||||
if($value === true){
|
||||
$this->server->addWhitelist(strtolower($this->getName()));
|
||||
}else{
|
||||
@ -112,7 +112,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
|
||||
}
|
||||
|
||||
public function hasPlayedBefore(){
|
||||
public function hasPlayedBefore() : bool{
|
||||
return $this->namedtag instanceof CompoundTag;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,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;
|
||||
@ -160,6 +159,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;
|
||||
@ -253,7 +253,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
protected $sleeping = null;
|
||||
protected $clientID = null;
|
||||
|
||||
private $loaderId = null;
|
||||
private $loaderId = 0;
|
||||
|
||||
protected $stepHeight = 0.6;
|
||||
|
||||
@ -320,11 +320,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
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");
|
||||
@ -333,11 +333,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
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{
|
||||
@ -357,12 +357,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getRemoveFormat(){
|
||||
public function getRemoveFormat() : bool{
|
||||
return $this->removeFormat;
|
||||
}
|
||||
|
||||
@ -450,7 +450,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canSee(Player $player){
|
||||
public function canSee(Player $player) : bool{
|
||||
return !isset($this->hiddenPlayers[$player->getRawUniqueId()]);
|
||||
}
|
||||
|
||||
@ -509,21 +509,21 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
@ -542,7 +542,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPermissionSet($name){
|
||||
public function isPermissionSet($name) : bool{
|
||||
return $this->perm->isPermissionSet($name);
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @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");
|
||||
}
|
||||
@ -599,9 +599,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return permission\PermissionAttachmentInfo[]
|
||||
* @return PermissionAttachmentInfo[]
|
||||
*/
|
||||
public function getEffectivePermissions(){
|
||||
public function getEffectivePermissions() : array{
|
||||
return $this->perm->getEffectivePermissions();
|
||||
}
|
||||
|
||||
@ -670,7 +670,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAchievement($achievementId){
|
||||
public function hasAchievement(string $achievementId) : bool{
|
||||
if(!isset(Achievement::$list[$achievementId])){
|
||||
return false;
|
||||
}
|
||||
@ -681,7 +681,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isConnected(){
|
||||
public function isConnected() : bool{
|
||||
return $this->connected === true;
|
||||
}
|
||||
|
||||
@ -690,7 +690,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName(){
|
||||
public function getDisplayName() : string{
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
@ -716,14 +716,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress(){
|
||||
public function getAddress() : string{
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPort(){
|
||||
public function getPort() : int{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
@ -734,7 +734,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSleeping(){
|
||||
public function isSleeping() : bool{
|
||||
return $this->sleeping !== null;
|
||||
}
|
||||
|
||||
@ -1007,7 +1007,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function batchDataPacket(DataPacket $packet){
|
||||
public function batchDataPacket(DataPacket $packet) : bool{
|
||||
if($this->connected === false){
|
||||
return false;
|
||||
}
|
||||
@ -1105,9 +1105,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function sleepOn(Vector3 $pos){
|
||||
public function sleepOn(Vector3 $pos) : bool{
|
||||
if(!$this->isOnline()){
|
||||
return false;
|
||||
}
|
||||
@ -1181,7 +1181,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @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)){
|
||||
@ -1205,7 +1205,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getGamemode(){
|
||||
public function getGamemode() : int{
|
||||
return $this->gamemode;
|
||||
}
|
||||
|
||||
@ -1237,7 +1237,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
@ -1374,7 +1374,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return $this->isCreative();
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
public function getDrops() : array{
|
||||
if(!$this->isCreative()){
|
||||
return parent::getDrops();
|
||||
}
|
||||
@ -3216,7 +3216,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
*
|
||||
* @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){
|
||||
@ -3874,11 +3874,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
}
|
||||
|
||||
public function getLoaderId(){
|
||||
public function getLoaderId() : int{
|
||||
return $this->loaderId;
|
||||
}
|
||||
|
||||
public function isLoaderActive(){
|
||||
public function isLoaderActive() : bool{
|
||||
return $this->isConnected();
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace pocketmine {
|
||||
use raklib\RakLib;
|
||||
|
||||
const VERSION = "1.6.2dev";
|
||||
const API_VERSION = "3.0.0-ALPHA6";
|
||||
const API_VERSION = "3.0.0-ALPHA7";
|
||||
const CODENAME = "Unleashed";
|
||||
|
||||
/*
|
||||
|
@ -577,7 +577,7 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \AttachableThreadedLogger
|
||||
* @return MainLogger
|
||||
*/
|
||||
public function getLogger(){
|
||||
return $this->logger;
|
||||
@ -1043,12 +1043,12 @@ class Server{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function generateLevel(string $name, $seed = null, $generator = null, array $options = []){
|
||||
public function generateLevel(string $name, int $seed = null, $generator = null, array $options = []) : bool{
|
||||
if(trim($name) === "" or $this->isLevelGenerated($name)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$seed = $seed === null ? Binary::readInt(random_bytes(4)) : (int) $seed;
|
||||
$seed = $seed ?? Binary::readInt(random_bytes(4));
|
||||
|
||||
if(!isset($options["preset"])){
|
||||
$options["preset"] = $this->getConfigString("generator-settings", "");
|
||||
@ -1328,7 +1328,7 @@ class Server{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWhitelisted(string $name){
|
||||
public function isWhitelisted(string $name) : bool{
|
||||
return !$this->hasWhitelist() or $this->operators->exists($name, true) or $this->whitelist->exists($name, true);
|
||||
}
|
||||
|
||||
@ -1337,7 +1337,7 @@ class Server{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOp(string $name){
|
||||
public function isOp(string $name) : bool{
|
||||
return $this->operators->exists($name, true);
|
||||
}
|
||||
|
||||
@ -1765,7 +1765,7 @@ class Server{
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function broadcastTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1, $recipients = null){
|
||||
public function broadcastTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1, array $recipients = null) : int{
|
||||
if(!is_array($recipients)){
|
||||
/** @var Player[] $recipients */
|
||||
$recipients = [];
|
||||
@ -1931,7 +1931,7 @@ class Server{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatchCommand(CommandSender $sender, string $commandLine){
|
||||
public function dispatchCommand(CommandSender $sender, string $commandLine) : bool{
|
||||
if($this->commandMap->dispatch($sender, $commandLine)){
|
||||
return true;
|
||||
}
|
||||
@ -2054,6 +2054,9 @@ class Server{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return QueryRegenerateEvent
|
||||
*/
|
||||
public function getQueryInformation(){
|
||||
return $this->queryRegenerateTask;
|
||||
}
|
||||
@ -2428,7 +2431,7 @@ class Server{
|
||||
/**
|
||||
* Tries to execute a server tick
|
||||
*/
|
||||
private function tick(){
|
||||
private function tick() : bool{
|
||||
$tickTime = microtime(true);
|
||||
if(($tickTime - $this->nextTick) < -0.025){ //Allow half a tick of diff
|
||||
return false;
|
||||
|
@ -60,7 +60,7 @@ class ThreadManager extends \Volatile{
|
||||
/**
|
||||
* @return Worker[]|Thread[]
|
||||
*/
|
||||
public function getAll(){
|
||||
public function getAll() : array{
|
||||
$array = [];
|
||||
foreach($this as $key => $thread){
|
||||
$array[$key] = $thread;
|
||||
|
@ -88,7 +88,7 @@ abstract class Worker extends \Worker{
|
||||
ThreadManager::getInstance()->remove($this);
|
||||
}
|
||||
|
||||
public function getThreadName(){
|
||||
public function getThreadName() : string{
|
||||
return (new \ReflectionClass($this))->getShortName();
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ abstract class Command{
|
||||
* @param string $usageMessage
|
||||
* @param string[] $aliases
|
||||
*/
|
||||
public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){
|
||||
public function __construct(string $name, string $description = "", string $usageMessage = null, array $aliases = []){
|
||||
$this->commandData = self::generateDefaultData();
|
||||
$this->name = $name;
|
||||
$this->setLabel($name);
|
||||
@ -100,7 +100,7 @@ abstract class Command{
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function generateCustomCommandData(Player $player){
|
||||
public function generateCustomCommandData(Player $player) : array{
|
||||
//TODO: fix command permission filtering on join
|
||||
/*if(!$this->testPermissionSilent($player)){
|
||||
return null;
|
||||
@ -118,7 +118,7 @@ abstract class Command{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getOverloads(): array{
|
||||
public function getOverloads() : array{
|
||||
return $this->commandData["overloads"];
|
||||
}
|
||||
|
||||
@ -129,12 +129,12 @@ abstract class Command{
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function execute(CommandSender $sender, $commandLabel, array $args);
|
||||
abstract public function execute(CommandSender $sender, string $commandLabel, array $args);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(){
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ abstract class Command{
|
||||
/**
|
||||
* @param string|null $permission
|
||||
*/
|
||||
public function setPermission($permission){
|
||||
public function setPermission(string $permission = null){
|
||||
if($permission !== null){
|
||||
$this->commandData["pocketminePermission"] = $permission;
|
||||
}else{
|
||||
@ -162,7 +162,7 @@ abstract class Command{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testPermission(CommandSender $target){
|
||||
public function testPermission(CommandSender $target) : bool{
|
||||
if($this->testPermissionSilent($target)){
|
||||
return true;
|
||||
}
|
||||
@ -181,7 +181,7 @@ abstract class Command{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testPermissionSilent(CommandSender $target){
|
||||
public function testPermissionSilent(CommandSender $target) : bool{
|
||||
if(($perm = $this->getPermission()) === null or $perm === ""){
|
||||
return true;
|
||||
}
|
||||
@ -198,11 +198,11 @@ abstract class Command{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel(){
|
||||
public function getLabel() : string{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel($name){
|
||||
public function setLabel(string $name) : bool{
|
||||
$this->nextLabel = $name;
|
||||
if(!$this->isRegistered()){
|
||||
if($this->timings instanceof TimingsHandler){
|
||||
@ -224,7 +224,7 @@ abstract class Command{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register(CommandMap $commandMap){
|
||||
public function register(CommandMap $commandMap) : bool{
|
||||
if($this->allowChangesFrom($commandMap)){
|
||||
$this->commandMap = $commandMap;
|
||||
|
||||
@ -239,7 +239,7 @@ abstract class Command{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unregister(CommandMap $commandMap){
|
||||
public function unregister(CommandMap $commandMap) : bool{
|
||||
if($this->allowChangesFrom($commandMap)){
|
||||
$this->commandMap = null;
|
||||
$this->activeAliases = $this->commandData["aliases"];
|
||||
@ -256,42 +256,42 @@ abstract class Command{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function allowChangesFrom(CommandMap $commandMap){
|
||||
private function allowChangesFrom(CommandMap $commandMap) : bool{
|
||||
return $this->commandMap === null or $this->commandMap === $commandMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRegistered(){
|
||||
public function isRegistered() : bool{
|
||||
return $this->commandMap !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAliases(){
|
||||
public function getAliases() : array{
|
||||
return $this->activeAliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPermissionMessage(){
|
||||
public function getPermissionMessage() : string{
|
||||
return $this->permissionMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(){
|
||||
public function getDescription() : string{
|
||||
return $this->commandData["description"];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsage(){
|
||||
public function getUsage() : string{
|
||||
return $this->usageMessage;
|
||||
}
|
||||
|
||||
@ -308,21 +308,21 @@ abstract class Command{
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription($description){
|
||||
public function setDescription(string $description){
|
||||
$this->commandData["description"] = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $permissionMessage
|
||||
*/
|
||||
public function setPermissionMessage($permissionMessage){
|
||||
public function setPermissionMessage(string $permissionMessage){
|
||||
$this->permissionMessage = $permissionMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $usage
|
||||
*/
|
||||
public function setUsage($usage){
|
||||
public function setUsage(string $usage){
|
||||
$this->usageMessage = $usage;
|
||||
}
|
||||
|
||||
@ -338,10 +338,10 @@ abstract class Command{
|
||||
|
||||
/**
|
||||
* @param CommandSender $source
|
||||
* @param string $message
|
||||
* @param TextContainer|string $message
|
||||
* @param bool $sendToSource
|
||||
*/
|
||||
public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){
|
||||
public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true){
|
||||
if($message instanceof TextContainer){
|
||||
$m = clone $message;
|
||||
$result = "[" . $source->getName() . ": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() . "]";
|
||||
@ -377,7 +377,7 @@ abstract class Command{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(){
|
||||
public function __toString() : string{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,6 @@ interface CommandExecutor{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onCommand(CommandSender $sender, Command $command, $label, array $args);
|
||||
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool;
|
||||
|
||||
}
|
@ -30,14 +30,16 @@ interface CommandMap{
|
||||
* @param string $fallbackPrefix
|
||||
* @param Command[] $commands
|
||||
*/
|
||||
public function registerAll($fallbackPrefix, array $commands);
|
||||
public function registerAll(string $fallbackPrefix, array $commands);
|
||||
|
||||
/**
|
||||
* @param string $fallbackPrefix
|
||||
* @param Command $command
|
||||
* @param string $label
|
||||
* @param string|null $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register($fallbackPrefix, Command $command, $label = null);
|
||||
public function register(string $fallbackPrefix, Command $command, string $label = null) : bool;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
@ -45,7 +47,7 @@ interface CommandMap{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function dispatch(CommandSender $sender, $cmdLine);
|
||||
public function dispatch(CommandSender $sender, string $cmdLine) : bool;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
@ -55,9 +57,9 @@ interface CommandMap{
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Command
|
||||
* @return Command|null
|
||||
*/
|
||||
public function getCommand($name);
|
||||
public function getCommand(string $name);
|
||||
|
||||
|
||||
}
|
@ -31,7 +31,6 @@ use pocketmine\permission\PermissionAttachmentInfo;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\Terminal;
|
||||
|
||||
class ConsoleCommandSender implements CommandSender{
|
||||
|
||||
@ -49,7 +48,7 @@ class ConsoleCommandSender implements CommandSender{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPermissionSet($name){
|
||||
public function isPermissionSet($name) : bool{
|
||||
return $this->perm->isPermissionSet($name);
|
||||
}
|
||||
|
||||
@ -58,7 +57,7 @@ class ConsoleCommandSender implements CommandSender{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPermission($name){
|
||||
public function hasPermission($name) : bool{
|
||||
return $this->perm->hasPermission($name);
|
||||
}
|
||||
|
||||
@ -89,14 +88,14 @@ class ConsoleCommandSender implements CommandSender{
|
||||
/**
|
||||
* @return PermissionAttachmentInfo[]
|
||||
*/
|
||||
public function getEffectivePermissions(){
|
||||
public function getEffectivePermissions() : array{
|
||||
return $this->perm->getEffectivePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlayer(){
|
||||
public function isPlayer() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -132,14 +131,14 @@ class ConsoleCommandSender implements CommandSender{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOp(){
|
||||
public function isOp() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setOp($value){
|
||||
public function setOp(bool $value){
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,12 @@ class FormattedCommandAlias extends Command{
|
||||
* @param string $alias
|
||||
* @param string[] $formatStrings
|
||||
*/
|
||||
public function __construct($alias, array $formatStrings){
|
||||
public function __construct(string $alias, array $formatStrings){
|
||||
parent::__construct($alias);
|
||||
$this->formatStrings = $formatStrings;
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $commandLabel, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
|
||||
$commands = [];
|
||||
$result = false;
|
||||
@ -71,9 +71,8 @@ class FormattedCommandAlias extends Command{
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function buildCommand($formatString, array $args){
|
||||
private function buildCommand(string $formatString, array $args) : string{
|
||||
$index = strpos($formatString, '$');
|
||||
while($index !== false){
|
||||
$start = $index;
|
||||
@ -153,7 +152,7 @@ class FormattedCommandAlias extends Command{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function inRange($i, $j, $k){
|
||||
private static function inRange(int $i, int $j, int $k) : bool{
|
||||
return $i >= $j and $i <= $k;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
|
||||
$this->usageMessage = "";
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $commandLabel, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
|
||||
if(!$this->owningPlugin->isEnabled()){
|
||||
return false;
|
||||
@ -64,7 +64,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function getExecutor(){
|
||||
public function getExecutor() : CommandExecutor{
|
||||
return $this->executor;
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
||||
public function getPlugin(){
|
||||
public function getPlugin() : Plugin{
|
||||
return $this->owningPlugin;
|
||||
}
|
||||
}
|
||||
|
@ -30,5 +30,5 @@ interface PluginIdentifiableCommand{
|
||||
/**
|
||||
* @return Plugin
|
||||
*/
|
||||
public function getPlugin();
|
||||
public function getPlugin() : Plugin;
|
||||
}
|
||||
|
@ -131,13 +131,20 @@ class SimpleCommandMap implements CommandMap{
|
||||
}
|
||||
|
||||
|
||||
public function registerAll($fallbackPrefix, array $commands){
|
||||
public function registerAll(string $fallbackPrefix, array $commands){
|
||||
foreach($commands as $command){
|
||||
$this->register($fallbackPrefix, $command);
|
||||
}
|
||||
}
|
||||
|
||||
public function register($fallbackPrefix, Command $command, $label = null){
|
||||
/**
|
||||
* @param string $fallbackPrefix
|
||||
* @param Command $command
|
||||
* @param string|null $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register(string $fallbackPrefix, Command $command, string $label = null) : bool{
|
||||
if($label === null){
|
||||
$label = $command->getName();
|
||||
}
|
||||
@ -163,7 +170,15 @@ class SimpleCommandMap implements CommandMap{
|
||||
return $registered;
|
||||
}
|
||||
|
||||
private function registerAlias(Command $command, $isAlias, $fallbackPrefix, $label){
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param bool $isAlias
|
||||
* @param string $fallbackPrefix
|
||||
* @param string $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function registerAlias(Command $command, bool $isAlias, string $fallbackPrefix, string $label) : bool{
|
||||
$this->knownCommands[$fallbackPrefix . ":" . $label] = $command;
|
||||
if(($command instanceof VanillaCommand or $isAlias) and isset($this->knownCommands[$label])){
|
||||
return false;
|
||||
@ -207,7 +222,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function dispatch(CommandSender $sender, $commandLine){
|
||||
public function dispatch(CommandSender $sender, string $commandLine) : bool{
|
||||
$args = explode(" ", $commandLine);
|
||||
$sentCommandLabel = "";
|
||||
$target = $this->matchCommand($sentCommandLabel, $args);
|
||||
@ -241,14 +256,14 @@ class SimpleCommandMap implements CommandMap{
|
||||
$this->setDefaultCommands();
|
||||
}
|
||||
|
||||
public function getCommand($name){
|
||||
public function getCommand(string $name){
|
||||
return $this->knownCommands[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Command[]
|
||||
*/
|
||||
public function getCommands(){
|
||||
public function getCommands() : array{
|
||||
return $this->knownCommands;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class BanCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.ban.player");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class BanIpCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.ban.ip");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class BanListCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.ban.list");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class DefaultGamemodeCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.defaultgamemode");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class DeopCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.op.take");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class DifficultyCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.difficulty");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class DumpMemoryCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.dumpmemory");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class EffectCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.effect");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class EnchantCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.enchant");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class GamemodeCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.gamemode");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class GarbageCollectorCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.gc");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class GiveCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.give");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace pocketmine\command\defaults;
|
||||
|
||||
use pocketmine\command\Command;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\ConsoleCommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
@ -41,7 +40,7 @@ class HelpCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.help");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class KickCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.kick");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class KillCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.kill.self;pocketmine.command.kill.other");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class ListCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.list");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class MeCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.me");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class OpCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.op.give");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class PardonCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.unban.player");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class PardonIpCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.unban.ip");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class ParticleCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.particle");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class PluginsCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.plugins");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class ReloadCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.reload");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class SaveCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.save.perform");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class SaveOffCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.save.disable");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class SaveOnCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.save.enable");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class SayCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.say");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class SeedCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.seed");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class SetWorldSpawnCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.setworldspawn");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class SpawnpointCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.spawnpoint");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class StatusCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.status");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class StopCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.stop");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class TeleportCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.teleport");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class TellCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.tell");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class TimeCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.time.add;pocketmine.command.time.set;pocketmine.command.time.start;pocketmine.command.time.stop");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(count($args) < 1){
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class TimingsCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.timings");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class TitleCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.title");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class TransferServerCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.transferserver");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $commandLabel, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(count($args) < 1){
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}elseif(!($sender instanceof Player)){
|
||||
|
@ -41,7 +41,7 @@ class VersionCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.version");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class WhitelistCommand extends VanillaCommand{
|
||||
$this->setPermission("pocketmine.command.whitelist.reload;pocketmine.command.whitelist.enable;pocketmine.command.whitelist.disable;pocketmine.command.whitelist.list;pocketmine.command.whitelist.add;pocketmine.command.whitelist.remove");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\entity;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\event\entity\EntityBlockChangeEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
|
@ -99,7 +99,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRawUniqueId(){
|
||||
public function getRawUniqueId() : string{
|
||||
return $this->rawUUID;
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
return $this->getNameTag();
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
public function getDrops() : array{
|
||||
return $this->inventory !== null ? array_values($this->inventory->getContents()) : [];
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@ use pocketmine\event\Timings;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\utils\BlockIterator;
|
||||
|
||||
@ -275,7 +274,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
/**
|
||||
* @return ItemItem[]
|
||||
*/
|
||||
public function getDrops(){
|
||||
public function getDrops() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ class Squid extends WaterAnimal{
|
||||
parent::spawnTo($player);
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
public function getDrops() : array{
|
||||
return [
|
||||
ItemItem::get(ItemItem::DYE, 0, mt_rand(1, 3))
|
||||
];
|
||||
|
@ -57,7 +57,7 @@ class Zombie extends Monster{
|
||||
parent::spawnTo($player);
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
public function getDrops() : array{
|
||||
$drops = [
|
||||
ItemItem::get(ItemItem::FEATHER, 0, 1)
|
||||
];
|
||||
|
@ -31,7 +31,7 @@ interface Cancellable{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCancelled();
|
||||
public function isCancelled() : bool;
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
|
@ -176,7 +176,7 @@ abstract class Timings{
|
||||
*
|
||||
* @return TimingsHandler
|
||||
*/
|
||||
public static function getPluginTaskTimings(TaskHandler $task, int $period){
|
||||
public static function getPluginTaskTimings(TaskHandler $task, int $period) : TimingsHandler{
|
||||
$ftask = $task->getTask();
|
||||
if($ftask instanceof PluginTask and $ftask->getOwner() !== null){
|
||||
$plugin = $ftask->getOwner()->getDescription()->getFullName();
|
||||
@ -208,7 +208,7 @@ abstract class Timings{
|
||||
*
|
||||
* @return TimingsHandler
|
||||
*/
|
||||
public static function getEntityTimings(Entity $entity){
|
||||
public static function getEntityTimings(Entity $entity) : TimingsHandler{
|
||||
$entityType = (new \ReflectionClass($entity))->getShortName();
|
||||
if(!isset(self::$entityTypeTimingMap[$entityType])){
|
||||
if($entity instanceof Player){
|
||||
@ -226,7 +226,7 @@ abstract class Timings{
|
||||
*
|
||||
* @return TimingsHandler
|
||||
*/
|
||||
public static function getTileEntityTimings(Tile $tile){
|
||||
public static function getTileEntityTimings(Tile $tile) : TimingsHandler{
|
||||
$tileType = (new \ReflectionClass($tile))->getShortName();
|
||||
if(!isset(self::$tileEntityTypeTimingMap[$tileType])){
|
||||
self::$tileEntityTypeTimingMap[$tileType] = new TimingsHandler("** tickTileEntity - " . $tileType, self::$tickTileEntityTimer);
|
||||
@ -240,7 +240,7 @@ abstract class Timings{
|
||||
*
|
||||
* @return TimingsHandler
|
||||
*/
|
||||
public static function getReceiveDataPacketTimings(DataPacket $pk){
|
||||
public static function getReceiveDataPacketTimings(DataPacket $pk) : TimingsHandler{
|
||||
if(!isset(self::$packetReceiveTimingMap[$pk::NETWORK_ID])){
|
||||
$pkName = (new \ReflectionClass($pk))->getShortName();
|
||||
self::$packetReceiveTimingMap[$pk::NETWORK_ID] = new TimingsHandler("** receivePacket - " . $pkName . " [0x" . dechex($pk::NETWORK_ID) . "]", self::$playerNetworkReceiveTimer);
|
||||
@ -255,7 +255,7 @@ abstract class Timings{
|
||||
*
|
||||
* @return TimingsHandler
|
||||
*/
|
||||
public static function getSendDataPacketTimings(DataPacket $pk){
|
||||
public static function getSendDataPacketTimings(DataPacket $pk) : TimingsHandler{
|
||||
if(!isset(self::$packetSendTimingMap[$pk::NETWORK_ID])){
|
||||
$pkName = (new \ReflectionClass($pk))->getShortName();
|
||||
self::$packetSendTimingMap[$pk::NETWORK_ID] = new TimingsHandler("** sendPacket - " . $pkName . " [0x" . dechex($pk::NETWORK_ID) . "]", self::$playerNetworkTimer);
|
||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
|
||||
class BlockFormEvent extends BlockGrowEvent{
|
||||
public static $handlerList = null;
|
||||
|
||||
|
@ -23,10 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\player;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
|
||||
class PlayerBucketFillEvent extends PlayerBucketEvent{
|
||||
public static $handlerList = null;
|
||||
}
|
@ -26,7 +26,6 @@ namespace pocketmine\event\player;
|
||||
use pocketmine\entity\Human;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\entity\EntityEvent;
|
||||
use pocketmine\Player;
|
||||
|
||||
class PlayerExhaustEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
@ -84,32 +84,32 @@ abstract class BaseInventory implements Inventory{
|
||||
$this->slots = [];
|
||||
}
|
||||
|
||||
public function getSize(){
|
||||
public function getSize() : int{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function setSize($size){
|
||||
$this->size = (int) $size;
|
||||
public function setSize(int $size){
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
public function getMaxStackSize(){
|
||||
public function getMaxStackSize() : int{
|
||||
return $this->maxStackSize;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getTitle(){
|
||||
public function getTitle() : string{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getItem($index){
|
||||
public function getItem(int $index) : Item{
|
||||
assert($index >= 0, "Inventory slot should not be negative");
|
||||
return isset($this->slots[$index]) ? clone $this->slots[$index] : Item::get(Item::AIR, 0, 0);
|
||||
}
|
||||
|
||||
public function getContents(){
|
||||
public function getContents() : array{
|
||||
return $this->slots;
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
}
|
||||
|
||||
public function setItem($index, Item $item){
|
||||
public function setItem(int $index, Item $item) : bool{
|
||||
$item = clone $item;
|
||||
if($index < 0 or $index >= $this->size){
|
||||
return false;
|
||||
@ -159,7 +159,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function contains(Item $item){
|
||||
public function contains(Item $item) : bool{
|
||||
$count = max(1, $item->getCount());
|
||||
$checkDamage = !$item->hasAnyDamageValue();
|
||||
$checkTags = $item->hasCompoundTag();
|
||||
@ -175,7 +175,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function all(Item $item){
|
||||
public function all(Item $item) : array{
|
||||
$slots = [];
|
||||
$checkDamage = !$item->hasAnyDamageValue();
|
||||
$checkTags = $item->hasCompoundTag();
|
||||
@ -199,7 +199,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
}
|
||||
|
||||
public function first(Item $item){
|
||||
public function first(Item $item) : int{
|
||||
$count = max(1, $item->getCount());
|
||||
$checkDamage = !$item->hasAnyDamageValue();
|
||||
$checkTags = $item->hasCompoundTag();
|
||||
@ -213,7 +213,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function firstEmpty(){
|
||||
public function firstEmpty() : int{
|
||||
for($i = 0; $i < $this->size; ++$i){
|
||||
if($this->getItem($i)->getId() === Item::AIR){
|
||||
return $i;
|
||||
@ -223,7 +223,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function canAddItem(Item $item){
|
||||
public function canAddItem(Item $item) : bool{
|
||||
$item = clone $item;
|
||||
$checkDamage = !$item->hasAnyDamageValue();
|
||||
$checkTags = $item->hasCompoundTag();
|
||||
@ -245,7 +245,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addItem(Item ...$slots){
|
||||
public function addItem(Item ...$slots) : array{
|
||||
/** @var Item[] $itemSlots */
|
||||
/** @var Item[] $slots */
|
||||
$itemSlots = [];
|
||||
@ -302,7 +302,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return $itemSlots;
|
||||
}
|
||||
|
||||
public function removeItem(Item ...$slots){
|
||||
public function removeItem(Item ...$slots) : array{
|
||||
/** @var Item[] $itemSlots */
|
||||
/** @var Item[] $slots */
|
||||
$itemSlots = [];
|
||||
@ -338,7 +338,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return $itemSlots;
|
||||
}
|
||||
|
||||
public function clear($index){
|
||||
public function clear(int $index) : bool{
|
||||
if(isset($this->slots[$index])){
|
||||
$item = Item::get(Item::AIR, 0, 0);
|
||||
$old = $this->slots[$index];
|
||||
@ -372,7 +372,7 @@ abstract class BaseInventory implements Inventory{
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getViewers(){
|
||||
public function getViewers() : array{
|
||||
return $this->viewers;
|
||||
}
|
||||
|
||||
@ -380,11 +380,11 @@ abstract class BaseInventory implements Inventory{
|
||||
return $this->holder;
|
||||
}
|
||||
|
||||
public function setMaxStackSize($size){
|
||||
$this->maxStackSize = (int) $size;
|
||||
public function setMaxStackSize(int $size){
|
||||
$this->maxStackSize = $size;
|
||||
}
|
||||
|
||||
public function open(Player $who){
|
||||
public function open(Player $who) : bool{
|
||||
$who->getServer()->getPluginManager()->callEvent($ev = new InventoryOpenEvent($this, $who));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
@ -459,7 +459,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
}
|
||||
|
||||
public function getType(){
|
||||
public function getType() : InventoryType{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
@ -43,31 +43,31 @@ class BaseTransaction implements Transaction{
|
||||
* @param Item $sourceItem
|
||||
* @param Item $targetItem
|
||||
*/
|
||||
public function __construct(Inventory $inventory, $slot, Item $sourceItem, Item $targetItem){
|
||||
public function __construct(Inventory $inventory, int $slot, Item $sourceItem, Item $targetItem){
|
||||
$this->inventory = $inventory;
|
||||
$this->slot = (int) $slot;
|
||||
$this->slot = $slot;
|
||||
$this->sourceItem = clone $sourceItem;
|
||||
$this->targetItem = clone $targetItem;
|
||||
$this->creationTime = microtime(true);
|
||||
}
|
||||
|
||||
public function getCreationTime(){
|
||||
public function getCreationTime() : float{
|
||||
return $this->creationTime;
|
||||
}
|
||||
|
||||
public function getInventory(){
|
||||
public function getInventory() : Inventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
public function getSlot(){
|
||||
public function getSlot() : int{
|
||||
return $this->slot;
|
||||
}
|
||||
|
||||
public function getSourceItem(){
|
||||
public function getSourceItem() : Item{
|
||||
return clone $this->sourceItem;
|
||||
}
|
||||
|
||||
public function getTargetItem(){
|
||||
public function getTargetItem() : Item{
|
||||
return clone $this->targetItem;
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ class CraftingInventory extends BaseInventory{
|
||||
return $this->resultInventory;
|
||||
}
|
||||
|
||||
public function getSize(){
|
||||
public function getSize() : int{
|
||||
return $this->getResultInventory()->getSize() + parent::getSize();
|
||||
}
|
||||
}
|
@ -160,14 +160,14 @@ class CraftingManager{
|
||||
/**
|
||||
* @return Recipe[]
|
||||
*/
|
||||
public function getRecipes(){
|
||||
public function getRecipes() : array{
|
||||
return $this->recipes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FurnaceRecipe[]
|
||||
*/
|
||||
public function getFurnaceRecipes(){
|
||||
public function getFurnaceRecipes() : array{
|
||||
return $this->furnaceRecipes;
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ class CraftingManager{
|
||||
* @param ShapelessRecipe $recipe
|
||||
* @return bool
|
||||
*/
|
||||
public function matchRecipe(ShapelessRecipe $recipe){
|
||||
public function matchRecipe(ShapelessRecipe $recipe) : bool{
|
||||
if(!isset($this->recipeLookup[$idx = $recipe->getResult()->getId() . ":" . $recipe->getResult()->getDamage()])){
|
||||
return false;
|
||||
}
|
||||
|
@ -50,19 +50,19 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
|
||||
return $this->left->getHolder();
|
||||
}
|
||||
|
||||
public function getItem($index){
|
||||
public function getItem(int $index) : Item{
|
||||
return $index < $this->left->getSize() ? $this->left->getItem($index) : $this->right->getItem($index - $this->right->getSize());
|
||||
}
|
||||
|
||||
public function setItem($index, Item $item){
|
||||
public function setItem(int $index, Item $item) : bool{
|
||||
return $index < $this->left->getSize() ? $this->left->setItem($index, $item) : $this->right->setItem($index - $this->right->getSize(), $item);
|
||||
}
|
||||
|
||||
public function clear($index){
|
||||
public function clear(int $index) : bool{
|
||||
return $index < $this->left->getSize() ? $this->left->clear($index) : $this->right->clear($index - $this->right->getSize());
|
||||
}
|
||||
|
||||
public function getContents(){
|
||||
public function getContents() : array{
|
||||
$contents = [];
|
||||
for($i = 0; $i < $this->getSize(); ++$i){
|
||||
$contents[$i] = $this->getItem($i);
|
||||
@ -129,14 +129,14 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
|
||||
/**
|
||||
* @return ChestInventory
|
||||
*/
|
||||
public function getLeftSide(){
|
||||
public function getLeftSide() : ChestInventory{
|
||||
return $this->left;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChestInventory
|
||||
*/
|
||||
public function getRightSide(){
|
||||
public function getRightSide() : ChestInventory{
|
||||
return $this->right;
|
||||
}
|
||||
}
|
||||
|
@ -41,21 +41,21 @@ class FurnaceInventory extends ContainerInventory{
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult(){
|
||||
public function getResult() : Item{
|
||||
return $this->getItem(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getFuel(){
|
||||
public function getFuel() : Item{
|
||||
return $this->getItem(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getSmelting(){
|
||||
public function getSmelting() : Item{
|
||||
return $this->getItem(0);
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class FurnaceInventory extends ContainerInventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setResult(Item $item){
|
||||
public function setResult(Item $item) : bool{
|
||||
return $this->setItem(2, $item);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ class FurnaceInventory extends ContainerInventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setFuel(Item $item){
|
||||
public function setFuel(Item $item) : bool{
|
||||
return $this->setItem(1, $item);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ class FurnaceInventory extends ContainerInventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setSmelting(Item $item){
|
||||
public function setSmelting(Item $item) : bool{
|
||||
return $this->setItem(0, $item);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\utils\UUID;
|
||||
|
||||
class FurnaceRecipe implements Recipe{
|
||||
|
||||
/** @var UUID|null */
|
||||
private $id = null;
|
||||
|
||||
/** @var Item */
|
||||
@ -46,10 +47,16 @@ class FurnaceRecipe implements Recipe{
|
||||
$this->ingredient = clone $ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UUID|null
|
||||
*/
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UUID $id
|
||||
*/
|
||||
public function setId(UUID $id){
|
||||
if($this->id !== null){
|
||||
throw new \InvalidStateException("Id is already set");
|
||||
@ -68,14 +75,14 @@ class FurnaceRecipe implements Recipe{
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getInput(){
|
||||
public function getInput() : Item{
|
||||
return clone $this->ingredient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult(){
|
||||
public function getResult() : Item{
|
||||
return clone $this->output;
|
||||
}
|
||||
|
||||
|
@ -32,37 +32,48 @@ use pocketmine\Player;
|
||||
interface Inventory{
|
||||
const MAX_STACK = 64;
|
||||
|
||||
public function getSize();
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() : int;
|
||||
|
||||
public function getMaxStackSize();
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxStackSize() : int;
|
||||
|
||||
/**
|
||||
* @param int $size
|
||||
*/
|
||||
public function setMaxStackSize($size);
|
||||
public function setMaxStackSize(int $size);
|
||||
|
||||
public function getName();
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string;
|
||||
|
||||
public function getTitle();
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() : string;
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getItem($index);
|
||||
public function getItem(int $index) : Item;
|
||||
|
||||
/**
|
||||
* Puts an Item in a slot.
|
||||
* If a plugin refuses the update or $index is invalid, it'll return false
|
||||
* If a source Player is specified, it won't send a Inventory update to it
|
||||
*
|
||||
* @param int $index
|
||||
* @param Item $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setItem($index, Item $item);
|
||||
public function setItem(int $index, Item $item) : bool;
|
||||
|
||||
/**
|
||||
* Stores the given Items in the inventory. This will try to fill
|
||||
@ -74,7 +85,7 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function addItem(Item ...$slots);
|
||||
public function addItem(Item ...$slots) : array;
|
||||
|
||||
/**
|
||||
* Checks if a given Item can be added to the inventory
|
||||
@ -83,7 +94,7 @@ interface Inventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canAddItem(Item $item);
|
||||
public function canAddItem(Item $item) : bool;
|
||||
|
||||
/**
|
||||
* Removes the given Item from the inventory.
|
||||
@ -93,12 +104,12 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function removeItem(Item ...$slots);
|
||||
public function removeItem(Item ...$slots) : array;
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getContents();
|
||||
public function getContents() : array;
|
||||
|
||||
/**
|
||||
* @param Item[] $items
|
||||
@ -124,7 +135,7 @@ interface Inventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function contains(Item $item);
|
||||
public function contains(Item $item) : bool;
|
||||
|
||||
/**
|
||||
* Will return all the Items that has the same id and metadata (if not null).
|
||||
@ -134,7 +145,7 @@ interface Inventory{
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
public function all(Item $item);
|
||||
public function all(Item $item) : array;
|
||||
|
||||
/**
|
||||
* Will return the first slot has the same id and metadata (if not null) as the Item.
|
||||
@ -144,14 +155,14 @@ interface Inventory{
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function first(Item $item);
|
||||
public function first(Item $item) : int;
|
||||
|
||||
/**
|
||||
* Returns the first empty slot, or -1 if not found
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function firstEmpty();
|
||||
public function firstEmpty() : int;
|
||||
|
||||
/**
|
||||
* Will remove all the Items that has the same id and metadata (if not null)
|
||||
@ -167,7 +178,7 @@ interface Inventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear($index);
|
||||
public function clear(int $index) : bool;
|
||||
|
||||
/**
|
||||
* Clears all the slots
|
||||
@ -180,12 +191,12 @@ interface Inventory{
|
||||
*
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getViewers();
|
||||
public function getViewers() : array;
|
||||
|
||||
/**
|
||||
* @return InventoryType
|
||||
*/
|
||||
public function getType();
|
||||
public function getType() : InventoryType;
|
||||
|
||||
/**
|
||||
* @return InventoryHolder
|
||||
@ -204,7 +215,7 @@ interface Inventory{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function open(Player $who);
|
||||
public function open(Player $who) : bool;
|
||||
|
||||
public function close(Player $who);
|
||||
|
||||
|
@ -91,21 +91,21 @@ class InventoryType{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultSize(){
|
||||
public function getDefaultSize() : int{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultTitle(){
|
||||
public function getDefaultTitle() : string{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNetworkType(){
|
||||
public function getNetworkType() : int{
|
||||
return $this->typeId;
|
||||
}
|
||||
}
|
@ -47,11 +47,11 @@ class PlayerInventory extends BaseInventory{
|
||||
parent::__construct($player, InventoryType::get(InventoryType::PLAYER));
|
||||
}
|
||||
|
||||
public function getSize(){
|
||||
public function getSize() : int{
|
||||
return parent::getSize() - 4; //Remove armor slots
|
||||
}
|
||||
|
||||
public function setSize($size){
|
||||
public function setSize(int $size){
|
||||
parent::setSize($size + 4);
|
||||
$this->sendContents($this->getViewers());
|
||||
}
|
||||
@ -316,7 +316,7 @@ class PlayerInventory extends BaseInventory{
|
||||
return $this->setItem($this->getSize() + 3, $boots);
|
||||
}
|
||||
|
||||
public function setItem($index, Item $item){
|
||||
public function setItem(int $index, Item $item) : bool{
|
||||
if($index < 0 or $index >= $this->size){
|
||||
return false;
|
||||
}elseif($item->getId() === 0 or $item->getCount() <= 0){
|
||||
@ -347,7 +347,7 @@ class PlayerInventory extends BaseInventory{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function clear($index){
|
||||
public function clear(int $index) : bool{
|
||||
if(isset($this->slots[$index])){
|
||||
$item = Item::get(Item::AIR, 0, 0);
|
||||
$old = $this->slots[$index];
|
||||
|
@ -31,14 +31,17 @@ interface Recipe{
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult();
|
||||
public function getResult() : Item;
|
||||
|
||||
public function registerToCraftingManager();
|
||||
|
||||
/**
|
||||
* @return UUID
|
||||
* @return UUID|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param UUID $id
|
||||
*/
|
||||
public function setId(UUID $id);
|
||||
}
|
@ -32,6 +32,7 @@ class ShapedRecipe implements Recipe{
|
||||
/** @var Item */
|
||||
private $output;
|
||||
|
||||
/** @var UUID|null */
|
||||
private $id = null;
|
||||
|
||||
/** @var string[] */
|
||||
@ -49,7 +50,7 @@ class ShapedRecipe implements Recipe{
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(Item $result, $height, $width){
|
||||
public function __construct(Item $result, int $height, int $width){
|
||||
for($h = 0; $h < $height; $h++){
|
||||
if($width === 0 or $width > 3){
|
||||
throw new \InvalidStateException("Crafting rows should be 1, 2, 3 wide, not $width");
|
||||
@ -60,18 +61,24 @@ class ShapedRecipe implements Recipe{
|
||||
$this->output = clone $result;
|
||||
}
|
||||
|
||||
public function getWidth(){
|
||||
public function getWidth() : int{
|
||||
return count($this->ingredients[0]);
|
||||
}
|
||||
|
||||
public function getHeight(){
|
||||
public function getHeight() : int{
|
||||
return count($this->ingredients);
|
||||
}
|
||||
|
||||
public function getResult(){
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult() : Item{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UUID|null
|
||||
*/
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
@ -84,7 +91,14 @@ class ShapedRecipe implements Recipe{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function addIngredient($x, $y, Item $item){
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param Item $item
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addIngredient(int $x, int $y, Item $item){
|
||||
$this->ingredients[$y][$x] = clone $item;
|
||||
return $this;
|
||||
}
|
||||
@ -96,7 +110,7 @@ class ShapedRecipe implements Recipe{
|
||||
* @return $this
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setIngredient($key, Item $item){
|
||||
public function setIngredient(string $key, Item $item){
|
||||
if(!array_key_exists($key, $this->shape)){
|
||||
throw new \Exception("Symbol does not appear in the shape: " . $key);
|
||||
}
|
||||
@ -106,7 +120,11 @@ class ShapedRecipe implements Recipe{
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function fixRecipe($key, $item){
|
||||
/**
|
||||
* @param string $key
|
||||
* @param Item $item
|
||||
*/
|
||||
protected function fixRecipe(string $key, Item $item){
|
||||
foreach($this->shapeItems[$key] as $entry){
|
||||
$this->ingredients[$entry->y][$entry->x] = clone $item;
|
||||
}
|
||||
@ -115,7 +133,7 @@ class ShapedRecipe implements Recipe{
|
||||
/**
|
||||
* @return Item[][]
|
||||
*/
|
||||
public function getIngredientMap(){
|
||||
public function getIngredientMap() : array{
|
||||
$ingredients = [];
|
||||
foreach($this->ingredients as $y => $row){
|
||||
$ingredients[$y] = [];
|
||||
@ -132,18 +150,19 @@ class ShapedRecipe implements Recipe{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $x
|
||||
* @param $y
|
||||
* @return null|Item
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getIngredient($x, $y){
|
||||
public function getIngredient(int $x, int $y) : Item{
|
||||
return $this->ingredients[$y][$x] ?? Item::get(Item::AIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getShape(){
|
||||
public function getShape() : array{
|
||||
return $this->shape;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ class ShapelessRecipe implements Recipe{
|
||||
/** @var Item */
|
||||
private $output;
|
||||
|
||||
/** @var UUID|null */
|
||||
private $id = null;
|
||||
|
||||
/** @var Item[] */
|
||||
@ -40,10 +41,16 @@ class ShapelessRecipe implements Recipe{
|
||||
$this->output = clone $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UUID|null
|
||||
*/
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UUID $id
|
||||
*/
|
||||
public function setId(UUID $id){
|
||||
if($this->id !== null){
|
||||
throw new \InvalidStateException("Id is already set");
|
||||
@ -52,18 +59,18 @@ class ShapelessRecipe implements Recipe{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getResult(){
|
||||
public function getResult() : Item{
|
||||
return clone $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
*
|
||||
* @returns ShapelessRecipe
|
||||
* @return ShapelessRecipe
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addIngredient(Item $item){
|
||||
public function addIngredient(Item $item) : ShapelessRecipe{
|
||||
if(count($this->ingredients) >= 9){
|
||||
throw new \InvalidArgumentException("Shapeless recipes cannot have more than 9 ingredients");
|
||||
}
|
||||
@ -101,7 +108,7 @@ class ShapelessRecipe implements Recipe{
|
||||
/**
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getIngredientList(){
|
||||
public function getIngredientList() : array{
|
||||
$ingredients = [];
|
||||
foreach($this->ingredients as $ingredient){
|
||||
$ingredients[] = clone $ingredient;
|
||||
@ -113,7 +120,7 @@ class ShapelessRecipe implements Recipe{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIngredientCount(){
|
||||
public function getIngredientCount() : int{
|
||||
$count = 0;
|
||||
foreach($this->ingredients as $ingredient){
|
||||
$count += $ingredient->getCount();
|
||||
|
@ -54,19 +54,25 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getSource(){
|
||||
public function getSource() : Player{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function getCreationTime(){
|
||||
public function getCreationTime() : float{
|
||||
return $this->creationTime;
|
||||
}
|
||||
|
||||
public function getInventories(){
|
||||
/**
|
||||
* @return Inventory[]
|
||||
*/
|
||||
public function getInventories() : array{
|
||||
return $this->inventories;
|
||||
}
|
||||
|
||||
public function getTransactions(){
|
||||
/**
|
||||
* @return Transaction[]
|
||||
*/
|
||||
public function getTransactions() : array{
|
||||
return $this->transactions;
|
||||
}
|
||||
|
||||
@ -93,7 +99,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function matchItems(array &$needItems, array &$haveItems){
|
||||
protected function matchItems(array &$needItems, array &$haveItems) : bool{
|
||||
foreach($this->transactions as $key => $ts){
|
||||
if($ts->getTargetItem()->getId() !== Item::AIR){
|
||||
$needItems[] = $ts->getTargetItem();
|
||||
@ -128,7 +134,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canExecute(){
|
||||
public function canExecute() : bool{
|
||||
$haveItems = [];
|
||||
$needItems = [];
|
||||
|
||||
@ -149,7 +155,10 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function execute(){
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function execute() : bool{
|
||||
if($this->hasExecuted() or !$this->canExecute()){
|
||||
return false;
|
||||
}
|
||||
@ -175,7 +184,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hasExecuted(){
|
||||
public function hasExecuted() : bool{
|
||||
return $this->hasExecuted;
|
||||
}
|
||||
}
|
@ -30,25 +30,25 @@ interface Transaction{
|
||||
/**
|
||||
* @return Inventory
|
||||
*/
|
||||
public function getInventory();
|
||||
public function getInventory() : Inventory;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSlot();
|
||||
public function getSlot() : int;
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getSourceItem();
|
||||
public function getSourceItem() : Item;
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getTargetItem();
|
||||
public function getTargetItem() : Item;
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getCreationTime();
|
||||
public function getCreationTime() : float;
|
||||
}
|
@ -28,17 +28,17 @@ interface TransactionGroup{
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getCreationTime();
|
||||
public function getCreationTime() : float;
|
||||
|
||||
/**
|
||||
* @return Transaction[]
|
||||
*/
|
||||
public function getTransactions();
|
||||
public function getTransactions() : array;
|
||||
|
||||
/**
|
||||
* @return Inventory[]
|
||||
*/
|
||||
public function getInventories();
|
||||
public function getInventories() : array;
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
@ -48,16 +48,16 @@ interface TransactionGroup{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canExecute();
|
||||
public function canExecute() : bool;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function execute();
|
||||
public function execute() : bool;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasExecuted();
|
||||
public function hasExecuted() : bool;
|
||||
|
||||
}
|
@ -106,7 +106,7 @@ class BaseLang{
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function translateString($str, array $params = [], $onlyPrefix = null){
|
||||
public function translateString(string $str, array $params = [], string $onlyPrefix = null) : string{
|
||||
$baseText = $this->get($str);
|
||||
$baseText = $this->parseTranslation(($baseText !== null and ($onlyPrefix === null or strpos($str, $onlyPrefix) === 0)) ? $baseText : $str, $onlyPrefix);
|
||||
|
||||
@ -152,7 +152,13 @@ class BaseLang{
|
||||
return $id;
|
||||
}
|
||||
|
||||
protected function parseTranslation($text, $onlyPrefix = null){
|
||||
/**
|
||||
* @param string $text
|
||||
* @param string|null $onlyPrefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function parseTranslation(string $text, string $onlyPrefix = null) : string{
|
||||
$newString = "";
|
||||
|
||||
$replaceString = null;
|
||||
|
@ -45,14 +45,14 @@ interface ChunkLoader{
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLoaderId();
|
||||
public function getLoaderId() : int;
|
||||
|
||||
/**
|
||||
* Returns if the chunk loader is currently active
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoaderActive();
|
||||
public function isLoaderActive() : bool;
|
||||
|
||||
/**
|
||||
* @return Position
|
||||
|
@ -130,7 +130,7 @@ interface ChunkManager{
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSeed();
|
||||
public function getSeed() : int;
|
||||
|
||||
/**
|
||||
* Returns the height of the world
|
||||
|
@ -63,7 +63,7 @@ class Explosion{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function explodeA(){
|
||||
public function explodeA() : bool{
|
||||
if($this->size < 0.1){
|
||||
return false;
|
||||
}
|
||||
@ -114,7 +114,7 @@ class Explosion{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function explodeB(){
|
||||
public function explodeB() : bool{
|
||||
$send = [];
|
||||
$updateBlocks = [];
|
||||
|
||||
|
@ -173,7 +173,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
/** @var Player[][] */
|
||||
private $playerLoaders = [];
|
||||
|
||||
/** @var DataPacket[] */
|
||||
/** @var DataPacket[][] */
|
||||
private $chunkPackets = [];
|
||||
|
||||
/** @var float[] */
|
||||
@ -292,7 +292,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public static function generateChunkLoaderId(ChunkLoader $loader) : int{
|
||||
if($loader->getLoaderId() === 0 or $loader->getLoaderId() === null){
|
||||
if($loader->getLoaderId() === 0){
|
||||
return self::$chunkLoaderCounter++;
|
||||
}else{
|
||||
throw new \InvalidStateException("ChunkLoader has a loader id already assigned: " . $loader->getLoaderId());
|
||||
@ -2774,9 +2774,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
/**
|
||||
* Gets the level seed
|
||||
*
|
||||
* @return int|string int value of seed, or the string numeric representation of a long in 32-bit systems
|
||||
* @return int
|
||||
*/
|
||||
public function getSeed(){
|
||||
public function getSeed() : int{
|
||||
return $this->provider->getSeed();
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Location extends Position{
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public static function fromObject(Vector3 $pos, Level $level = null, $yaw = 0.0, $pitch = 0.0){
|
||||
public static function fromObject(Vector3 $pos, Level $level = null, $yaw = 0.0, $pitch = 0.0) : Location{
|
||||
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, $level ?? (($pos instanceof Position) ? $pos->level : null));
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class Location extends Position{
|
||||
return "Location (level=" . ($this->isValid() ? $this->getLevel()->getName() : "null") . ", x=$this->x, y=$this->y, z=$this->z, yaw=$this->yaw, pitch=$this->pitch)";
|
||||
}
|
||||
|
||||
public function equals(Vector3 $v){
|
||||
public function equals(Vector3 $v) : bool{
|
||||
if($v instanceof Location){
|
||||
return parent::equals($v) and $v->yaw == $this->yaw and $v->pitch == $this->pitch;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class MovingObjectPosition{
|
||||
*
|
||||
* @return MovingObjectPosition
|
||||
*/
|
||||
public static function fromBlock($x, $y, $z, $side, Vector3 $hitVector){
|
||||
public static function fromBlock(int $x, int $y, int $z, int $side, Vector3 $hitVector) : MovingObjectPosition{
|
||||
$ob = new MovingObjectPosition;
|
||||
$ob->typeOfHit = 0;
|
||||
$ob->blockX = $x;
|
||||
@ -75,7 +75,7 @@ class MovingObjectPosition{
|
||||
*
|
||||
* @return MovingObjectPosition
|
||||
*/
|
||||
public static function fromEntity(Entity $entity){
|
||||
public static function fromEntity(Entity $entity) : MovingObjectPosition{
|
||||
$ob = new MovingObjectPosition;
|
||||
$ob->typeOfHit = 1;
|
||||
$ob->entityHit = $entity;
|
||||
|
@ -95,7 +95,7 @@ class Position extends Vector3{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(){
|
||||
public function isValid() : bool{
|
||||
return $this->getLevel() instanceof Level;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ class Position extends Vector3{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function equals(Vector3 $v){
|
||||
public function equals(Vector3 $v) : bool{
|
||||
if($v instanceof Position){
|
||||
return parent::equals($v) and $v->getLevel() === $this->getLevel();
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class SimpleChunkManager implements ChunkManager{
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSeed(){
|
||||
public function getSeed() : int{
|
||||
return $this->seed;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ namespace pocketmine\level\format;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\level\format\ChunkException;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -989,7 +988,7 @@ class Chunk{
|
||||
*
|
||||
* @return Chunk
|
||||
*/
|
||||
public static function fastDeserialize(string $data){
|
||||
public static function fastDeserialize(string $data) : Chunk{
|
||||
$stream = new BinaryStream();
|
||||
$stream->setBuffer($data);
|
||||
$data = null;
|
||||
|
@ -76,7 +76,7 @@ abstract class BaseLevelProvider implements LevelProvider{
|
||||
return $this->level->getServer();
|
||||
}
|
||||
|
||||
public function getLevel(){
|
||||
public function getLevel() : Level{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ interface LevelProvider{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
public function getName() : string;
|
||||
|
||||
/**
|
||||
* @return int|string int, or the string numeric representation of a long in 32-bit systems
|
||||
@ -216,7 +216,7 @@ interface LevelProvider{
|
||||
/**
|
||||
* @return Level
|
||||
*/
|
||||
public function getLevel();
|
||||
public function getLevel() : Level;
|
||||
|
||||
public function close();
|
||||
|
||||
|
@ -25,7 +25,6 @@ namespace pocketmine\level\format\io\leveldb;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\ChunkException;
|
||||
use pocketmine\level\format\io\BaseLevelProvider;
|
||||
use pocketmine\level\format\io\ChunkUtils;
|
||||
use pocketmine\level\format\io\exception\UnsupportedChunkFormatException;
|
||||
@ -576,7 +575,7 @@ class LevelDB extends BaseLevelProvider{
|
||||
/**
|
||||
* @return \LevelDB
|
||||
*/
|
||||
public function getDatabase(){
|
||||
public function getDatabase() : \LevelDB{
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
|
@ -422,7 +422,7 @@ class McRegion extends BaseLevelProvider{
|
||||
*
|
||||
* @return Chunk
|
||||
*/
|
||||
public function getEmptyChunk(int $chunkX, int $chunkZ){
|
||||
public function getEmptyChunk(int $chunkX, int $chunkZ) : Chunk{
|
||||
return Chunk::getEmptyChunk($chunkX, $chunkZ);
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,11 @@ class Flat extends Generator{
|
||||
private $populators = [];
|
||||
private $structure, $chunks, $options, $floorLevel, $preset;
|
||||
|
||||
public function getSettings(){
|
||||
public function getSettings() : array{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
public function getName() : string{
|
||||
return "flat";
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ class Flat extends Generator{
|
||||
*/
|
||||
}
|
||||
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
public function generateChunk(int $chunkX, int $chunkZ){
|
||||
if($this->chunk === null){
|
||||
if(isset($this->options["preset"]) and $this->options["preset"] != ""){
|
||||
$this->parsePreset($this->options["preset"], $chunkX, $chunkZ);
|
||||
@ -169,7 +169,7 @@ class Flat extends Generator{
|
||||
$this->level->setChunk($chunkX, $chunkZ, $chunk);
|
||||
}
|
||||
|
||||
public function populateChunk($chunkX, $chunkZ){
|
||||
public function populateChunk(int $chunkX, int $chunkZ){
|
||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
||||
foreach($this->populators as $populator){
|
||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||
@ -177,7 +177,7 @@ class Flat extends Generator{
|
||||
|
||||
}
|
||||
|
||||
public function getSpawn(){
|
||||
public function getSpawn() : Vector3{
|
||||
return new Vector3(128, $this->floorLevel, 128);
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,13 @@ namespace pocketmine\level\generator;
|
||||
use pocketmine\level\ChunkManager;
|
||||
use pocketmine\level\generator\noise\Noise;
|
||||
use pocketmine\level\generator\normal\Normal;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
abstract class Generator{
|
||||
private static $list = [];
|
||||
|
||||
public static function addGenerator($object, $name){
|
||||
public static function addGenerator($object, $name) : bool{
|
||||
if(is_subclass_of($object, Generator::class) and !isset(Generator::$list[$name = strtolower($name)])){
|
||||
Generator::$list[$name] = $object;
|
||||
|
||||
@ -47,7 +48,7 @@ abstract class Generator{
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getGeneratorList(){
|
||||
public static function getGeneratorList() : array{
|
||||
return array_keys(Generator::$list);
|
||||
}
|
||||
|
||||
@ -83,10 +84,8 @@ abstract class Generator{
|
||||
* @param int $z
|
||||
*
|
||||
* @return \SplFixedArray
|
||||
*
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise1D(Noise $noise, $xSize, $samplingRate, $x, $y, $z){
|
||||
public static function getFastNoise1D(Noise $noise, int $xSize, int $samplingRate, int $x, int $y, int $z) : \SplFixedArray{
|
||||
if($samplingRate === 0){
|
||||
throw new \InvalidArgumentException("samplingRate cannot be 0");
|
||||
}
|
||||
@ -120,11 +119,8 @@ abstract class Generator{
|
||||
* @param int $z
|
||||
*
|
||||
* @return \SplFixedArray
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){
|
||||
public static function getFastNoise2D(Noise $noise, int $xSize, int $zSize, int $samplingRate, int $x, int $y, int $z) : \SplFixedArray{
|
||||
assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0"));
|
||||
|
||||
assert($xSize % $samplingRate === 0, new \InvalidArgumentCountException("xSize % samplingRate must return 0"));
|
||||
@ -172,12 +168,9 @@ abstract class Generator{
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return \SplFixedArray
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \InvalidArgumentCountException
|
||||
* @return array
|
||||
*/
|
||||
public static function getFastNoise3D(Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){
|
||||
public static function getFastNoise3D(Noise $noise, int $xSize, int $ySize, int $zSize, int $xSamplingRate, int $ySamplingRate, int $zSamplingRate, int $x, int $y, int $z) : array{
|
||||
|
||||
assert($xSamplingRate !== 0, new \InvalidArgumentException("xSamplingRate cannot be 0"));
|
||||
assert($zSamplingRate !== 0, new \InvalidArgumentException("zSamplingRate cannot be 0"));
|
||||
@ -239,13 +232,13 @@ abstract class Generator{
|
||||
|
||||
abstract public function init(ChunkManager $level, Random $random);
|
||||
|
||||
abstract public function generateChunk($chunkX, $chunkZ);
|
||||
abstract public function generateChunk(int $chunkX, int $chunkZ);
|
||||
|
||||
abstract public function populateChunk($chunkX, $chunkZ);
|
||||
abstract public function populateChunk(int $chunkX, int $chunkZ);
|
||||
|
||||
abstract public function getSettings();
|
||||
abstract public function getSettings() : array;
|
||||
|
||||
abstract public function getName();
|
||||
abstract public function getName() : string;
|
||||
|
||||
abstract public function getSpawn();
|
||||
abstract public function getSpawn() : Vector3;
|
||||
}
|
||||
|
@ -70,7 +70,9 @@ abstract class Biome{
|
||||
/** @var Populator[] */
|
||||
private $populators = [];
|
||||
|
||||
/** @var int */
|
||||
private $minElevation;
|
||||
/** @var int */
|
||||
private $maxElevation;
|
||||
|
||||
private $groundCover = [];
|
||||
@ -78,9 +80,9 @@ abstract class Biome{
|
||||
protected $rainfall = 0.5;
|
||||
protected $temperature = 0.5;
|
||||
|
||||
protected static function register($id, Biome $biome){
|
||||
self::$biomes[(int) $id] = $biome;
|
||||
$biome->setId((int) $id);
|
||||
protected static function register(int $id, Biome $biome){
|
||||
self::$biomes[$id] = $biome;
|
||||
$biome->setId($id);
|
||||
}
|
||||
|
||||
public static function init(){
|
||||
@ -102,11 +104,11 @@ abstract class Biome{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Biome
|
||||
*/
|
||||
public static function getBiome($id){
|
||||
public static function getBiome(int $id) : Biome{
|
||||
return self::$biomes[$id] ?? self::$biomes[self::OCEAN];
|
||||
}
|
||||
|
||||
@ -118,38 +120,47 @@ abstract class Biome{
|
||||
$this->populators[] = $populator;
|
||||
}
|
||||
|
||||
public function populateChunk(ChunkManager $level, $chunkX, $chunkZ, Random $random){
|
||||
/**
|
||||
* @param ChunkManager $level
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Random $random
|
||||
*/
|
||||
public function populateChunk(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
foreach($this->populators as $populator){
|
||||
$populator->populate($level, $chunkX, $chunkZ, $random);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPopulators(){
|
||||
/**
|
||||
* @return Populator[]
|
||||
*/
|
||||
public function getPopulators() : array{
|
||||
return $this->populators;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
public function setId(int $id){
|
||||
if(!$this->registered){
|
||||
$this->registered = true;
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
public function getId() : int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
abstract public function getName();
|
||||
abstract public function getName() : string;
|
||||
|
||||
public function getMinElevation(){
|
||||
public function getMinElevation() : int{
|
||||
return $this->minElevation;
|
||||
}
|
||||
|
||||
public function getMaxElevation(){
|
||||
public function getMaxElevation() : int{
|
||||
return $this->maxElevation;
|
||||
}
|
||||
|
||||
public function setElevation($min, $max){
|
||||
public function setElevation(int $min, int $max){
|
||||
$this->minElevation = $min;
|
||||
$this->maxElevation = $max;
|
||||
}
|
||||
@ -157,7 +168,7 @@ abstract class Biome{
|
||||
/**
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getGroundCover(){
|
||||
public function getGroundCover() : array{
|
||||
return $this->groundCover;
|
||||
}
|
||||
|
||||
@ -168,11 +179,11 @@ abstract class Biome{
|
||||
$this->groundCover = $covers;
|
||||
}
|
||||
|
||||
public function getTemperature(){
|
||||
public function getTemperature() : float{
|
||||
return $this->temperature;
|
||||
}
|
||||
|
||||
public function getRainfall(){
|
||||
public function getRainfall() : float{
|
||||
return $this->rainfall;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user