From 1cb96d24ce87ccfab9ea83ea3f7c7c94035b9f50 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 4 Jan 2017 11:29:24 +0000 Subject: [PATCH] Some fixes, thanks PhpStorm --- CONTRIBUTING.md | 2 +- src/pocketmine/Player.php | 4 ++-- src/pocketmine/block/Block.php | 4 ++-- src/pocketmine/item/Bucket.php | 4 ++-- src/pocketmine/item/Item.php | 3 ++- src/pocketmine/level/format/Chunk.php | 6 +++++- src/pocketmine/level/format/LevelProvider.php | 2 ++ src/pocketmine/level/format/generic/GenericChunk.php | 4 ++-- src/pocketmine/level/format/region/Anvil.php | 2 +- src/pocketmine/math/Vector2.php | 4 ---- src/pocketmine/nbt/NBT.php | 2 ++ src/pocketmine/network/protocol/TextPacket.php | 2 ++ src/pocketmine/plugin/Plugin.php | 2 +- src/pocketmine/plugin/PluginBase.php | 2 +- src/pocketmine/scheduler/AsyncTask.php | 4 ++-- src/pocketmine/tile/FlowerPot.php | 1 + 16 files changed, 28 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8eac88568..cd68b8ecc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,7 +76,7 @@ class ExampleClass{ 4 => "value5", 5 => "value6", ]; - } + }; } } diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ede1b94b9..2dbd715a7 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1078,8 +1078,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade */ public function awardAchievement($achievementId){ if(isset(Achievement::$list[$achievementId]) and !$this->hasAchievement($achievementId)){ - foreach(Achievement::$list[$achievementId]["requires"] as $requerimentId){ - if(!$this->hasAchievement($requerimentId)){ + foreach(Achievement::$list[$achievementId]["requires"] as $requirementId){ + if(!$this->hasAchievement($requirementId)){ return false; } } diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index e8b4ca587..fbac3c01a 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -366,10 +366,10 @@ class Block extends Position implements BlockIds, Metadatable{ * * @param int $type * - * @return void + * @return int|bool */ public function onUpdate($type){ - + return false; } /** diff --git a/src/pocketmine/item/Bucket.php b/src/pocketmine/item/Bucket.php index 2d4e48203..b4cb0e355 100644 --- a/src/pocketmine/item/Bucket.php +++ b/src/pocketmine/item/Bucket.php @@ -52,7 +52,7 @@ class Bucket extends Item{ if(!$ev->isCancelled()){ $player->getLevel()->setBlock($target, new Air(), true, true); if($player->isSurvival()){ - $player->getInventory()->setItemInHand($ev->getItem(), $player); + $player->getInventory()->setItemInHand($ev->getItem()); } return true; }else{ @@ -66,7 +66,7 @@ class Bucket extends Item{ if(!$ev->isCancelled()){ $player->getLevel()->setBlock($block, $targetBlock, true, true); if($player->isSurvival()){ - $player->getInventory()->setItemInHand($ev->getItem(), $player); + $player->getInventory()->setItemInHand($ev->getItem()); } return true; }else{ diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index e9f55799b..338bb2ae0 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -787,7 +787,8 @@ class Item implements ItemIds, \JsonSerializable{ /** * Serializes the item to an NBT CompoundTag * - * @param int $slot optional, the inventory slot of the item + * @param int $slot optional, the inventory slot of the item + * @param string $tagName the name to assign to the CompoundTag object * * @return CompoundTag */ diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index fb48868f6..b1fcada26 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -61,6 +61,7 @@ interface Chunk{ * @return int */ public function getHeight() : int; + /** * Gets block and meta in one go * @@ -324,6 +325,7 @@ interface Chunk{ /** * @param int $fY 0-15 * @param SubChunk $subChunk + * @param bool $allowEmpty * * @return bool */ @@ -337,7 +339,7 @@ interface Chunk{ /** * Returns the index of the highest non-empty subchunk * - * @return bool + * @return int */ public function getHighestSubChunkIndex() : int; @@ -363,6 +365,8 @@ interface Chunk{ /** * Serializes a chunk without compression for use in AsyncTasks. * + * @param Chunk $chunk + * * @return string */ public static function fastSerialize(Chunk $chunk) : string; diff --git a/src/pocketmine/level/format/LevelProvider.php b/src/pocketmine/level/format/LevelProvider.php index 14cd85fea..f7ecd4ff5 100644 --- a/src/pocketmine/level/format/LevelProvider.php +++ b/src/pocketmine/level/format/LevelProvider.php @@ -109,6 +109,8 @@ interface LevelProvider{ /** * @param int $chunkX * @param int $chunkZ + * + * @return bool */ public function saveChunk(int $chunkX, int $chunkZ) : bool; diff --git a/src/pocketmine/level/format/generic/GenericChunk.php b/src/pocketmine/level/format/generic/GenericChunk.php index 8cb089603..73b1cb367 100644 --- a/src/pocketmine/level/format/generic/GenericChunk.php +++ b/src/pocketmine/level/format/generic/GenericChunk.php @@ -91,7 +91,7 @@ class GenericChunk implements Chunk{ * @param CompoundTag[] $entities * @param CompoundTag[] $tiles * @param string $biomeIds - * @param int[256] $heightMap + * @param int[] $heightMap */ public function __construct($provider, int $chunkX, int $chunkZ, array $subChunks = [], array $entities = [], array $tiles = [], string $biomeIds = "", array $heightMap = []){ $this->provider = $provider; @@ -736,7 +736,7 @@ class GenericChunk implements Chunk{ /** * Converts pre-MCPE-1.0 biome colour array to biome ID array. RIP BiomeColors :( * - * @param int[256] $array of biome colour values + * @param int[] $array of biome colour values * * @return string */ diff --git a/src/pocketmine/level/format/region/Anvil.php b/src/pocketmine/level/format/region/Anvil.php index b385a8ddb..ad67bc40c 100644 --- a/src/pocketmine/level/format/region/Anvil.php +++ b/src/pocketmine/level/format/region/Anvil.php @@ -59,7 +59,7 @@ class Anvil extends McRegion{ } $nbt->Sections[++$subChunks] = new CompoundTag(null, [ "Y" => new ByteTag("Y", $y), - "Blocks" => new ByteArrayTag("Blocks", GenericChunk::reorderByteArray($subChunk->getBlockIdArray())), //Generic in-memory chunks are currrently always XZY + "Blocks" => new ByteArrayTag("Blocks", GenericChunk::reorderByteArray($subChunk->getBlockIdArray())), //Generic in-memory chunks are currently always XZY "Data" => new ByteArrayTag("Data", GenericChunk::reorderNibbleArray($subChunk->getBlockDataArray())), "SkyLight" => new ByteArrayTag("SkyLight", GenericChunk::reorderNibbleArray($subChunk->getSkyLightArray())), "BlockLight" => new ByteArrayTag("BlockLight", GenericChunk::reorderNibbleArray($subChunk->getBlockLightArray())) diff --git a/src/pocketmine/math/Vector2.php b/src/pocketmine/math/Vector2.php index e6b600f79..05de2e709 100644 --- a/src/pocketmine/math/Vector2.php +++ b/src/pocketmine/math/Vector2.php @@ -21,10 +21,6 @@ namespace pocketmine\math; -/** - * WARNING: This class is available on the PocketMine-MP Zephir project. - * If this class is modified, remember to modify the PHP C extension. - */ class Vector2{ public $x; public $y; diff --git a/src/pocketmine/nbt/NBT.php b/src/pocketmine/nbt/NBT.php index fcae202f1..ac531196b 100644 --- a/src/pocketmine/nbt/NBT.php +++ b/src/pocketmine/nbt/NBT.php @@ -433,6 +433,8 @@ class NBT{ /** + * @param bool $network + * * @return string|bool */ public function write(bool $network = false){ diff --git a/src/pocketmine/network/protocol/TextPacket.php b/src/pocketmine/network/protocol/TextPacket.php index 558b0f652..4fb02777f 100644 --- a/src/pocketmine/network/protocol/TextPacket.php +++ b/src/pocketmine/network/protocol/TextPacket.php @@ -45,6 +45,7 @@ class TextPacket extends DataPacket{ switch($this->type){ case self::TYPE_POPUP: case self::TYPE_CHAT: + /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_WHISPER: $this->source = $this->getString(); case self::TYPE_RAW: @@ -68,6 +69,7 @@ class TextPacket extends DataPacket{ switch($this->type){ case self::TYPE_POPUP: case self::TYPE_CHAT: + /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_WHISPER: $this->putString($this->source); case self::TYPE_RAW: diff --git a/src/pocketmine/plugin/Plugin.php b/src/pocketmine/plugin/Plugin.php index ece3905d1..9c30693e6 100644 --- a/src/pocketmine/plugin/Plugin.php +++ b/src/pocketmine/plugin/Plugin.php @@ -80,7 +80,7 @@ interface Plugin extends CommandExecutor{ public function saveResource($filename, $replace = false); /** - * Returns all the resources incrusted in the plugin + * Returns all the resources packaged with the plugin */ public function getResources(); diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index 7c0c75c6e..1a21698a0 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -217,7 +217,7 @@ abstract class PluginBase implements Plugin{ } /** - * Returns all the resources incrusted on the plugin + * Returns all the resources packaged with the plugin * * @return string[] */ diff --git a/src/pocketmine/scheduler/AsyncTask.php b/src/pocketmine/scheduler/AsyncTask.php index 98d3f8cdc..455d2e1f4 100644 --- a/src/pocketmine/scheduler/AsyncTask.php +++ b/src/pocketmine/scheduler/AsyncTask.php @@ -31,7 +31,7 @@ use pocketmine\Server; * with no AsyncTask running. Therefore, an AsyncTask SHOULD NOT execute for more than a few seconds. For tasks that * run for a long time or infinitely, start another {@link \pocketmine\Thread} instead. * - * WARNING: Do not call PocketMine-MP API methods, or save objects (and arrays cotaining objects) from/on other Threads!! + * WARNING: Do not call PocketMine-MP API methods, or save objects (and arrays containing objects) from/on other Threads!! */ abstract class AsyncTask extends Collectable{ @@ -176,7 +176,7 @@ abstract class AsyncTask extends Collectable{ } /** - * Call this method from {@link AsyncTask#onRun} (AsyncTask execution therad) to schedule a call to + * Call this method from {@link AsyncTask#onRun} (AsyncTask execution thread) to schedule a call to * {@link AsyncTask#onProgressUpdate} from the main thread with the given progress parameter. * * @param mixed $progress A value that can be safely serialize()'ed. diff --git a/src/pocketmine/tile/FlowerPot.php b/src/pocketmine/tile/FlowerPot.php index 49561c214..b9e430973 100644 --- a/src/pocketmine/tile/FlowerPot.php +++ b/src/pocketmine/tile/FlowerPot.php @@ -45,6 +45,7 @@ class FlowerPot extends Spawnable{ return false; } switch($item->getId()){ + /** @noinspection PhpMissingBreakStatementInspection */ case Item::TALL_GRASS: if($item->getDamage() === 1){ return false;