diff --git a/src/pocketmine/CompatibleClassLoader.php b/src/pocketmine/CompatibleClassLoader.php index 42bbffec8..07a03e691 100644 --- a/src/pocketmine/CompatibleClassLoader.php +++ b/src/pocketmine/CompatibleClassLoader.php @@ -23,10 +23,4 @@ namespace pocketmine; class CompatibleClassLoader extends \BaseClassLoader{ - /** - * @deprecated - */ - public function add($namespace, $paths){ - $this->addPath(array_shift($paths)); - } } \ No newline at end of file diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index deb8e26ee..2a798057e 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -183,12 +183,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade protected $isCrafting = false; - /** - * @deprecated - * @var array - */ - public $loginData = []; - public $creationTime = 0; protected $randomClientId; @@ -885,11 +879,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return false; } - if(!isset($this->batchedPackets[$packet->getChannel()])){ - $this->batchedPackets[$packet->getChannel()] = []; - } - - $this->batchedPackets[$packet->getChannel()][] = clone $packet; + $this->batchedPackets[] = clone $packet; $timings->stopTiming(); return true; } @@ -1224,20 +1214,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return []; } - /** - * @deprecated - */ - public function addEntityMotion($entityId, $x, $y, $z){ - - } - - /** - * @deprecated - */ - public function addEntityMovement($entityId, $x, $y, $z, $yaw, $pitch, $headYaw = null){ - - } - public function setDataProperty($id, $type, $value){ if(parent::setDataProperty($id, $type, $value)){ $this->sendData($this, [$id => $this->dataProperties[$id]]); @@ -1562,9 +1538,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if(count($this->batchedPackets) > 0){ - foreach($this->batchedPackets as $channel => $list){ - $this->server->batchPackets([$this], $list, false, $channel); - } + $this->server->batchPackets([$this], $this->batchedPackets, false); $this->batchedPackets = []; } @@ -1833,7 +1807,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } $this->randomClientId = $packet->clientId; - $this->loginData = ["clientId" => $packet->clientId, "loginData" => null]; $this->uuid = $packet->clientUUID; $this->rawUUID = $this->uuid->toBinary(); diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 6925b1efa..7b28e05a3 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -86,9 +86,9 @@ namespace pocketmine { */ if(\Phar::running(true) !== ""){ - @define("pocketmine\\PATH", \Phar::running(true) . "/"); + @define('pocketmine\PATH', \Phar::running(true) . "/"); }else{ - @define("pocketmine\\PATH", \getcwd() . DIRECTORY_SEPARATOR); + @define('pocketmine\PATH', \getcwd() . DIRECTORY_SEPARATOR); } if(version_compare("7.0", PHP_VERSION) > 0){ @@ -126,16 +126,16 @@ namespace pocketmine { ini_set("default_charset", "utf-8"); ini_set("memory_limit", -1); - define("pocketmine\\START_TIME", microtime(true)); + define('pocketmine\START_TIME', microtime(true)); $opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]); - define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); - define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); + define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); + define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); Terminal::init(); - define("pocketmine\\ANSI", Terminal::hasFormattingCodes()); + define('pocketmine\ANSI', Terminal::hasFormattingCodes()); if(!file_exists(\pocketmine\DATA)){ mkdir(\pocketmine\DATA, 0777, true); @@ -379,8 +379,6 @@ namespace pocketmine { return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/"); } - set_error_handler([\ExceptionHandler::class, "handler"], -1); - $errors = 0; if(php_sapi_name() !== "cli"){ @@ -444,9 +442,9 @@ namespace pocketmine { } if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information! - define("pocketmine\\GIT_COMMIT", strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master")))); + define('pocketmine\GIT_COMMIT', strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master")))); }else{ //Unknown :( - define("pocketmine\\GIT_COMMIT", str_repeat("00", 20)); + define('pocketmine\GIT_COMMIT', str_repeat("00", 20)); } @define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN)); diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index de9adca9d..40f4b7405 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -117,7 +117,6 @@ use pocketmine\utils\ServerException; use pocketmine\utils\ServerKiller; use pocketmine\utils\Terminal; use pocketmine\utils\TextFormat; -use pocketmine\utils\TextWrapper; use pocketmine\utils\Utils; use pocketmine\utils\UUID; use pocketmine\utils\VersionString; @@ -363,13 +362,6 @@ class Server{ return $this->getConfigString("server-ip", "0.0.0.0"); } - /** - * @deprecated - */ - public function getServerName(){ - return $this->getConfigString("motd", "Minecraft: PE Server"); - } - public function getServerUniqueId(){ return $this->serverID; } @@ -659,56 +651,6 @@ class Server{ return round((array_sum($this->useAverage) / count($this->useAverage)) * 100, 2); } - - /** - * @deprecated - * - * @param $address - * @param int $timeout - */ - public function blockAddress($address, $timeout = 300){ - $this->network->blockAddress($address, $timeout); - } - - /** - * @deprecated - * - * @param $address - * @param $port - * @param $payload - */ - public function sendPacket($address, $port, $payload){ - $this->network->sendPacket($address, $port, $payload); - } - - /** - * @deprecated - * - * @return SourceInterface[] - */ - public function getInterfaces(){ - return $this->network->getInterfaces(); - } - - /** - * @deprecated - * - * @param SourceInterface $interface - */ - public function addInterface(SourceInterface $interface){ - $this->network->registerInterface($interface); - } - - /** - * @deprecated - * - * @param SourceInterface $interface - */ - public function removeInterface(SourceInterface $interface){ - $interface->shutdown(); - $this->network->unregisterInterface($interface); - } - /** * @return SimpleCommandMap */ @@ -1581,7 +1523,7 @@ class Server{ $this->setConfigInt("difficulty", 3); } - define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1)); + define('pocketmine\DEBUG', (int) $this->getProperty("debug.level", 1)); if($this->logger instanceof MainLogger){ $this->logger->setLogDebug(\pocketmine\DEBUG > 1); } @@ -1624,8 +1566,6 @@ class Server{ Effect::init(); Enchantment::init(); Attribute::init(); - /** TODO: @deprecated */ - TextWrapper::init(); $this->craftingManager = new CraftingManager(); $this->pluginManager = new PluginManager($this, $this->commandMap); @@ -1819,7 +1759,7 @@ class Server{ $packet->encode(); $packet->isEncoded = true; if(Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){ - Server::getInstance()->batchPackets($players, [$packet->buffer], false, $packet->getChannel()); + Server::getInstance()->batchPackets($players, [$packet->buffer], false); return; } @@ -1837,9 +1777,8 @@ class Server{ * @param Player[] $players * @param DataPacket[]|string $packets * @param bool $forceSync - * @param int $channel */ - public function batchPackets(array $players, array $packets, $forceSync = false, $channel = 0){ + public function batchPackets(array $players, array $packets, $forceSync = false){ Timings::$playerNetworkTimer->startTiming(); $str = ""; @@ -1862,10 +1801,10 @@ class Server{ } if(!$forceSync and $this->networkCompressionAsync){ - $task = new CompressBatchedTask($str, $targets, $this->networkCompressionLevel, $channel); + $task = new CompressBatchedTask($str, $targets, $this->networkCompressionLevel); $this->getScheduler()->scheduleAsyncTask($task); }else{ - $this->broadcastPacketsCallback(zlib_encode($str, ZLIB_ENCODING_DEFLATE, $this->networkCompressionLevel), $targets, $channel); + $this->broadcastPacketsCallback(zlib_encode($str, ZLIB_ENCODING_DEFLATE, $this->networkCompressionLevel), $targets); } Timings::$playerNetworkTimer->stopTiming(); @@ -1908,15 +1847,6 @@ class Server{ $this->pluginManager->enablePlugin($plugin); } - /** - * @param Plugin $plugin - * - * @deprecated - */ - public function loadPlugin(Plugin $plugin){ - $this->enablePlugin($plugin); - } - public function disablePlugins(){ $this->pluginManager->disablePlugins(); } @@ -1981,8 +1911,6 @@ class Server{ $this->reloadWhitelist(); $this->operators->reload(); - $this->memoryManager->doObjectCleanup(); - foreach($this->getIPBans()->getEntries() as $entry){ $this->getNetwork()->blockAddress($entry->getName(), -1); } @@ -2056,8 +1984,6 @@ class Server{ $this->network->unregisterInterface($interface); } - $this->memoryManager->doObjectCleanup(); - gc_collect_cycles(); }catch(\Throwable $e){ $this->logger->emergency("Crashed while crashing, killing process"); diff --git a/src/pocketmine/ThreadManager.php b/src/pocketmine/ThreadManager.php index fbe49a036..27851a098 100644 --- a/src/pocketmine/ThreadManager.php +++ b/src/pocketmine/ThreadManager.php @@ -21,7 +21,7 @@ namespace pocketmine; -class ThreadManager extends \Threaded{ +class ThreadManager extends \Volatile{ /** @var ThreadManager */ private static $instance = null; diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 833eab7cb..d94a751f7 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -279,32 +279,6 @@ class Block extends Position implements Metadatable{ /** @var AxisAlignedBB */ public $boundingBox = null; - /** - * Backwards-compatibility with old way to define block properties - * - * @deprecated - * - * @param string $key - * - * @return mixed - */ - public function __get($key){ - static $map = [ - "hardness" => "getHardness", - "lightLevel" => "getLightLevel", - "frictionFactor" => "getFrictionFactor", - "name" => "getName", - "isPlaceable" => "canBePlaced", - "isReplaceable" => "canBeReplaced", - "isTransparent" => "isTransparent", - "isSolid" => "isSolid", - "isFlowable" => "canBeFlowedInto", - "isActivable" => "canBeActivated", - "hasEntityCollision" => "hasEntityCollision" - ]; - return isset($map[$key]) ? $this->{$map[$key]}() : null; - } - public static function init(){ if(self::$list === null){ self::$list = new \SplFixedArray(256); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 173cf5140..b302f6220 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -555,13 +555,6 @@ abstract class Entity extends Location implements Metadatable{ } } - /** - * @deprecated - */ - public function sendMetadata($player){ - $this->sendData($player); - } - /** * @param Player[]|Player $player * @param array $data Properly formatted entity data, defaults to everything diff --git a/src/pocketmine/event/entity/EntityMoveEvent.php b/src/pocketmine/event/entity/EntityMoveEvent.php deleted file mode 100644 index 099c9a7a4..000000000 --- a/src/pocketmine/event/entity/EntityMoveEvent.php +++ /dev/null @@ -1,48 +0,0 @@ -entity = $entity; - $this->pos = $pos; - } - - public function getVector(){ - return $this->pos; - } - - -} \ No newline at end of file diff --git a/src/pocketmine/event/player/PlayerChatEvent.php b/src/pocketmine/event/player/PlayerChatEvent.php index c04cd5e66..4121a025d 100644 --- a/src/pocketmine/event/player/PlayerChatEvent.php +++ b/src/pocketmine/event/player/PlayerChatEvent.php @@ -46,13 +46,6 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ $this->player = $player; $this->message = $message; - //TODO: @deprecated (backwards-compativility) - $i = 0; - while(($pos = strpos($format, "%s")) !== false){ - $format = substr($format, 0, $pos) . "{%$i}" . substr($format, $pos + 2); - ++$i; - } - $this->format = $format; if($recipients === null){ @@ -84,13 +77,6 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ } public function setFormat($format){ - //TODO: @deprecated (backwards-compativility) - $i = 0; - while(($pos = strpos($format, "%s")) !== false){ - $format = substr($format, 0, $pos) . "{%$i}" . substr($format, $pos + 2); - ++$i; - } - $this->format = $format; } diff --git a/src/pocketmine/event/server/QueryRegenerateEvent.php b/src/pocketmine/event/server/QueryRegenerateEvent.php index 1f3028b35..9f8ac3b2c 100644 --- a/src/pocketmine/event/server/QueryRegenerateEvent.php +++ b/src/pocketmine/event/server/QueryRegenerateEvent.php @@ -53,7 +53,7 @@ class QueryRegenerateEvent extends ServerEvent{ public function __construct(Server $server, $timeout = 5){ $this->timeout = $timeout; - $this->serverName = $server->getServerName(); + $this->serverName = $server->getMotd(); $this->listPlugins = $server->getProperty("settings.query-plugins", true); $this->plugins = $server->getPluginManager()->getPlugins(); $this->players = []; diff --git a/src/pocketmine/level/ChunkManager.php b/src/pocketmine/level/ChunkManager.php index 124f259e5..b40dd9fcd 100644 --- a/src/pocketmine/level/ChunkManager.php +++ b/src/pocketmine/level/ChunkManager.php @@ -19,6 +19,8 @@ * */ +declare(strict_types=1); + namespace pocketmine\level; use pocketmine\level\format\FullChunk; @@ -33,7 +35,7 @@ interface ChunkManager{ * * @return int 0-255 */ - public function getBlockIdAt($x, $y, $z); + public function getBlockIdAt(int $x, int $y, int $z) : int; /** * Sets the raw block id. @@ -43,7 +45,7 @@ interface ChunkManager{ * @param int $z * @param int $id 0-255 */ - public function setBlockIdAt($x, $y, $z, $id); + public function setBlockIdAt(int $x, int $y, int $z, int $id); /** * Gets the raw block metadata @@ -54,7 +56,7 @@ interface ChunkManager{ * * @return int 0-15 */ - public function getBlockDataAt($x, $y, $z); + public function getBlockDataAt(int $x, int $y, int $z) : int; /** * Sets the raw block metadata. @@ -64,27 +66,27 @@ interface ChunkManager{ * @param int $z * @param int $data 0-15 */ - public function setBlockDataAt($x, $y, $z, $data); + public function setBlockDataAt(int $x, int $y, int $z, int $data); /** * @param int $chunkX * @param int $chunkZ * - * @return FullChunk + * @return FullChunk|null */ - public function getChunk($chunkX, $chunkZ); + public function getChunk(int $chunkX, int $chunkZ); /** * @param int $chunkX * @param int $chunkZ * @param FullChunk $chunk */ - public function setChunk($chunkX, $chunkZ, FullChunk $chunk = null); + public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null); /** * Gets the level seed * * @return int */ - public function getSeed(); + public function getSeed() : int; } \ No newline at end of file diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 706905804..0f060034f 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -63,18 +63,6 @@ class Explosion{ $this->what = $what; } - /** - * @deprecated - * @return bool - */ - public function explode(){ - if($this->explodeA()){ - return $this->explodeB(); - } - - return false; - } - /** * @return bool */ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index dc0a76e8d..f2f48f43c 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -19,6 +19,8 @@ * */ +declare(strict_types=1); + /** * All Level related classes are here, like Generators, Populators, Noise, ... */ @@ -266,23 +268,15 @@ class Level implements ChunkManager, Metadatable{ /** @var Generator */ private $generatorInstance; - /** - * Returns the chunk unique hash/key - * - * @param int $x - * @param int $z - * - * @return string - */ - public static function chunkHash($x, $z){ + public static function chunkHash(int $x, int $z){ return PHP_INT_SIZE === 8 ? (($x & 0xFFFFFFFF) << 32) | ($z & 0xFFFFFFFF) : $x . ":" . $z; } - public static function blockHash($x, $y, $z){ + public static function blockHash(int $x, int $y, int $z){ return PHP_INT_SIZE === 8 ? (($x & 0xFFFFFFF) << 35) | (($y & 0x7f) << 28) | ($z & 0xFFFFFFF) : $x . ":" . $y .":". $z; } - public static function chunkBlockHash($x, $y, $z){ + public static function chunkBlockHash(int $x, int $y, int $z) : int{ return ($x << 11) | ($z << 7) | $y; } @@ -310,7 +304,7 @@ class Level implements ChunkManager, Metadatable{ } } - public static function generateChunkLoaderId(ChunkLoader $loader){ + public static function generateChunkLoaderId(ChunkLoader $loader) : int{ if($loader->getLoaderId() === 0 or $loader->getLoaderId() === null or $loader->getLoaderId() === null){ return self::$chunkLoaderCounter++; }else{ @@ -328,7 +322,7 @@ class Level implements ChunkManager, Metadatable{ * * @throws \Exception */ - public function __construct(Server $server, $name, $path, $provider){ + public function __construct(Server $server, string $name, string $path, string $provider){ $this->blockStates = Block::$fullList; $this->levelId = static::$levelIdCounter++; $this->blockMetadata = new BlockMetadataStore($this); @@ -367,16 +361,16 @@ class Level implements ChunkManager, Metadatable{ $this->tickRate = 1; } - public function getTickRate(){ + public function getTickRate() : int{ return $this->tickRate; } - public function getTickRateTime(){ + public function getTickRateTime() : int{ return $this->tickRateTime; } - public function setTickRate($tickRate){ - $this->tickRate = (int) $tickRate; + public function setTickRate(int $tickRate){ + $this->tickRate = $tickRate; } public function initLevel(){ @@ -401,33 +395,22 @@ class Level implements ChunkManager, Metadatable{ } } - /** - * @return BlockMetadataStore - */ - public function getBlockMetadata(){ + public function getBlockMetadata() : BlockMetadataStore{ return $this->blockMetadata; } - /** - * @return Server - */ - public function getServer(){ + public function getServer() : Server{ return $this->server; } - /** - * @return LevelProvider - */ - final public function getProvider(){ + final public function getProvider() : LevelProvider{ return $this->provider; } /** * Returns the unique level identifier - * - * @return int */ - final public function getId(){ + final public function getId() : int{ return $this->levelId; } @@ -498,17 +481,11 @@ class Level implements ChunkManager, Metadatable{ } } - /** - * @return bool - */ - public function getAutoSave(){ + public function getAutoSave() : bool{ return $this->autoSave; } - /** - * @param bool $value - */ - public function setAutoSave($value){ + public function setAutoSave(bool $value){ $this->autoSave = $value; } @@ -519,7 +496,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function unload($force = false){ + public function unload(bool $force = false) : bool{ $ev = new LevelUnloadEvent($this); @@ -552,13 +529,6 @@ class Level implements ChunkManager, Metadatable{ return true; } - /** - * @deprecated Use Level->getChunkPlayers($chunkX, $chunkZ) - */ - public function getUsingChunk($chunkX, $chunkZ){ - return $this->getChunkPlayers($chunkX, $chunkZ); - } - /** * Gets the players being used in a specific chunk * @@ -567,7 +537,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Player[] */ - public function getChunkPlayers($chunkX, $chunkZ){ + public function getChunkPlayers(int $chunkX, int $chunkZ) : array{ return isset($this->playerLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->playerLoaders[$index] : []; } @@ -579,11 +549,11 @@ class Level implements ChunkManager, Metadatable{ * * @return ChunkLoader[] */ - public function getChunkLoaders($chunkX, $chunkZ){ + public function getChunkLoaders(int $chunkX, int $chunkZ) : array{ return isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunkLoaders[$index] : []; } - public function addChunkPacket($chunkX, $chunkZ, DataPacket $packet){ + public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){ if(!isset($this->chunkPackets[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->chunkPackets[$index] = [$packet]; }else{ @@ -591,7 +561,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function registerChunkLoader(ChunkLoader $loader, $chunkX, $chunkZ, $autoLoad = true){ + public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true){ $hash = $loader->getLoaderId(); if(!isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)])){ @@ -620,7 +590,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function unregisterChunkLoader(ChunkLoader $loader, $chunkX, $chunkZ){ + public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){ if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = $loader->getLoaderId()])){ unset($this->chunkLoaders[$index][$hash]); unset($this->playerLoaders[$index][$hash]); @@ -667,9 +637,8 @@ class Level implements ChunkManager, Metadatable{ * * @param int $currentTick * - * @return bool */ - public function doTick($currentTick){ + public function doTick(int $currentTick){ $this->timings->doTick->startTiming(); @@ -804,7 +773,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function sendBlockExtraData($x, $y, $z, $id, $data, array $targets = null){ + public function sendBlockExtraData(int $x, int $y, int $z, int $id, int $data, array $targets = null){ $pk = new LevelEventPacket; $pk->evid = LevelEventPacket::EVENT_SET_DATA; $pk->x = $x + 0.5; @@ -821,7 +790,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $flags * @param bool $optimizeRebuilds */ - public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, $optimizeRebuilds = false){ + public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){ $pk = new UpdateBlockPacket(); if($optimizeRebuilds){ @@ -862,7 +831,7 @@ class Level implements ChunkManager, Metadatable{ Server::broadcastPacket($target, $pk); } - public function clearCache($full = false){ + public function clearCache(bool $full = false){ if($full){ $this->chunkCache = []; $this->blockCache = []; @@ -879,7 +848,7 @@ class Level implements ChunkManager, Metadatable{ } - public function clearChunkCache($chunkX, $chunkZ){ + public function clearChunkCache(int $chunkX, int $chunkZ){ unset($this->chunkCache[Level::chunkHash($chunkX, $chunkZ)]); } @@ -983,7 +952,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function __debugInfo(){ + public function __debugInfo() : array{ return []; } @@ -992,7 +961,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function save($force = false){ + public function save(bool $force = false){ if(!$this->getAutoSave() and !$force){ return false; @@ -1058,7 +1027,7 @@ class Level implements ChunkManager, Metadatable{ * @param Vector3 $pos * @param int $delay */ - public function scheduleUpdate(Vector3 $pos, $delay){ + public function scheduleUpdate(Vector3 $pos, int $delay){ if(isset($this->updateQueueIndex[$index = Level::blockHash($pos->x, $pos->y, $pos->z)]) and $this->updateQueueIndex[$index] <= $delay){ return; } @@ -1072,7 +1041,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Block[] */ - public function getCollisionBlocks(AxisAlignedBB $bb, $targetFirst = false){ + public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{ $minX = Math::floorFloat($bb->minX); $minY = Math::floorFloat($bb->minY); $minZ = Math::floorFloat($bb->minZ); @@ -1115,7 +1084,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isFullBlock(Vector3 $pos){ + public function isFullBlock(Vector3 $pos) : bool{ if($pos instanceof Block){ if($pos->isSolid()){ return true; @@ -1135,7 +1104,7 @@ class Level implements ChunkManager, Metadatable{ * * @return AxisAlignedBB[] */ - public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, $entities = true){ + public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{ $minX = Math::floorFloat($bb->minX); $minY = Math::floorFloat($bb->minY); $minZ = Math::floorFloat($bb->minZ); @@ -1237,10 +1206,10 @@ class Level implements ChunkManager, Metadatable{ } */ - public function getFullLight(Vector3 $pos){ + public function getFullLight(Vector3 $pos) : int{ $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false); $level = 0; - if($chunk instanceof FullChunk){ + if($chunk !== null){ $level = $chunk->getBlockSkyLight($pos->x & 0x0f, $pos->y & 0x7f, $pos->z & 0x0f); //TODO: decrease light level by time of day if($level < 15){ @@ -1258,7 +1227,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int bitmap, (id << 4) | data */ - public function getFullBlock($x, $y, $z){ + public function getFullBlock(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, false)->getFullBlock($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -1270,7 +1239,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Block */ - public function getBlock(Vector3 $pos, $cached = true){ + public function getBlock(Vector3 $pos, $cached = true) : Block{ $index = Level::blockHash($pos->x, $pos->y, $pos->z); if($cached and isset($this->blockCache[$index])){ return $this->blockCache[$index]; @@ -1295,11 +1264,11 @@ class Level implements ChunkManager, Metadatable{ $this->updateBlockLight($pos->x, $pos->y, $pos->z); } - public function updateBlockSkyLight($x, $y, $z){ + public function updateBlockSkyLight(int $x, int $y, int $z){ //TODO } - public function updateBlockLight($x, $y, $z){ + public function updateBlockLight(int $x, int $y, int $z){ $lightPropagationQueue = new \SplQueue(); $lightRemovalQueue = new \SplQueue(); $visited = []; @@ -1351,7 +1320,7 @@ class Level implements ChunkManager, Metadatable{ } } - private function computeRemoveBlockLight($x, $y, $z, $currentLight, \SplQueue $queue, \SplQueue $spreadQueue, array &$visited, array &$spreadVisited){ + private function computeRemoveBlockLight(int $x, int $y, int $z, int $currentLight, \SplQueue $queue, \SplQueue $spreadQueue, array &$visited, array &$spreadVisited){ $current = $this->getBlockLightAt($x, $y, $z); if($current !== 0 and $current < $currentLight){ @@ -1371,7 +1340,7 @@ class Level implements ChunkManager, Metadatable{ } } - private function computeSpreadBlockLight($x, $y, $z, $currentLight, \SplQueue $queue, array &$visited){ + private function computeSpreadBlockLight(int $x, int $y, int $z, int $currentLight, \SplQueue $queue, array &$visited){ $current = $this->getBlockLightAt($x, $y, $z); if($current < $currentLight){ @@ -1404,7 +1373,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool Whether the block has been updated or not */ - public function setBlock(Vector3 $pos, Block $block, $direct = false, $update = true){ + public function setBlock(Vector3 $pos, Block $block, bool $direct = false, bool $update = true) : bool{ if($pos->y < 0 or $pos->y >= 128){ return false; } @@ -1460,7 +1429,7 @@ class Level implements ChunkManager, Metadatable{ * @param Vector3 $motion * @param int $delay */ - public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, $delay = 10){ + public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, int $delay = 10){ $motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion; $itemTag = NBT::putItemHelper($item); $itemTag->setName("Item"); @@ -1500,9 +1469,9 @@ class Level implements ChunkManager, Metadatable{ * @param Player $player * @param bool $createParticles * - * @return boolean + * @return boole */ - public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, $createParticles = false){ + public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, bool $createParticles = false) : bool{ $target = $this->getBlock($vector); //TODO: Adventure mode checks @@ -1640,9 +1609,9 @@ class Level implements ChunkManager, Metadatable{ * @param float $fz default 0.0 * @param Player $player default null * - * @return boolean + * @return bool */ - public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null){ + public function useItemOn(Vector3 $vector, Item &$item, int $face, float $fx = 0.0, float $fy = 0.0, float $fz = 0.0, Player $player = null) : bool{ $target = $this->getBlock($vector); $block = $target->getSide($face); @@ -1805,7 +1774,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity */ - public function getEntity($entityId){ + public function getEntity(int $entityId){ return isset($this->entities[$entityId]) ? $this->entities[$entityId] : null; } @@ -1814,7 +1783,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getEntities(){ + public function getEntities() : array{ return $this->entities; } @@ -1826,7 +1795,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null){ + public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null) : array{ $nearby = []; if($entity === null or $entity->canCollide){ @@ -1857,7 +1826,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getNearbyEntities(AxisAlignedBB $bb, Entity $entity = null){ + public function getNearbyEntities(AxisAlignedBB $bb, Entity $entity = null) : array{ $nearby = []; $minX = Math::floorFloat(($bb->minX - 2) / 16); @@ -1883,7 +1852,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile[] */ - public function getTiles(){ + public function getTiles() : array{ return $this->tiles; } @@ -1892,7 +1861,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile */ - public function getTileById($tileId){ + public function getTileById(int $tileId){ return isset($this->tiles[$tileId]) ? $this->tiles[$tileId] : null; } @@ -1901,14 +1870,14 @@ class Level implements ChunkManager, Metadatable{ * * @return Player[] */ - public function getPlayers(){ + public function getPlayers() : array{ return $this->players; } /** * @return ChunkLoader[] */ - public function getLoaders(){ + public function getLoaders() : array{ return $this->loaders; } @@ -1937,7 +1906,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getChunkEntities($X, $Z){ + public function getChunkEntities($X, $Z) : array{ return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getEntities() : []; } @@ -1949,7 +1918,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile[] */ - public function getChunkTiles($X, $Z){ + public function getChunkTiles($X, $Z) : array{ return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getTiles() : []; } @@ -1962,7 +1931,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-255 */ - public function getBlockIdAt($x, $y, $z){ + public function getBlockIdAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockId($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -1974,7 +1943,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $id 0-255 */ - public function setBlockIdAt($x, $y, $z, $id){ + public function setBlockIdAt(int $x, int $y, int $z, int $id){ unset($this->blockCache[Level::blockHash($x, $y, $z)]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y & 0x7f, $z & 0x0f, $id & 0xff); @@ -1996,7 +1965,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 16-bit */ - public function getBlockExtraDataAt($x, $y, $z){ + public function getBlockExtraDataAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockExtraData($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2009,7 +1978,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $id * @param int $data */ - public function setBlockExtraDataAt($x, $y, $z, $id, $data){ + public function setBlockExtraDataAt(int $x, int $y, int $z, int $id, int $data){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockExtraData($x & 0x0f, $y & 0x7f, $z & 0x0f, ($data << 8) | $id); $this->sendBlockExtraData($x, $y, $z, $id, $data); @@ -2024,7 +1993,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-15 */ - public function getBlockDataAt($x, $y, $z){ + public function getBlockDataAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockData($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2036,7 +2005,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $data 0-15 */ - public function setBlockDataAt($x, $y, $z, $data){ + public function setBlockDataAt(int $x, int $y, int $z, int $data){ unset($this->blockCache[Level::blockHash($x, $y, $z)]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y & 0x7f, $z & 0x0f, $data & 0x0f); @@ -2058,7 +2027,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-15 */ - public function getBlockSkyLightAt($x, $y, $z){ + public function getBlockSkyLightAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockSkyLight($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2070,7 +2039,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $level 0-15 */ - public function setBlockSkyLightAt($x, $y, $z, $level){ + public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockSkyLight($x & 0x0f, $y & 0x7f, $z & 0x0f, $level & 0x0f); } @@ -2083,7 +2052,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-15 */ - public function getBlockLightAt($x, $y, $z){ + public function getBlockLightAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockLight($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2095,7 +2064,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $level 0-15 */ - public function setBlockLightAt($x, $y, $z, $level){ + public function setBlockLightAt(int $x, int $y, int $z, int $level){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockLight($x & 0x0f, $y & 0x7f, $z & 0x0f, $level & 0x0f); } @@ -2105,7 +2074,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int */ - public function getBiomeId($x, $z){ + public function getBiomeId(int $x, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBiomeId($x & 0x0f, $z & 0x0f); } @@ -2115,7 +2084,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int[] */ - public function getBiomeColor($x, $z){ + public function getBiomeColor(int $x, int $z) : array{ return $this->getChunk($x >> 4, $z >> 4, true)->getBiomeColor($x & 0x0f, $z & 0x0f); } @@ -2125,7 +2094,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int */ - public function getHeightMap($x, $z){ + public function getHeightMap(int $x, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getHeightMap($x & 0x0f, $z & 0x0f); } @@ -2134,7 +2103,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $biomeId */ - public function setBiomeId($x, $z, $biomeId){ + public function setBiomeId(int $x, int $z, int $biomeId){ $this->getChunk($x >> 4, $z >> 4, true)->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId); } @@ -2145,7 +2114,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $G * @param int $B */ - public function setBiomeColor($x, $z, $R, $G, $B){ + public function setBiomeColor(int $x, int $z, int $R, int $G, int $B){ $this->getChunk($x >> 4, $z >> 4, true)->setBiomeColor($x & 0x0f, $z & 0x0f, $R, $G, $B); } @@ -2154,14 +2123,14 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $value */ - public function setHeightMap($x, $z, $value){ + public function setHeightMap(int $x, int $z, int $value){ $this->getChunk($x >> 4, $z >> 4, true)->setHeightMap($x & 0x0f, $z & 0x0f, $value); } /** * @return FullChunk[]|Chunk[] */ - public function getChunks(){ + public function getChunks() : array{ return $this->chunks; } @@ -2174,7 +2143,7 @@ class Level implements ChunkManager, Metadatable{ * * @return FullChunk|Chunk */ - public function getChunk($x, $z, $create = false){ + public function getChunk(int $x, int $z, bool $create = false){ if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){ return $this->chunks[$index]; }elseif($this->loadChunk($x, $z, $create)){ @@ -2184,20 +2153,7 @@ class Level implements ChunkManager, Metadatable{ return null; } - /** - * @param int $x - * @param int $z - * @param bool $create - * - * @return FullChunk|Chunk - * - * @deprecated - */ - public function getChunkAt($x, $z, $create = false){ - return $this->getChunk($x, $z, $create); - } - - public function generateChunkCallback($x, $z, FullChunk $chunk){ + public function generateChunkCallback(int $x, int $z, FullChunk $chunk){ Timings::$generationCallbackTimer->startTiming(); if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)])){ $oldChunk = $this->getChunk($x, $z, false); @@ -2235,7 +2191,7 @@ class Level implements ChunkManager, Metadatable{ * @param FullChunk $chunk * @param bool $unload */ - public function setChunk($chunkX, $chunkZ, FullChunk $chunk = null, $unload = true){ + public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null, bool $unload = true){ if($chunk === null){ return; } @@ -2284,7 +2240,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-127 */ - public function getHighestBlockAt($x, $z){ + public function getHighestBlockAt(int $x, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getHighestBlockAt($x & 0x0f, $z & 0x0f); } @@ -2294,7 +2250,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkLoaded($x, $z){ + public function isChunkLoaded(int $x, int $z) : bool{ return isset($this->chunks[Level::chunkHash($x, $z)]) or $this->provider->isChunkLoaded($x, $z); } @@ -2304,7 +2260,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkGenerated($x, $z){ + public function isChunkGenerated(int $x, int $z) : bool{ $chunk = $this->getChunk($x, $z); return $chunk !== null ? $chunk->isGenerated() : false; } @@ -2315,7 +2271,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkPopulated($x, $z){ + public function isChunkPopulated(int $x, int $z) : bool{ $chunk = $this->getChunk($x, $z); return $chunk !== null ? $chunk->isPopulated() : false; } @@ -2325,7 +2281,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Position */ - public function getSpawnLocation(){ + public function getSpawnLocation() : Position{ return Position::fromObject($this->provider->getSpawn(), $this); } @@ -2340,7 +2296,7 @@ class Level implements ChunkManager, Metadatable{ $this->server->getPluginManager()->callEvent(new SpawnChangeEvent($this, $previousSpawn)); } - public function requestChunk($x, $z, Player $player){ + public function requestChunk(int $x, int $z, Player $player){ $index = Level::chunkHash($x, $z); if(!isset($this->chunkSendQueue[$index])){ $this->chunkSendQueue[$index] = []; @@ -2349,7 +2305,7 @@ class Level implements ChunkManager, Metadatable{ $this->chunkSendQueue[$index][$player->getLoaderId()] = $player; } - private function sendChunkFromCache($x, $z){ + private function sendChunkFromCache(int $x, int $z){ if(isset($this->chunkSendTasks[$index = Level::chunkHash($x, $z)])){ foreach($this->chunkSendQueue[$index] as $player){ /** @var Player $player */ @@ -2390,7 +2346,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function chunkRequestCallback($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS){ + public function chunkRequestCallback(int $x, int $z, string $payload, int $ordering = FullChunkDataPacket::ORDER_COLUMNS){ $this->timings->syncChunkSendTimer->startTiming(); $index = Level::chunkHash($x, $z); @@ -2487,7 +2443,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkInUse($x, $z){ + public function isChunkInUse(int $x, int $z) : bool{ return isset($this->chunkLoaders[$index = Level::chunkHash($x, $z)]) and count($this->chunkLoaders[$index]) > 0; } @@ -2498,7 +2454,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function loadChunk($x, $z, $generate = true){ + public function loadChunk(int $x, int $z, bool $generate = true) : bool{ if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){ return true; } @@ -2543,12 +2499,12 @@ class Level implements ChunkManager, Metadatable{ return true; } - private function queueUnloadChunk($x, $z){ + private function queueUnloadChunk(int $x, int $z){ $this->unloadQueue[$index = Level::chunkHash($x, $z)] = microtime(true); unset($this->chunkTickList[$index]); } - public function unloadChunkRequest($x, $z, $safe = true){ + public function unloadChunkRequest(int $x, int $z, bool $safe = true){ if(($safe === true and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){ return false; } @@ -2558,11 +2514,11 @@ class Level implements ChunkManager, Metadatable{ return true; } - public function cancelUnloadChunkRequest($x, $z){ + public function cancelUnloadChunkRequest(int $x, int $z){ unset($this->unloadQueue[Level::chunkHash($x, $z)]); } - public function unloadChunk($x, $z, $safe = true, $trySave = true){ + public function unloadChunk(int $x, int $z, bool $safe = true, bool $trySave = true) : bool{ if(($safe === true and $this->isChunkInUse($x, $z))){ return false; } @@ -2632,23 +2588,13 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isSpawnChunk($X, $Z){ + public function isSpawnChunk(int $X, int $Z) : bool{ $spawnX = $this->provider->getSpawn()->getX() >> 4; $spawnZ = $this->provider->getSpawn()->getZ() >> 4; return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1; } - /** - * Returns the raw spawnpoint - * - * @deprecated - * @return Position - */ - public function getSpawn(){ - return $this->getSpawnLocation(); - } - /** * @param Vector3 $spawn default null * @@ -2702,23 +2648,12 @@ class Level implements ChunkManager, Metadatable{ return false; } - /** - * Sets the spawnpoint - * - * @param Vector3 $pos - * - * @deprecated - */ - public function setSpawn(Vector3 $pos){ - $this->setSpawnLocation($pos); - } - /** * Gets the current time * * @return int */ - public function getTime(){ + public function getTime() : int{ return (int) $this->time; } @@ -2727,7 +2662,7 @@ class Level implements ChunkManager, Metadatable{ * * @return string */ - public function getName(){ + public function getName() : string{ return $this->provider->getName(); } @@ -2736,7 +2671,7 @@ class Level implements ChunkManager, Metadatable{ * * @return string */ - public function getFolderName(){ + public function getFolderName() : string{ return $this->folderName; } @@ -2745,8 +2680,8 @@ class Level implements ChunkManager, Metadatable{ * * @param int $time */ - public function setTime($time){ - $this->time = (int) $time; + public function setTime(int $time){ + $this->time = $time; $this->sendTime(); } @@ -2771,7 +2706,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int */ - public function getSeed(){ + public function getSeed() : int{ return $this->provider->getSeed(); } @@ -2780,12 +2715,12 @@ class Level implements ChunkManager, Metadatable{ * * @param int $seed */ - public function setSeed($seed){ + public function setSeed(int $seed){ $this->provider->setSeed($seed); } - public function populateChunk($x, $z, $force = false){ + public function populateChunk(int $x, int $z, bool $force = false) : bool{ if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)]) or (count($this->chunkPopulationQueue) >= $this->chunkPopulationQueueSize and !$force)){ return false; } @@ -2823,7 +2758,7 @@ class Level implements ChunkManager, Metadatable{ return true; } - public function generateChunk($x, $z, $force = false){ + public function generateChunk(int $x, int $z, bool $force = false){ if(count($this->chunkGenerationQueue) >= $this->chunkGenerationQueueSize and !$force){ return; } @@ -2837,7 +2772,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function regenerateChunk($x, $z){ + public function regenerateChunk(int $x, int $z){ $this->unloadChunk($x, $z, false); $this->cancelUnloadChunkRequest($x, $z); @@ -2872,7 +2807,7 @@ class Level implements ChunkManager, Metadatable{ $this->timings->doChunkGC->stopTiming(); } - public function unloadChunks($force = false){ + public function unloadChunks(bool $force = false){ if(count($this->unloadQueue) > 0){ $maxUnload = 96; $now = microtime(true); @@ -2912,14 +2847,14 @@ class Level implements ChunkManager, Metadatable{ $this->server->getLevelMetadata()->removeMetadata($this, $metadataKey, $plugin); } - public function addEntityMotion($chunkX, $chunkZ, $entityId, $x, $y, $z){ + public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){ if(!isset($this->motionToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->motionToSend[$index] = []; } $this->motionToSend[$index][$entityId] = [$entityId, $x, $y, $z]; } - public function addEntityMovement($chunkX, $chunkZ, $entityId, $x, $y, $z, $yaw, $pitch, $headYaw = null){ + public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){ if(!isset($this->moveToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->moveToSend[$index] = []; } diff --git a/src/pocketmine/level/Position.php b/src/pocketmine/level/Position.php index d06061328..05c323a9a 100644 --- a/src/pocketmine/level/Position.php +++ b/src/pocketmine/level/Position.php @@ -67,30 +67,6 @@ class Position extends Vector3{ return $this->level !== null; } - /** - * Marks the level reference as strong so it won't be collected - * by the garbage collector. - * - * @deprecated - * - * @return bool - */ - public function setStrong(){ - return false; - } - - /** - * Marks the level reference as weak so it won't have effect against - * the garbage collector decision. - * - * @deprecated - * - * @return bool - */ - public function setWeak(){ - return false; - } - /** * Returns a side Vector * diff --git a/src/pocketmine/level/SimpleChunkManager.php b/src/pocketmine/level/SimpleChunkManager.php index bd480e9dd..136ab9ed1 100644 --- a/src/pocketmine/level/SimpleChunkManager.php +++ b/src/pocketmine/level/SimpleChunkManager.php @@ -19,6 +19,8 @@ * */ +declare(strict_types=1); + namespace pocketmine\level; use pocketmine\level\format\FullChunk; @@ -43,7 +45,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int 0-255 */ - public function getBlockIdAt($x, $y, $z){ + public function getBlockIdAt(int $x, int $y, int $z) : int{ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ return $chunk->getBlockId($x & 0xf, $y & 0x7f, $z & 0xf); } @@ -58,7 +60,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $z * @param int $id 0-255 */ - public function setBlockIdAt($x, $y, $z, $id){ + public function setBlockIdAt(int $x, int $y, int $z, int $id){ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ $chunk->setBlockId($x & 0xf, $y & 0x7f, $z & 0xf, $id); } @@ -73,7 +75,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int 0-15 */ - public function getBlockDataAt($x, $y, $z){ + public function getBlockDataAt(int $x, int $y, int $z) : int{ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ return $chunk->getBlockData($x & 0xf, $y & 0x7f, $z & 0xf); } @@ -88,7 +90,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $z * @param int $data 0-15 */ - public function setBlockDataAt($x, $y, $z, $data){ + public function setBlockDataAt(int $x, int $y, int $z, int $data){ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ $chunk->setBlockData($x & 0xf, $y & 0x7f, $z & 0xf, $data); } @@ -98,9 +100,9 @@ class SimpleChunkManager implements ChunkManager{ * @param int $chunkX * @param int $chunkZ * - * @return FullChunk + * @return FullChunk|null */ - public function getChunk($chunkX, $chunkZ){ + public function getChunk(int $chunkX, int $chunkZ){ return isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunks[$index] : null; } @@ -109,7 +111,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $chunkZ * @param FullChunk $chunk */ - public function setChunk($chunkX, $chunkZ, FullChunk $chunk = null){ + public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null){ if($chunk === null){ unset($this->chunks[Level::chunkHash($chunkX, $chunkZ)]); return; @@ -126,7 +128,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int */ - public function getSeed(){ + public function getSeed() : int{ return $this->seed; } } \ No newline at end of file diff --git a/src/pocketmine/level/format/ChunkSection.php b/src/pocketmine/level/format/ChunkSection.php index 9de459921..130032bc0 100644 --- a/src/pocketmine/level/format/ChunkSection.php +++ b/src/pocketmine/level/format/ChunkSection.php @@ -62,19 +62,6 @@ interface ChunkSection{ */ public function setBlockData($x, $y, $z, $data); - /** - * Modifies $blockId and $meta - * - * @deprecated - * - * @param int $x 0-15 - * @param int $y 0-15 - * @param int $z 0-15 - * @param int &$blockId - * @param int &$meta - */ - public function getBlock($x, $y, $z, &$blockId, &$meta = null); - /** * Gets block and meta in one go * diff --git a/src/pocketmine/level/format/FullChunk.php b/src/pocketmine/level/format/FullChunk.php index 783a939ff..d5f3e155a 100644 --- a/src/pocketmine/level/format/FullChunk.php +++ b/src/pocketmine/level/format/FullChunk.php @@ -50,20 +50,6 @@ interface FullChunk{ */ public function setProvider(LevelProvider $provider); - - /** - * Modifies $blockId and $meta - * - * @deprecated - * - * @param int $x 0-15 - * @param int $y 0-127 - * @param int $z 0-15 - * @param int &$blockId - * @param int &$meta - */ - public function getBlock($x, $y, $z, &$blockId, &$meta = null); - /** * Gets block and meta in one go * diff --git a/src/pocketmine/level/format/anvil/ChunkSection.php b/src/pocketmine/level/format/anvil/ChunkSection.php index b1c8731f9..872fab017 100644 --- a/src/pocketmine/level/format/anvil/ChunkSection.php +++ b/src/pocketmine/level/format/anvil/ChunkSection.php @@ -70,12 +70,6 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{ } } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->getFullBlock($x, $y, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function getFullBlock($x, $y, $z){ $i = ($y << 8) + ($z << 4) + $x; if(($x & 1) === 0){ diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index 0baab47f1..25ecfd3ac 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -77,12 +77,6 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->NBTentities = $entities; } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->sections[$y >> 4]->getFullBlock($x, $y & 0x0f, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function getFullBlock($x, $y, $z){ return $this->sections[$y >> 4]->getFullBlock($x, $y & 0x0f, $z); } diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index d1d89bf12..9403656e4 100644 --- a/src/pocketmine/level/format/generic/BaseFullChunk.php +++ b/src/pocketmine/level/format/generic/BaseFullChunk.php @@ -203,15 +203,6 @@ abstract class BaseFullChunk implements FullChunk{ $this->z = $z; } - /** - * @return LevelProvider - * - * @deprecated - */ - public function getLevel(){ - return $this->getProvider(); - } - /** * @return LevelProvider */ diff --git a/src/pocketmine/level/format/leveldb/Chunk.php b/src/pocketmine/level/format/leveldb/Chunk.php index 9716605d0..0e4635091 100644 --- a/src/pocketmine/level/format/leveldb/Chunk.php +++ b/src/pocketmine/level/format/leveldb/Chunk.php @@ -101,12 +101,6 @@ class Chunk extends BaseFullChunk{ } } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->getFullBlock($x, $y, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function setBlock($x, $y, $z, $blockId = null, $meta = null){ $i = ($x << 11) | ($z << 7) | $y; diff --git a/src/pocketmine/level/format/mcregion/Chunk.php b/src/pocketmine/level/format/mcregion/Chunk.php index af8273adc..b97b30c83 100644 --- a/src/pocketmine/level/format/mcregion/Chunk.php +++ b/src/pocketmine/level/format/mcregion/Chunk.php @@ -155,12 +155,6 @@ class Chunk extends BaseFullChunk{ } } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->getFullBlock($x, $y, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function setBlock($x, $y, $z, $blockId = null, $meta = null){ $i = ($x << 11) | ($z << 7) | $y; diff --git a/src/pocketmine/network/CompressBatchedTask.php b/src/pocketmine/network/CompressBatchedTask.php index 66f546295..e2e68ca7b 100644 --- a/src/pocketmine/network/CompressBatchedTask.php +++ b/src/pocketmine/network/CompressBatchedTask.php @@ -29,14 +29,12 @@ class CompressBatchedTask extends AsyncTask{ public $level = 7; public $data; public $final; - public $channel = 0; public $targets = []; - public function __construct($data, array $targets, $level = 7, $channel = 0){ + public function __construct($data, array $targets, $level = 7){ $this->data = $data; $this->targets = $targets; $this->level = $level; - $this->channel = $channel; } public function onRun(){ diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 05da01ed3..5a6b6f38f 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -84,25 +84,6 @@ class Network{ public static $BATCH_THRESHOLD = 512; - /** @deprecated */ - const CHANNEL_NONE = 0; - /** @deprecated */ - const CHANNEL_PRIORITY = 1; //Priority channel, only to be used when it matters - /** @deprecated */ - const CHANNEL_WORLD_CHUNKS = 2; //Chunk sending - /** @deprecated */ - const CHANNEL_MOVEMENT = 3; //Movement sending - /** @deprecated */ - const CHANNEL_BLOCKS = 4; //Block updates or explosions - /** @deprecated */ - const CHANNEL_WORLD_EVENTS = 5; //Entity, level or tile entity events - /** @deprecated */ - const CHANNEL_ENTITY_SPAWNING = 6; //Entity spawn/despawn channel - /** @deprecated */ - const CHANNEL_TEXT = 7; //Chat and other text stuff - /** @deprecated */ - const CHANNEL_END = 31; - /** @var \SplFixedArray */ private $packetPool; diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index ae98c7f12..d4907ad10 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -64,10 +64,6 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->rakLib = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp()); $this->interface = new ServerHandler($this->rakLib, $this); - - for($i = 0; $i < 256; ++$i){ - $this->channelCounts[$i] = 0; - } } public function setNetwork(Network $network){ @@ -83,9 +79,9 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } if($this->rakLib->isTerminated()){ - $info = $this->rakLib->getTerminationInfo(); $this->network->unregisterInterface($this); - \ExceptionHandler::handler(E_ERROR, "RakLib Thread crashed [".$info["scope"]."]: " . (isset($info["message"]) ? $info["message"] : ""), $info["file"], $info["line"]); + + throw new \Exception("RakLib Thread crashed"); } return $work; @@ -206,13 +202,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $packet->__encapsulatedPacket = new CachedEncapsulatedPacket; $packet->__encapsulatedPacket->identifierACK = null; $packet->__encapsulatedPacket->buffer = $packet->buffer; - if($packet->getChannel() !== 0){ - $packet->__encapsulatedPacket->reliability = 3; - $packet->__encapsulatedPacket->orderChannel = $packet->getChannel(); - $packet->__encapsulatedPacket->orderIndex = 0; - }else{ - $packet->__encapsulatedPacket->reliability = 2; - } + $packet->__encapsulatedPacket->reliability = 2; } $pk = $packet->__encapsulatedPacket; } @@ -220,20 +210,14 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ if(!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET and Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){ - $this->server->batchPackets([$player], [$packet], true, $packet->getChannel()); + $this->server->batchPackets([$player], [$packet], true); return null; } if($pk === null){ $pk = new EncapsulatedPacket(); $pk->buffer = $packet->buffer; - if($packet->getChannel() !== 0){ - $packet->reliability = 3; - $packet->orderChannel = $packet->getChannel(); - $packet->orderIndex = 0; - }else{ - $packet->reliability = 2; - } + $packet->reliability = 2; if($needACK === true){ $pk->identifierACK = $this->identifiersACK[$identifier]++; diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index b71aa84a3..ef1e841d3 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -37,7 +37,6 @@ abstract class DataPacket extends BinaryStream{ const NETWORK_ID = 0; public $isEncoded = false; - private $channel = 0; public function pid(){ return $this::NETWORK_ID; @@ -52,18 +51,6 @@ abstract class DataPacket extends BinaryStream{ $this->offset = 0; } - /** - * @deprecated This adds extra overhead on the network, so its usage is now discouraged. It was a test for the viability of this. - */ - public function setChannel($channel){ - $this->channel = (int) $channel; - return $this; - } - - public function getChannel(){ - return $this->channel; - } - public function clean(){ $this->buffer = null; $this->isEncoded = false; diff --git a/src/pocketmine/network/rcon/RCONInstance.php b/src/pocketmine/network/rcon/RCONInstance.php index b7d9990fb..64e1009a3 100644 --- a/src/pocketmine/network/rcon/RCONInstance.php +++ b/src/pocketmine/network/rcon/RCONInstance.php @@ -31,6 +31,11 @@ class RCONInstance extends Thread{ private $socket; private $password; private $maxClients; + private $waiting; + + public function isWaiting(){ + return $this->waiting === true; + } public function __construct($socket, $password, $maxClients = 50){ @@ -137,8 +142,10 @@ class RCONInstance extends Thread{ socket_getpeername($client, $addr, $port); $this->response = "[INFO] Successful Rcon connection from: /$addr:$port"; $this->synchronized(function (){ + $this->waiting = true; $this->wait(); }); + $this->waiting = false; $this->response = ""; $this->writePacket($client, $requestID, 2, ""); $this->{"status" . $n} = 1; @@ -156,8 +163,10 @@ class RCONInstance extends Thread{ if(strlen($payload) > 0){ $this->cmd = ltrim($payload); $this->synchronized(function (){ + $this->waiting = true; $this->wait(); }); + $this->waiting = false; $this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response))); $this->response = ""; $this->cmd = ""; diff --git a/src/pocketmine/scheduler/AsyncPool.php b/src/pocketmine/scheduler/AsyncPool.php index bb0914a61..9f288011e 100644 --- a/src/pocketmine/scheduler/AsyncPool.php +++ b/src/pocketmine/scheduler/AsyncPool.php @@ -150,10 +150,8 @@ class AsyncPool{ $this->removeTask($task); }elseif($task->isTerminated()){ - $info = $task->getTerminationInfo(); $this->removeTask($task, true); - $this->server->getLogger()->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": " . (isset($info["message"]) ? $info["message"] : "Unknown")); - $this->server->getLogger()->critical("On ".$info["scope"].", line ".$info["line"] .", ".$info["function"]."()"); + $this->server->getLogger()->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": Task crashed"); } } diff --git a/src/pocketmine/scheduler/AsyncTask.php b/src/pocketmine/scheduler/AsyncTask.php index 17b9320cd..1a2a24042 100644 --- a/src/pocketmine/scheduler/AsyncTask.php +++ b/src/pocketmine/scheduler/AsyncTask.php @@ -49,15 +49,6 @@ abstract class AsyncTask extends \Collectable{ $this->setGarbage(); } - /** - * @deprecated - * - * @return bool - */ - public function isFinished(){ - return $this->isGarbage(); - } - /** * @return mixed */ diff --git a/src/pocketmine/scheduler/CallbackTask.php b/src/pocketmine/scheduler/CallbackTask.php deleted file mode 100644 index 4d4969404..000000000 --- a/src/pocketmine/scheduler/CallbackTask.php +++ /dev/null @@ -1,62 +0,0 @@ -callable = $callable; - $this->args = $args; - $this->args[] = $this; - } - - /** - * @return callable - */ - public function getCallable(){ - return $this->callable; - } - - public function onRun($currentTicks){ - call_user_func_array($this->callable, $this->args); - } - -} diff --git a/src/pocketmine/scheduler/SendUsageTask.php b/src/pocketmine/scheduler/SendUsageTask.php index 911f9717a..c9d488c67 100644 --- a/src/pocketmine/scheduler/SendUsageTask.php +++ b/src/pocketmine/scheduler/SendUsageTask.php @@ -24,6 +24,7 @@ namespace pocketmine\scheduler; use pocketmine\network\protocol\Info; use pocketmine\Server; use pocketmine\utils\Utils; +use pocketmine\utils\UUID; use pocketmine\utils\VersionString; class SendUsageTask extends AsyncTask{ @@ -41,7 +42,7 @@ class SendUsageTask extends AsyncTask{ $data = []; $data["uniqueServerId"] = $server->getServerUniqueId(); $data["uniqueMachineId"] = Utils::getMachineUniqueId(); - $data["uniqueRequestId"] = Utils::dataToUUID($server->getServerUniqueId(), microtime(true)); + $data["uniqueRequestId"] = UUID::fromData($server->getServerUniqueId(), microtime(true)); switch($type){ case self::TYPE_OPEN: diff --git a/src/pocketmine/scheduler/Task.php b/src/pocketmine/scheduler/Task.php index 5793466ae..cbf82a74a 100644 --- a/src/pocketmine/scheduler/Task.php +++ b/src/pocketmine/scheduler/Task.php @@ -21,6 +21,9 @@ namespace pocketmine\scheduler; +/** + * WARNING! Plugins that create tasks MUST extend PluginTask + */ abstract class Task{ /** @var TaskHandler */ diff --git a/src/pocketmine/utils/Cache.php b/src/pocketmine/utils/Cache.php deleted file mode 100644 index 1bea19e6e..000000000 --- a/src/pocketmine/utils/Cache.php +++ /dev/null @@ -1,86 +0,0 @@ - $data){ - if($data[1] < $time){ - unset(self::$cached[$index]); - } - } - } - -} \ No newline at end of file diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index dbcfb40c1..9db96f436 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -321,46 +321,6 @@ class Config{ return ($this->correct and isset($this->config[$k])) ? $this->config[$k] : $default; } - /** - * @param string $path - * - * @deprecated - * - * @return mixed - */ - public function getPath($path){ - $currPath =& $this->config; - foreach(explode(".", $path) as $component){ - if(isset($currPath[$component])){ - $currPath =& $currPath[$component]; - }else{ - $currPath = null; - } - } - - return $currPath; - } - - /** - * - * @deprecated - * - * @param string $path - * @param mixed $value - */ - public function setPath($path, $value){ - $currPath =& $this->config; - $components = explode(".", $path); - $final = array_pop($components); - foreach($components as $component){ - if(!isset($currPath[$component])){ - $currPath[$component] = []; - } - $currPath =& $currPath[$component]; - } - $currPath[$final] = $value; - } - /** * @param string $k key to be set * @param mixed $v value to set key diff --git a/src/pocketmine/utils/TextWrapper.php b/src/pocketmine/utils/TextWrapper.php deleted file mode 100644 index efe313ab5..000000000 --- a/src/pocketmine/utils/TextWrapper.php +++ /dev/null @@ -1,93 +0,0 @@ -?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~"; - - private static $allowedCharsArray = []; - - public static function init(){ - self::$allowedCharsArray = []; - $len = strlen(self::$allowedChars); - for($i = 0; $i < $len; ++$i){ - self::$allowedCharsArray[self::$allowedChars{$i}] = self::$characterWidths[$i]; - } - } - - /** - * @deprecated - * - * @param $text - * - * @return string - */ - public static function wrap($text){ - $result = ""; - $len = strlen($text); - $lineWidth = 0; - $lineLength = 0; - - for($i = 0; $i < $len; ++$i){ - $char = $text{$i}; - - if($char === "\n"){ - $lineLength = 0; - $lineWidth = 0; - }elseif(isset(self::$allowedCharsArray[$char])){ - $width = self::$allowedCharsArray[$char]; - - if($lineLength + 1 > self::CHAT_STRING_LENGTH or $lineWidth + $width > self::CHAT_WINDOW_WIDTH){ - $result .= "\n"; - $lineLength = 0; - $lineWidth = 0; - } - - ++$lineLength; - $lineWidth += $width; - }else{ - return $text; - } - - $result .= $char; - } - - return $result; - } -} \ No newline at end of file diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 1ae2ca88f..0c4cd36e7 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -49,34 +49,6 @@ class Utils{ } } - /** - * @deprecated - */ - public static function randomUUID(){ - return Utils::toUUID(Binary::writeInt(time()) . Binary::writeShort(getmypid()) . Binary::writeShort(getmyuid()) . Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)) . Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)), 2); - } - - /** - * @deprecated - */ - public static function dataToUUID(...$params){ - return Utils::toUUID(hash("md5", implode($params), true), 3); - } - - /** - * @deprecated - */ - public static function toUUID($data, $version = 2, $fixed = "8"){ - if(strlen($data) !== 16){ - throw new \InvalidArgumentException("Data must be 16 bytes"); - } - - $hex = bin2hex($data); - - //xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx 8-4-4-12 - return substr($hex, 0, 8) . "-" . substr($hex, 8, 4) . "-" . hexdec($version) . substr($hex, 13, 3) . "-" . $fixed{0} . substr($hex, 17, 3) . "-" . substr($hex, 20, 12); - } - /** * Gets this machine / server instance unique ID * Returns a hash, the first 32 characters (or 16 if raw) diff --git a/src/pocketmine/utils/VersionString.php b/src/pocketmine/utils/VersionString.php index 35e5e8c5c..069c2fb8e 100644 --- a/src/pocketmine/utils/VersionString.php +++ b/src/pocketmine/utils/VersionString.php @@ -54,13 +54,6 @@ class VersionString{ return (int) (($this->generation << 9) + ($this->major << 5) + $this->minor); } - /** - * @deprecated - */ - public function getStage(){ - return "final"; - } - public function getGeneration(){ return $this->generation; } diff --git a/src/raklib b/src/raklib index 11fc08675..08f0a0c1c 160000 --- a/src/raklib +++ b/src/raklib @@ -1 +1 @@ -Subproject commit 11fc08675d301e73f1dbdec24029663a576de2c4 +Subproject commit 08f0a0c1c49c8c00c6dd569c6c1d9768a699ea9a diff --git a/src/spl b/src/spl index 9c79e91a0..612661afd 160000 --- a/src/spl +++ b/src/spl @@ -1 +1 @@ -Subproject commit 9c79e91a03dffe64101660e959da2593264f1462 +Subproject commit 612661afd49420743baec096b129f0c0f9df4023