From 6a507bb149590872b50177c7ba2dca993f89ffac Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Mar 2020 12:18:16 +0000 Subject: [PATCH 1/5] further CS fixes --- src/pocketmine/CoreConstants.php | 4 ++++ src/pocketmine/Thread.php | 4 +++- src/pocketmine/VersionInfo.php | 2 ++ src/pocketmine/Worker.php | 4 +++- src/pocketmine/network/mcpe/NetworkBinaryStream.php | 1 - src/pocketmine/network/mcpe/protocol/BatchPacket.php | 1 - 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/CoreConstants.php b/src/pocketmine/CoreConstants.php index 7dd0e50a47..091c438981 100644 --- a/src/pocketmine/CoreConstants.php +++ b/src/pocketmine/CoreConstants.php @@ -23,6 +23,10 @@ declare(strict_types=1); namespace pocketmine; +use function define; +use function defined; +use function dirname; + // composer autoload doesn't use require_once and also pthreads can inherit things if(defined('pocketmine\_CORE_CONSTANTS_INCLUDED')){ return; diff --git a/src/pocketmine/Thread.php b/src/pocketmine/Thread.php index 389eb9550b..86d9233164 100644 --- a/src/pocketmine/Thread.php +++ b/src/pocketmine/Thread.php @@ -23,6 +23,8 @@ declare(strict_types=1); namespace pocketmine; +use const PTHREADS_INHERIT_ALL; + /** * This class must be extended by all custom threading classes */ @@ -78,7 +80,7 @@ abstract class Thread extends \Thread{ * * @return bool */ - public function start(?int $options = \PTHREADS_INHERIT_ALL){ + public function start(?int $options = PTHREADS_INHERIT_ALL){ ThreadManager::getInstance()->add($this); if($this->getClassLoader() === null){ diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index 6e4ec054ff..db462770c6 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -23,6 +23,8 @@ declare(strict_types=1); namespace pocketmine; +use function defined; + // composer autoload doesn't use require_once and also pthreads can inherit things // TODO: drop this file and use a final class with constants if(defined('pocketmine\_VERSION_INFO_INCLUDED')){ diff --git a/src/pocketmine/Worker.php b/src/pocketmine/Worker.php index b7b551c29b..3687e80b47 100644 --- a/src/pocketmine/Worker.php +++ b/src/pocketmine/Worker.php @@ -23,6 +23,8 @@ declare(strict_types=1); namespace pocketmine; +use const PTHREADS_INHERIT_ALL; + /** * This class must be extended by all custom threading classes */ @@ -78,7 +80,7 @@ abstract class Worker extends \Worker{ * * @return bool */ - public function start(?int $options = \PTHREADS_INHERIT_ALL){ + public function start(?int $options = PTHREADS_INHERIT_ALL){ ThreadManager::getInstance()->add($this); if($this->getClassLoader() === null){ diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index c2890bfa2c..627a6eb156 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -27,7 +27,6 @@ namespace pocketmine\network\mcpe; use pocketmine\entity\Attribute; use pocketmine\entity\Entity; -use pocketmine\entity\Skin; use pocketmine\item\Durable; use pocketmine\item\Item; use pocketmine\item\ItemFactory; diff --git a/src/pocketmine/network/mcpe/protocol/BatchPacket.php b/src/pocketmine/network/mcpe/protocol/BatchPacket.php index 7124f7515f..b9e715586d 100644 --- a/src/pocketmine/network/mcpe/protocol/BatchPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BatchPacket.php @@ -25,7 +25,6 @@ namespace pocketmine\network\mcpe\protocol; #include - use pocketmine\network\mcpe\NetworkBinaryStream; use pocketmine\network\mcpe\NetworkSession; use function assert; From db215283a2da0d2d2da9384a378c6d827aee33a6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Mar 2020 12:28:44 +0000 Subject: [PATCH 2/5] Effect: add desc for color parameter --- src/pocketmine/entity/Effect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/entity/Effect.php b/src/pocketmine/entity/Effect.php index c50e600490..3471a08810 100644 --- a/src/pocketmine/entity/Effect.php +++ b/src/pocketmine/entity/Effect.php @@ -125,7 +125,7 @@ class Effect{ /** * @param int $id Effect ID as per Minecraft PE * @param string $name Translation key used for effect name - * @param Color $color + * @param Color $color Color of bubbles given by this effect * @param bool $isBad Whether the effect is harmful * @param int $defaultDuration Duration in ticks the effect will last for by default if applied without a duration. * @param bool $hasBubbles Whether the effect has potion bubbles. Some do not (e.g. Instant Damage has its own particles instead of bubbles) From 167492087f2fc04f699dafe46adcaec6c201ff4f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Mar 2020 12:33:53 +0000 Subject: [PATCH 3/5] Chunk: specify expected bounds for Y coordinates --- src/pocketmine/level/format/Chunk.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index c5989a9342..3ad1980ce0 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -175,7 +175,7 @@ class Chunk{ * Returns a bitmap of block ID and meta at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * * @return int bitmap, (id << 4) | meta @@ -188,7 +188,7 @@ class Chunk{ * Sets block ID and meta in one call at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * @param int|null $blockId 0-255 if null, does not change * @param int|null $meta 0-15 if null, does not change @@ -205,7 +205,7 @@ class Chunk{ * Returns the block ID at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * * @return int 0-255 @@ -218,7 +218,7 @@ class Chunk{ * Sets the block ID at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * @param int $id 0-255 * @@ -234,7 +234,7 @@ class Chunk{ * Returns the block meta value at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * * @return int 0-15 @@ -247,7 +247,7 @@ class Chunk{ * Sets the block meta value at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * @param int $data 0-15 * @@ -263,7 +263,7 @@ class Chunk{ * Returns the sky light level at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * * @return int 0-15 @@ -276,7 +276,7 @@ class Chunk{ * Sets the sky light level at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * @param int $level 0-15 * @@ -303,7 +303,7 @@ class Chunk{ * Returns the block light level at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y 0-15 + * @param int $y 0-255 * @param int $z 0-15 * * @return int 0-15 @@ -316,7 +316,7 @@ class Chunk{ * Sets the block light level at the specified chunk block coordinates * * @param int $x 0-15 - * @param int $y 0-15 + * @param int $y 0-255 * @param int $z 0-15 * @param int $level 0-15 * @@ -653,7 +653,7 @@ class Chunk{ * Returns the tile at the specified chunk block coordinates, or null if no tile exists. * * @param int $x 0-15 - * @param int $y + * @param int $y 0-255 * @param int $z 0-15 * * @return Tile|null From 344c980cffce0f0547fbdf1d2e15cd90c495a7e5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Mar 2020 12:35:13 +0000 Subject: [PATCH 4/5] GlobalConstants: add strict_types --- src/pocketmine/GlobalConstants.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pocketmine/GlobalConstants.php b/src/pocketmine/GlobalConstants.php index d3b4a9f9a2..e32d07c040 100644 --- a/src/pocketmine/GlobalConstants.php +++ b/src/pocketmine/GlobalConstants.php @@ -19,6 +19,8 @@ * */ +declare(strict_types=1); + // composer autoload doesn't use require_once and also pthreads can inherit things if(defined('pocketmine\_GLOBAL_CONSTANTS_INCLUDED')){ return; From 456d9a722a3b8c488cc21796587bc17dbb405b32 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Mar 2020 12:36:19 +0000 Subject: [PATCH 5/5] reduce some doc comments to single line --- src/pocketmine/entity/object/ExperienceOrb.php | 8 ++------ .../transaction/action/CreativeInventoryAction.php | 8 ++------ .../mcpe/protocol/AvailableCommandsPacket.php | 4 +--- .../network/mcpe/protocol/ProtocolInfo.php | 12 +++--------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/pocketmine/entity/object/ExperienceOrb.php b/src/pocketmine/entity/object/ExperienceOrb.php index 3a70e17d9b..aaea3653d5 100644 --- a/src/pocketmine/entity/object/ExperienceOrb.php +++ b/src/pocketmine/entity/object/ExperienceOrb.php @@ -36,14 +36,10 @@ class ExperienceOrb extends Entity{ public const TAG_VALUE_PC = "Value"; //short public const TAG_VALUE_PE = "experience value"; //int (WTF?) - /** - * Max distance an orb will follow a player across. - */ + /** Max distance an orb will follow a player across. */ public const MAX_TARGET_DISTANCE = 8.0; - /** - * Split sizes used for dropping experience orbs. - */ + /** Split sizes used for dropping experience orbs. */ public const ORB_SPLIT_SIZES = [2477, 1237, 617, 307, 149, 73, 37, 17, 7, 3, 1]; //This is indexed biggest to smallest so that we can return as soon as we found the biggest value. /** diff --git a/src/pocketmine/inventory/transaction/action/CreativeInventoryAction.php b/src/pocketmine/inventory/transaction/action/CreativeInventoryAction.php index 91cb1d7a8b..7e5b94e0f1 100644 --- a/src/pocketmine/inventory/transaction/action/CreativeInventoryAction.php +++ b/src/pocketmine/inventory/transaction/action/CreativeInventoryAction.php @@ -28,13 +28,9 @@ use pocketmine\Player; class CreativeInventoryAction extends InventoryAction{ - /** - * Player put an item into the creative window to destroy it. - */ + /** Player put an item into the creative window to destroy it. */ public const TYPE_DELETE_ITEM = 0; - /** - * Player took an item from the creative window. - */ + /** Player took an item from the creative window. */ public const TYPE_CREATE_ITEM = 1; /** @var int */ diff --git a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php index eac4833d0a..3ca5484ca4 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php @@ -75,9 +75,7 @@ class AvailableCommandsPacket extends DataPacket{ */ public const ARG_FLAG_ENUM = 0x200000; - /** - * This is used for /xp L. It can only be applied to integer parameters. - */ + /** This is used for /xp L. It can only be applied to integer parameters. */ public const ARG_FLAG_POSTFIX = 0x1000000; public const HARDCODED_ENUM_NAMES = [ diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index 0161fa03dd..8d08df6c3e 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -36,17 +36,11 @@ interface ProtocolInfo{ * This file is generated automatically, do not edit it manually. */ - /** - * Actual Minecraft: PE protocol version - */ + /** Actual Minecraft: PE protocol version */ public const CURRENT_PROTOCOL = 389; - /** - * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. - */ + /** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ public const MINECRAFT_VERSION = 'v1.14.0'; - /** - * Version number sent to clients in ping responses. - */ + /** Version number sent to clients in ping responses. */ public const MINECRAFT_VERSION_NETWORK = '1.14.0'; public const LOGIN_PACKET = 0x01;