From 58ff3815571ffc4fb55155b329474d019b1a7518 Mon Sep 17 00:00:00 2001 From: SOFe Date: Mon, 3 Oct 2016 19:05:48 +0800 Subject: [PATCH] PhpStorm automated formatting (#11) * PhpStorm reformatting * Tuned PhpStorm reformatting * Improved ItemIds and BlockIds formatting * Tuned more PhpStorm reformatting * Improved string concatenation --- src/pocketmine/MemoryManager.php | 10 +- src/pocketmine/PocketMine.php | 4 +- src/pocketmine/Server.php | 16 +-- src/pocketmine/block/ActivatorRail.php | 2 +- src/pocketmine/block/BlockIds.php | 118 +++++++++--------- src/pocketmine/block/CocoaBlock.php | 2 +- src/pocketmine/block/DaylightSensor.php | 2 +- src/pocketmine/block/DetectorRail.php | 2 +- src/pocketmine/block/Fence.php | 2 +- src/pocketmine/block/FlowerPot.php | 10 +- src/pocketmine/block/Lever.php | 2 +- src/pocketmine/block/LitRedstoneLamp.php | 2 +- src/pocketmine/block/LitRedstoneTorch.php | 2 +- src/pocketmine/block/MobHead.php | 2 +- src/pocketmine/block/NetherBrickFence.php | 9 +- src/pocketmine/block/NoteBlock.php | 2 +- src/pocketmine/block/PoweredRail.php | 2 +- src/pocketmine/block/Rail.php | 2 +- src/pocketmine/block/RedstoneLamp.php | 2 +- src/pocketmine/block/RedstoneTorch.php | 2 +- src/pocketmine/block/Slab.php | 1 - src/pocketmine/block/StoneButton.php | 2 +- src/pocketmine/block/StonePressurePlate.php | 2 +- src/pocketmine/block/Tripwire.php | 2 +- src/pocketmine/block/TripwireHook.php | 2 +- src/pocketmine/block/WallSign.php | 4 +- .../block/WeightedPressurePlateHeavy.php | 2 +- .../block/WeightedPressurePlateLight.php | 2 +- src/pocketmine/block/WoodenButton.php | 2 +- src/pocketmine/block/WoodenPressurePlate.php | 2 +- src/pocketmine/command/Command.php | 2 +- .../defaults/GarbageCollectorCommand.php | 2 +- .../command/defaults/GiveCommand.php | 2 +- .../command/defaults/StatusCommand.php | 15 ++- .../command/defaults/TellCommand.php | 5 +- src/pocketmine/entity/AttributeMap.php | 2 +- src/pocketmine/entity/Entity.php | 2 +- .../entity/EntityDamageByEntityEvent.php | 2 + .../event/inventory/CraftItemEvent.php | 4 +- .../event/player/PlayerCreationEvent.php | 4 +- .../event/server/LowMemoryEvent.php | 1 + src/pocketmine/inventory/BaseInventory.php | 6 +- src/pocketmine/inventory/CraftingManager.php | 72 +++++------ .../inventory/DoubleChestInventory.php | 2 +- src/pocketmine/inventory/Inventory.php | 10 +- src/pocketmine/item/ItemIds.php | 51 ++++---- src/pocketmine/lang/BaseLang.php | 4 +- src/pocketmine/level/ChunkManager.php | 6 +- src/pocketmine/level/Level.php | 13 +- src/pocketmine/level/SimpleChunkManager.php | 8 +- src/pocketmine/level/format/FullChunk.php | 6 +- .../level/format/generic/BaseChunk.php | 4 +- .../level/format/generic/BaseFullChunk.php | 4 +- .../level/format/mcregion/RegionLoader.php | 2 +- src/pocketmine/level/generator/Flat.php | 2 +- src/pocketmine/level/generator/Generator.php | 2 +- .../level/generator/noise/Noise.php | 2 +- .../level/generator/normal/Normal.php | 4 +- .../generator/normal/biome/DesertBiome.php | 1 - .../level/particle/FloatingTextParticle.php | 4 +- src/pocketmine/nbt/tag/NamedTag.php | 2 +- src/pocketmine/network/Network.php | 2 +- src/pocketmine/network/RakLibInterface.php | 8 +- .../network/protocol/AddEntityPacket.php | 4 +- .../network/protocol/LoginPacket.php | 2 +- .../network/protocol/MoveEntityPacket.php | 12 +- src/pocketmine/network/rcon/RCON.php | 4 +- src/pocketmine/network/rcon/RCONInstance.php | 4 +- src/pocketmine/scheduler/FileWriteTask.php | 2 +- src/pocketmine/scheduler/SendUsageTask.php | 2 +- src/pocketmine/tile/EnchantTable.php | 8 +- src/pocketmine/tile/Tile.php | 8 +- src/pocketmine/utils/Binary.php | 1 + src/pocketmine/utils/Config.php | 1 + src/pocketmine/utils/MainLogger.php | 2 +- src/pocketmine/utils/Random.php | 4 +- src/pocketmine/utils/TextFormat.php | 4 +- 77 files changed, 266 insertions(+), 264 deletions(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index 9d6cc43c5..458df304d 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -127,8 +127,8 @@ class MemoryManager{ } public function trigger($memory, $limit, $global = false, $triggerCount = 0){ - $this->server->getLogger()->debug("[Memory Manager] ".($global ? "Global " : "") ."Low memory triggered, limit ". round(($limit / 1024) / 1024, 2)."MB, using ". round(($memory / 1024) / 1024, 2)."MB"); - + $this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB", + $global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2))); if($this->cacheTrigger){ foreach($this->server->getLevels() as $level){ $level->clearCache(true); @@ -149,7 +149,7 @@ class MemoryManager{ $cycles = $this->triggerGarbageCollector(); } - $this->server->getLogger()->debug("[Memory Manager] Freed " . round(($ev->getMemoryFreed() / 1024) / 1024, 2)."MB, $cycles cycles"); + $this->server->getLogger()->debug(sprintf("[Memory Manager] Freed %gMB, $cycles cycles", round(($ev->getMemoryFreed() / 1024) / 1024, 2))); } public function check(){ @@ -265,7 +265,7 @@ class MemoryManager{ $this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize); } - fwrite($obData, "$hash@$className: ". json_encode($info, JSON_UNESCAPED_SLASHES) . "\n"); + fwrite($obData, "$hash@$className: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n"); if(!isset($objects["staticProperties"][$className])){ $staticProperties[$className] = []; @@ -323,7 +323,7 @@ class MemoryManager{ $this->continueDump($value, $data[$key], $objects, $refCounts, $recursion + 1, $maxNesting, $maxStringSize); } }elseif(is_string($from)){ - $data = "(string) len(".strlen($from).") " . substr(Utils::printable($from), 0, $maxStringSize); + $data = sprintf("(string) len(%d) " . substr(Utils::printable($from), 0, $maxStringSize), strlen($from)); }elseif(is_resource($from)){ $data = "(resource) " . print_r($from, true); }else{ diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 679cc2718..34629f224 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -175,7 +175,7 @@ namespace pocketmine { $default_timezone = timezone_name_from_abbr($timezone); ini_set("date.timezone", $default_timezone); date_default_timezone_set($default_timezone); - } else { + }else{ date_default_timezone_set($timezone); } } @@ -323,7 +323,7 @@ namespace pocketmine { if(function_exists("posix_kill")){ posix_kill($pid, SIGKILL); }else{ - exec("kill -9 " . ((int)$pid) . " > /dev/null 2>&1"); + exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1"); } } } diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 73222ec5a..d9ee59029 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -801,9 +801,9 @@ class Server{ } /** - * @param string $name + * @param string $name * @param CompoundTag $nbtTag - * @param bool $async + * @param bool $async */ public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){ $nbt = new NBT(NBT::BIG_ENDIAN); @@ -1779,7 +1779,7 @@ class Server{ * * @param Player[] $players * @param DataPacket[]|string $packets - * @param bool $forceSync + * @param bool $forceSync */ public function batchPackets(array $players, array $packets, $forceSync = false){ Timings::$playerNetworkTimer->startTiming(); @@ -1986,7 +1986,7 @@ class Server{ gc_collect_cycles(); }catch(\Throwable $e){ $this->logger->emergency("Crashed while crashing, killing process"); - $this->logger->emergency(get_class($e) . ": ". $e->getMessage()); + $this->logger->emergency(get_class($e) . ": " . $e->getMessage()); @kill(getmypid()); } @@ -2264,14 +2264,14 @@ class Server{ if($r > $this->baseTickRate){ $level->tickRateCounter = $level->getTickRate(); } - $this->getLogger()->debug("Raising level \"".$level->getName()."\" tick rate to ".$level->getTickRate()." ticks"); + $this->getLogger()->debug("Raising level \"{$level->getName()}\" tick rate to {$level->getTickRate()} ticks"); }elseif($tickMs >= 50){ if($level->getTickRate() === $this->baseTickRate){ $level->setTickRate(max($this->baseTickRate + 1, min($this->autoTickRateLimit, floor($tickMs / 50)))); - $this->getLogger()->debug("Level \"".$level->getName()."\" took ".round($tickMs, 2)."ms, setting tick rate to ".$level->getTickRate()." ticks"); + $this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate())); }elseif(($tickMs / $level->getTickRate()) >= 50 and $level->getTickRate() < $this->autoTickRateLimit){ $level->setTickRate($level->getTickRate() + 1); - $this->getLogger()->debug("Level \"".$level->getName()."\" took ".round($tickMs, 2)."ms, setting tick rate to ".$level->getTickRate()." ticks"); + $this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate())); } $level->tickRateCounter = $level->getTickRate(); } @@ -2343,7 +2343,7 @@ class Server{ $d = Utils::getRealMemoryUsage(); $u = Utils::getMemoryUsage(true); - $usage = round(($u[0] / 1024) / 1024, 2) . "/" . round(($d[0] / 1024) / 1024, 2) . "/" . round(($u[1] / 1024) / 1024, 2) . "/".round(($u[2] / 1024) / 1024, 2)." MB @ " . Utils::getThreadCount() . " threads"; + $usage = sprintf("%g/%g/%g/%g MB @ %d threads", round(($u[0] / 1024) / 1024, 2), round(($d[0] / 1024) / 1024, 2), round(($u[1] / 1024) / 1024, 2), round(($u[2] / 1024) / 1024, 2), Utils::getThreadCount()); echo "\x1b]0;" . $this->getName() . " " . $this->getPocketMineVersion() . diff --git a/src/pocketmine/block/ActivatorRail.php b/src/pocketmine/block/ActivatorRail.php index 642d0c4ab..58dd19f4a 100644 --- a/src/pocketmine/block/ActivatorRail.php +++ b/src/pocketmine/block/ActivatorRail.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class ActivatorRail extends Solid { +class ActivatorRail extends Solid{ protected $id = self::ACTIVATOR_RAIL; diff --git a/src/pocketmine/block/BlockIds.php b/src/pocketmine/block/BlockIds.php index 6f5c7bbdd..415cddf5f 100644 --- a/src/pocketmine/block/BlockIds.php +++ b/src/pocketmine/block/BlockIds.php @@ -27,9 +27,9 @@ interface BlockIds{ const STONE = 1; const GRASS = 2; const DIRT = 3; - const COBBLESTONE = 4; const COBBLE = 4; - const PLANK = 5; const PLANKS = 5; const WOODEN_PLANK = 5; const WOODEN_PLANKS = 5; - const SAPLING = 6; const SAPLINGS = 6; + const COBBLESTONE = 4, COBBLE = 4; + const PLANK = 5, PLANKS = 5, WOODEN_PLANK = 5, WOODEN_PLANKS = 5; + const SAPLING = 6, SAPLINGS = 6; const BEDROCK = 7; const WATER = 8; const STILL_WATER = 9; @@ -40,7 +40,7 @@ interface BlockIds{ const GOLD_ORE = 14; const IRON_ORE = 15; const COAL_ORE = 16; - const LOG = 17; const WOOD = 17; const TRUNK = 17; + const LOG = 17, WOOD = 17, TRUNK = 17; const LEAVES = 18; const SPONGE = 19; const GLASS = 20; @@ -48,130 +48,130 @@ interface BlockIds{ const LAPIS_BLOCK = 22; const DISPENSER = 23; const SANDSTONE = 24; - const NOTE_BLOCK = 25; const NOTEBLOCK = 25; + const NOTE_BLOCK = 25, NOTEBLOCK = 25; const BED_BLOCK = 26; const POWERED_RAIL = 27; const DETECTOR_RAIL = 28; const STICKY_PISTON = 29; const COBWEB = 30; const TALL_GRASS = 31; - const BUSH = 32; const DEAD_BUSH = 32; + const BUSH = 32, DEAD_BUSH = 32; const PISTON = 33; const PISTON_HEAD = 34; const WOOL = 35; const DANDELION = 37; - const POPPY = 38; const ROSE = 38; const RED_FLOWER = 38; + const POPPY = 38, ROSE = 38, RED_FLOWER = 38; const BROWN_MUSHROOM = 39; const RED_MUSHROOM = 40; const GOLD_BLOCK = 41; const IRON_BLOCK = 42; - const DOUBLE_SLAB = 43; const DOUBLE_SLABS = 43; - const SLAB = 44; const SLABS = 44; const STONE_SLAB = 44; - const BRICKS = 45; const BRICKS_BLOCK = 45; + const DOUBLE_SLAB = 43, DOUBLE_SLABS = 43; + const SLAB = 44, SLABS = 44, STONE_SLAB = 44; + const BRICKS = 45, BRICKS_BLOCK = 45; const TNT = 46; const BOOKSHELF = 47; - const MOSS_STONE = 48; const MOSSY_STONE = 48; + const MOSS_STONE = 48, MOSSY_STONE = 48; const OBSIDIAN = 49; const TORCH = 50; const FIRE = 51; const MONSTER_SPAWNER = 52; - const WOOD_STAIRS = 53; const WOODEN_STAIRS = 53; const OAK_WOOD_STAIRS = 53; const OAK_WOODEN_STAIRS = 53; + const WOOD_STAIRS = 53, WOODEN_STAIRS = 53, OAK_WOOD_STAIRS = 53, OAK_WOODEN_STAIRS = 53; const CHEST = 54; const REDSTONE_WIRE = 55; const DIAMOND_ORE = 56; const DIAMOND_BLOCK = 57; - const CRAFTING_TABLE = 58; const WORKBENCH = 58; + const CRAFTING_TABLE = 58, WORKBENCH = 58; const WHEAT_BLOCK = 59; const FARMLAND = 60; const FURNACE = 61; - const BURNING_FURNACE = 62; const LIT_FURNACE = 62; + const BURNING_FURNACE = 62, LIT_FURNACE = 62; const SIGN_POST = 63; - const DOOR_BLOCK = 64; const WOODEN_DOOR_BLOCK = 64; const WOOD_DOOR_BLOCK = 64; + const DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64, WOOD_DOOR_BLOCK = 64; const LADDER = 65; const RAIL = 66; - const COBBLESTONE_STAIRS = 67; const COBBLE_STAIRS = 67; + const COBBLESTONE_STAIRS = 67, COBBLE_STAIRS = 67; const WALL_SIGN = 68; const LEVER = 69; const STONE_PRESSURE_PLATE = 70; const IRON_DOOR_BLOCK = 71; const WOODEN_PRESSURE_PLATE = 72; const REDSTONE_ORE = 73; - const GLOWING_REDSTONE_ORE = 74; const LIT_REDSTONE_ORE = 74; + const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74; const UNLIT_REDSTONE_TORCH = 75; - const REDSTONE_TORCH = 76; const LIT_REDSTONE_TORCH = 76; + const REDSTONE_TORCH = 76, LIT_REDSTONE_TORCH = 76; const STONE_BUTTON = 77; - const SNOW = 78; const SNOW_LAYER = 78; + const SNOW = 78, SNOW_LAYER = 78; const ICE = 79; const SNOW_BLOCK = 80; const CACTUS = 81; const CLAY_BLOCK = 82; - const REEDS = 83; const SUGARCANE_BLOCK = 83; + const REEDS = 83, SUGARCANE_BLOCK = 83; const FENCE = 85; const PUMPKIN = 86; const NETHERRACK = 87; const SOUL_SAND = 88; - const GLOWSTONE = 89; const GLOWSTONE_BLOCK = 89; - const PORTAL_BLOCK = 90; const PORTAL = 90; - const JACK_O_LANTERN = 91; const LIT_PUMPKIN = 91; + const GLOWSTONE = 89, GLOWSTONE_BLOCK = 89; + const PORTAL_BLOCK = 90, PORTAL = 90; + const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91; const CAKE_BLOCK = 92; - const REPEATER_BLOCK = 93; const UNPOWERED_REPEATER_BLOCK = 93; + const REPEATER_BLOCK = 93, UNPOWERED_REPEATER_BLOCK = 93; const POWERED_REPEATER_BLOCK = 94; const INVISIBLE_BEDROCK = 95; - const TRAPDOOR = 96; const WOODEN_TRAPDOOR = 96; + const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96; const MONSTER_EGG_BLOCK = 97; - const STONE_BRICKS = 98; const STONE_BRICK = 98; + const STONE_BRICKS = 98, STONE_BRICK = 98; const BROWN_MUSHROOM_BLOCK = 99; const RED_MUSHROOM_BLOCK = 100; - const IRON_BARS = 101; const IRON_BAR = 101; - const GLASS_PANE = 102; const GLASS_PANEL = 102; + const IRON_BARS = 101, IRON_BAR = 101; + const GLASS_PANE = 102, GLASS_PANEL = 102; const MELON_BLOCK = 103; const PUMPKIN_STEM = 104; const MELON_STEM = 105; - const VINES = 106; const VINE = 106; - const FENCE_GATE = 107; const OAK_FENCE_GATE = 107; + const VINES = 106, VINE = 106; + const FENCE_GATE = 107, OAK_FENCE_GATE = 107; const BRICK_STAIRS = 108; const STONE_BRICK_STAIRS = 109; const MYCELIUM = 110; - const LILY_PAD = 111; const WATER_LILY = 111; - const NETHER_BRICKS = 112; const NETHER_BRICK_BLOCK = 112; + const LILY_PAD = 111, WATER_LILY = 111; + const NETHER_BRICKS = 112, NETHER_BRICK_BLOCK = 112; const NETHER_BRICK_FENCE = 113; - const NETHER_BRICK_STAIRS = 114; const NETHER_BRICKS_STAIRS = 114; + const NETHER_BRICK_STAIRS = 114, NETHER_BRICKS_STAIRS = 114; const NETHER_WART_BLOCK = 115; - const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; + const ENCHANTING_TABLE = 116, ENCHANT_TABLE = 116, ENCHANTMENT_TABLE = 116; const BREWING_STAND_BLOCK = 117; const CAULDRON_BLOCK = 118; - const END_PORTAL_FRAME = 120; const END_PORTAL = 120; + const END_PORTAL_FRAME = 120, END_PORTAL = 120; const END_STONE = 121; - const REDSTONE_LAMP = 123; const INACTIVE_REDSTONE_LAMP = 123; - const LIT_REDSTONE_LAMP = 124; const ACTIVE_REDSTONE_LAMP = 124; + const REDSTONE_LAMP = 123, INACTIVE_REDSTONE_LAMP = 123; + const LIT_REDSTONE_LAMP = 124, ACTIVE_REDSTONE_LAMP = 124; const DROPPER = 125; const ACTIVATOR_RAIL = 126; - const COCOA_BLOCK = 127; const COCOA_PODS = 127; + const COCOA_BLOCK = 127, COCOA_PODS = 127; const SANDSTONE_STAIRS = 128; const EMERALD_ORE = 129; const TRIPWIRE_HOOK = 131; const TRIPWIRE = 132; const EMERALD_BLOCK = 133; - const SPRUCE_WOOD_STAIRS = 134; const SPRUCE_WOODEN_STAIRS = 134; - const BIRCH_WOOD_STAIRS = 135; const BIRCH_WOODEN_STAIRS = 135; - const JUNGLE_WOOD_STAIRS = 136; const JUNGLE_WOODEN_STAIRS = 136; + const SPRUCE_WOOD_STAIRS = 134, SPRUCE_WOODEN_STAIRS = 134; + const BIRCH_WOOD_STAIRS = 135, BIRCH_WOODEN_STAIRS = 135; + const JUNGLE_WOOD_STAIRS = 136, JUNGLE_WOODEN_STAIRS = 136; - const COBBLESTONE_WALL = 139; const COBBLE_WALL = 139; const STONE_WALL = 139; + const COBBLESTONE_WALL = 139, COBBLE_WALL = 139, STONE_WALL = 139; const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; const WOODEN_BUTTON = 143; - const MOB_HEAD_BLOCK = 144; const SKULL_BLOCK = 144; + const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144; const ANVIL = 145; const TRAPPED_CHEST = 146; - const WEIGHTED_PRESSURE_PLATE_LIGHT = 147; const LIGHT_WEIGHTED_PRESSURE_PLATE = 147; const GOLD_PRESSURE_PLATE = 147; - const WEIGHTED_PRESSURE_PLATE_HEAVY = 148; const HEAVY_WEIGHTED_PRESSURE_PLATE = 148; const IRON_PRESSURE_PLATE = 148; - const COMPARATOR_BLOCK = 149; const UNPOWERED_COMPARATOR_BLOCK = 149; + const WEIGHTED_PRESSURE_PLATE_LIGHT = 147, LIGHT_WEIGHTED_PRESSURE_PLATE = 147, GOLD_PRESSURE_PLATE = 147; + const WEIGHTED_PRESSURE_PLATE_HEAVY = 148, HEAVY_WEIGHTED_PRESSURE_PLATE = 148, IRON_PRESSURE_PLATE = 148; + const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR_BLOCK = 149; const POWERED_COMPARATOR_BLOCK = 150; const DAYLIGHT_SENSOR = 151; const REDSTONE_BLOCK = 152; @@ -179,14 +179,14 @@ interface BlockIds{ const HOPPER_BLOCK = 154; const QUARTZ_BLOCK = 155; const QUARTZ_STAIRS = 156; - const DOUBLE_WOOD_SLAB = 157; const DOUBLE_WOODEN_SLAB = 157; const DOUBLE_WOOD_SLABS = 157; const DOUBLE_WOODEN_SLABS = 157; - const WOOD_SLAB = 158; const WOODEN_SLAB = 158; const WOOD_SLABS = 158; const WOODEN_SLABS = 158; - const STAINED_CLAY = 159; const STAINED_HARDENED_CLAY = 159; + const DOUBLE_WOOD_SLAB = 157, DOUBLE_WOODEN_SLAB = 157, DOUBLE_WOOD_SLABS = 157, DOUBLE_WOODEN_SLABS = 157; + const WOOD_SLAB = 158, WOODEN_SLAB = 158, WOOD_SLABS = 158, WOODEN_SLABS = 158; + const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159; const LEAVES2 = 161; - const WOOD2 = 162; const TRUNK2 = 162; const LOG2 = 162; - const ACACIA_WOOD_STAIRS = 163; const ACACIA_WOODEN_STAIRS = 163; - const DARK_OAK_WOOD_STAIRS = 164; const DARK_OAK_WOODEN_STAIRS = 164; + const WOOD2 = 162, TRUNK2 = 162, LOG2 = 162; + const ACACIA_WOOD_STAIRS = 163, ACACIA_WOODEN_STAIRS = 163; + const DARK_OAK_WOOD_STAIRS = 164, DARK_OAK_WOODEN_STAIRS = 164; const SLIME_BLOCK = 165; const IRON_TRAPDOOR = 167; @@ -198,16 +198,16 @@ interface BlockIds{ const PACKED_ICE = 174; const DOUBLE_PLANT = 175; - const INVERTED_DAYLIGHT_SENSOR = 178; const DAYLIGHT_SENSOR_INVERTED = 178; + const INVERTED_DAYLIGHT_SENSOR = 178, DAYLIGHT_SENSOR_INVERTED = 178; const RED_SANDSTONE = 179; const RED_SANDSTONE_STAIRS = 180; const DOUBLE_RED_SANDSTONE_SLAB = 181; const RED_SANDSTONE_SLAB = 182; - const SPRUCE_FENCE_GATE = 183; const FENCE_GATE_SPRUCE = 183; - const BIRCH_FENCE_GATE = 184; const FENCE_GATE_BIRCH = 184; - const JUNGLE_FENCE_GATE = 185; const FENCE_GATE_JUNGLE = 185; - const DARK_OAK_FENCE_GATE = 186; const FENCE_GATE_DARK_OAK = 186; - const ACACIA_FENCE_GATE = 187; const FENCE_GATE_ACACIA = 187; + const SPRUCE_FENCE_GATE = 183, FENCE_GATE_SPRUCE = 183; + const BIRCH_FENCE_GATE = 184, FENCE_GATE_BIRCH = 184; + const JUNGLE_FENCE_GATE = 185, FENCE_GATE_JUNGLE = 185; + const DARK_OAK_FENCE_GATE = 186, FENCE_GATE_DARK_OAK = 186; + const ACACIA_FENCE_GATE = 187, FENCE_GATE_ACACIA = 187; const SPRUCE_DOOR_BLOCK = 193; const BIRCH_DOOR_BLOCK = 194; @@ -227,4 +227,4 @@ interface BlockIds{ const BLOCK_MOVED_BY_PISTON = 250; const OBSERVER = 251; const INFO_RESERVED6 = 255; -} \ No newline at end of file +} diff --git a/src/pocketmine/block/CocoaBlock.php b/src/pocketmine/block/CocoaBlock.php index e18638e10..70d3c67e0 100644 --- a/src/pocketmine/block/CocoaBlock.php +++ b/src/pocketmine/block/CocoaBlock.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class CocoaBlock extends Solid { +class CocoaBlock extends Solid{ protected $id = self::COCOA_BLOCK; diff --git a/src/pocketmine/block/DaylightSensor.php b/src/pocketmine/block/DaylightSensor.php index 9e0977e4e..2dc5124e2 100644 --- a/src/pocketmine/block/DaylightSensor.php +++ b/src/pocketmine/block/DaylightSensor.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class DaylightSensor extends Solid { +class DaylightSensor extends Solid{ protected $id = self::DAYLIGHT_SENSOR; diff --git a/src/pocketmine/block/DetectorRail.php b/src/pocketmine/block/DetectorRail.php index 203ad347c..ecd809d35 100644 --- a/src/pocketmine/block/DetectorRail.php +++ b/src/pocketmine/block/DetectorRail.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class DetectorRail extends Solid { +class DetectorRail extends Solid{ protected $id = self::DETECTOR_RAIL; diff --git a/src/pocketmine/block/Fence.php b/src/pocketmine/block/Fence.php index 3011af23f..b64a36ef7 100644 --- a/src/pocketmine/block/Fence.php +++ b/src/pocketmine/block/Fence.php @@ -26,7 +26,7 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3; class Fence extends Transparent{ - const FENCE_OAK = 0; + const FENCE_OAK = 0; const FENCE_SPRUCE = 1; const FENCE_BIRCH = 2; const FENCE_JUNGLE = 3; diff --git a/src/pocketmine/block/FlowerPot.php b/src/pocketmine/block/FlowerPot.php index 828c1875b..43d235f28 100644 --- a/src/pocketmine/block/FlowerPot.php +++ b/src/pocketmine/block/FlowerPot.php @@ -54,12 +54,12 @@ class FlowerPot extends Flowable{ public function getBoundingBox(){ return new AxisAlignedBB( - $this->x + (5/16), + $this->x + (5 / 16), $this->y, - $this->z + (5/16), - $this->x + (11/16), - $this->y + (6/16), - $this->z + (11/16) + $this->z + (5 / 16), + $this->x + (11 / 16), + $this->y + (6 / 16), + $this->z + (11 / 16) ); } diff --git a/src/pocketmine/block/Lever.php b/src/pocketmine/block/Lever.php index 04203e2aa..5e305854c 100644 --- a/src/pocketmine/block/Lever.php +++ b/src/pocketmine/block/Lever.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class Lever extends Solid { +class Lever extends Solid{ protected $id = self::LEVER; diff --git a/src/pocketmine/block/LitRedstoneLamp.php b/src/pocketmine/block/LitRedstoneLamp.php index 5257a1041..15f267af0 100644 --- a/src/pocketmine/block/LitRedstoneLamp.php +++ b/src/pocketmine/block/LitRedstoneLamp.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class LitRedstoneLamp extends Solid { +class LitRedstoneLamp extends Solid{ protected $id = self::LIT_REDSTONE_LAMP; diff --git a/src/pocketmine/block/LitRedstoneTorch.php b/src/pocketmine/block/LitRedstoneTorch.php index 46d05fc1a..30b40d62c 100644 --- a/src/pocketmine/block/LitRedstoneTorch.php +++ b/src/pocketmine/block/LitRedstoneTorch.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class LitRedstoneTorch extends Solid { +class LitRedstoneTorch extends Solid{ protected $id = self::REDSTONE_TORCH; diff --git a/src/pocketmine/block/MobHead.php b/src/pocketmine/block/MobHead.php index bfe034e32..7f4c3bb50 100644 --- a/src/pocketmine/block/MobHead.php +++ b/src/pocketmine/block/MobHead.php @@ -61,7 +61,7 @@ class MobHead extends Solid{ $nbt = new CompoundTag("", [ new StringTag("id", Tile::SKULL), new ByteTag("SkullType", $item->getDamage()), - new ByteTag("Rot", $rot), + new ByteTag("Rot", $rot), new IntTag("x", (int) $this->x), new IntTag("y", (int) $this->y), new IntTag("z", (int) $this->z) diff --git a/src/pocketmine/block/NetherBrickFence.php b/src/pocketmine/block/NetherBrickFence.php index 7d06e9f42..be32daf0a 100644 --- a/src/pocketmine/block/NetherBrickFence.php +++ b/src/pocketmine/block/NetherBrickFence.php @@ -23,7 +23,7 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\item\Tool; -class NetherBrickFence extends Transparent { +class NetherBrickFence extends Transparent{ protected $id = self::NETHER_BRICK_FENCE; @@ -32,11 +32,10 @@ class NetherBrickFence extends Transparent { } public function getBreakTime(Item $item){ - if ($item instanceof Air){ + if($item instanceof Air){ //Breaking by hand return 10; - } - else{ + }else{ // Other breaktimes are equal to woodfences. return parent::getBreakTime($item); } @@ -67,5 +66,5 @@ class NetherBrickFence extends Transparent { }else{ return []; } - } + } } diff --git a/src/pocketmine/block/NoteBlock.php b/src/pocketmine/block/NoteBlock.php index 0ae5cdda3..6c19d8ae8 100644 --- a/src/pocketmine/block/NoteBlock.php +++ b/src/pocketmine/block/NoteBlock.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class NoteBlock extends Solid { +class NoteBlock extends Solid{ protected $id = self::NOTE_BLOCK; diff --git a/src/pocketmine/block/PoweredRail.php b/src/pocketmine/block/PoweredRail.php index a34d67a54..40da67695 100644 --- a/src/pocketmine/block/PoweredRail.php +++ b/src/pocketmine/block/PoweredRail.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class PoweredRail extends Solid { +class PoweredRail extends Solid{ protected $id = self::POWERED_RAIL; public function __construct($meta = 0){ diff --git a/src/pocketmine/block/Rail.php b/src/pocketmine/block/Rail.php index 7121bae83..04f63bb16 100644 --- a/src/pocketmine/block/Rail.php +++ b/src/pocketmine/block/Rail.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class Rail extends Solid { +class Rail extends Solid{ protected $id = self::RAIL; diff --git a/src/pocketmine/block/RedstoneLamp.php b/src/pocketmine/block/RedstoneLamp.php index dff45170b..84bbd0503 100644 --- a/src/pocketmine/block/RedstoneLamp.php +++ b/src/pocketmine/block/RedstoneLamp.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class RedstoneLamp extends Solid { +class RedstoneLamp extends Solid{ protected $id = self::REDSTONE_LAMP; diff --git a/src/pocketmine/block/RedstoneTorch.php b/src/pocketmine/block/RedstoneTorch.php index 39bbd11ac..2932af565 100644 --- a/src/pocketmine/block/RedstoneTorch.php +++ b/src/pocketmine/block/RedstoneTorch.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class RedstoneTorch extends Solid { +class RedstoneTorch extends Solid{ protected $id = self::REDSTONE_TORCH; diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 0bf6ae950..a200d03d5 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -143,7 +143,6 @@ class Slab extends Transparent{ } - public function getToolType(){ return Tool::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/StoneButton.php b/src/pocketmine/block/StoneButton.php index 3b8e3dce4..ef69f4950 100644 --- a/src/pocketmine/block/StoneButton.php +++ b/src/pocketmine/block/StoneButton.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class StoneButton extends Solid { +class StoneButton extends Solid{ protected $id = self::STONE_BUTTON; diff --git a/src/pocketmine/block/StonePressurePlate.php b/src/pocketmine/block/StonePressurePlate.php index 4d10165e8..c741623ed 100644 --- a/src/pocketmine/block/StonePressurePlate.php +++ b/src/pocketmine/block/StonePressurePlate.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class StonePressurePlate extends Solid { +class StonePressurePlate extends Solid{ protected $id = self::STONE_PRESSURE_PLATE; diff --git a/src/pocketmine/block/Tripwire.php b/src/pocketmine/block/Tripwire.php index ac3e40cbc..f2f335217 100644 --- a/src/pocketmine/block/Tripwire.php +++ b/src/pocketmine/block/Tripwire.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class Tripwire extends Solid { +class Tripwire extends Solid{ protected $id = self::TRIPWIRE; diff --git a/src/pocketmine/block/TripwireHook.php b/src/pocketmine/block/TripwireHook.php index a94325370..5e6a576f2 100644 --- a/src/pocketmine/block/TripwireHook.php +++ b/src/pocketmine/block/TripwireHook.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class TripwireHook extends Solid { +class TripwireHook extends Solid{ protected $id = self::TRIPWIRE_HOOK; diff --git a/src/pocketmine/block/WallSign.php b/src/pocketmine/block/WallSign.php index 5be82cc1c..7de2fab32 100644 --- a/src/pocketmine/block/WallSign.php +++ b/src/pocketmine/block/WallSign.php @@ -39,8 +39,8 @@ class WallSign extends SignPost{ 5 => 4, ]; if($type === Level::BLOCK_UPDATE_NORMAL){ - if(isset($faces[$this->meta])) { - if ($this->getSide($faces[$this->meta])->getId() === self::AIR) { + if(isset($faces[$this->meta])){ + if($this->getSide($faces[$this->meta])->getId() === self::AIR){ $this->getLevel()->useBreakOn($this); } return Level::BLOCK_UPDATE_NORMAL; diff --git a/src/pocketmine/block/WeightedPressurePlateHeavy.php b/src/pocketmine/block/WeightedPressurePlateHeavy.php index 5592bea3a..1347a42d3 100644 --- a/src/pocketmine/block/WeightedPressurePlateHeavy.php +++ b/src/pocketmine/block/WeightedPressurePlateHeavy.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class WeightedPressurePlateHeavy extends Solid { +class WeightedPressurePlateHeavy extends Solid{ protected $id = self::WEIGHTED_PRESSURE_PLATE_HEAVY; diff --git a/src/pocketmine/block/WeightedPressurePlateLight.php b/src/pocketmine/block/WeightedPressurePlateLight.php index e1413f42b..d8dc2304d 100644 --- a/src/pocketmine/block/WeightedPressurePlateLight.php +++ b/src/pocketmine/block/WeightedPressurePlateLight.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class WeightedPressurePlateLight extends Solid { +class WeightedPressurePlateLight extends Solid{ protected $id = self::WEIGHTED_PRESSURE_PLATE_LIGHT; diff --git a/src/pocketmine/block/WoodenButton.php b/src/pocketmine/block/WoodenButton.php index a11376d45..36985130a 100644 --- a/src/pocketmine/block/WoodenButton.php +++ b/src/pocketmine/block/WoodenButton.php @@ -21,7 +21,7 @@ namespace pocketmine\block; -class WoodenButton extends Solid { +class WoodenButton extends Solid{ protected $id = self::WOODEN_BUTTON; diff --git a/src/pocketmine/block/WoodenPressurePlate.php b/src/pocketmine/block/WoodenPressurePlate.php index da81ff6a4..f11240894 100644 --- a/src/pocketmine/block/WoodenPressurePlate.php +++ b/src/pocketmine/block/WoodenPressurePlate.php @@ -25,7 +25,7 @@ class WoodenPressurePlate extends Solid{ protected $id = self::WOODEN_PRESSURE_PLATE; - public function __construct($meta = 0) { + public function __construct($meta = 0){ $this->meta = $meta; } diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 5cb6a4aee..04d32d5d8 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -289,7 +289,7 @@ abstract class Command{ public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){ if($message instanceof TextContainer){ $m = clone $message; - $result = "[".$source->getName().": ".($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() ."]"; + $result = "[" . $source->getName() . ": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() . "]"; $users = $source->getServer()->getPluginManager()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_ADMINISTRATIVE); $colored = TextFormat::GRAY . TextFormat::ITALIC . $result; diff --git a/src/pocketmine/command/defaults/GarbageCollectorCommand.php b/src/pocketmine/command/defaults/GarbageCollectorCommand.php index 1c785dfa6..0d6843ac3 100644 --- a/src/pocketmine/command/defaults/GarbageCollectorCommand.php +++ b/src/pocketmine/command/defaults/GarbageCollectorCommand.php @@ -64,7 +64,7 @@ class GarbageCollectorCommand extends VanillaCommand{ $sender->sendMessage(TextFormat::GOLD . "Tiles: " . TextFormat::RED . number_format($tilesCollected)); $sender->sendMessage(TextFormat::GOLD . "Cycles: " . TextFormat::RED . number_format($cyclesCollected)); - $sender->sendMessage(TextFormat::GOLD . "Memory freed: " . TextFormat::RED . number_format(round((($memory - memory_get_usage()) / 1024) / 1024, 2))." MB"); + $sender->sendMessage(TextFormat::GOLD . "Memory freed: " . TextFormat::RED . number_format(round((($memory - memory_get_usage()) / 1024) / 1024, 2)) . " MB"); return true; } } diff --git a/src/pocketmine/command/defaults/GiveCommand.php b/src/pocketmine/command/defaults/GiveCommand.php index b01d7edc5..f26f8b688 100644 --- a/src/pocketmine/command/defaults/GiveCommand.php +++ b/src/pocketmine/command/defaults/GiveCommand.php @@ -66,7 +66,7 @@ class GiveCommand extends VanillaCommand{ $data = implode(" ", array_slice($args, 3)); try{ $tags = NBT::parseJSON($data); - }catch (\Throwable $ex){ + }catch(\Throwable $ex){ $exception = $ex; } diff --git a/src/pocketmine/command/defaults/StatusCommand.php b/src/pocketmine/command/defaults/StatusCommand.php index 441dec7ff..54117e080 100644 --- a/src/pocketmine/command/defaults/StatusCommand.php +++ b/src/pocketmine/command/defaults/StatusCommand.php @@ -81,7 +81,7 @@ class StatusCommand extends VanillaCommand{ $tpsColor = TextFormat::RED; } - $sender->sendMessage(TextFormat::GOLD . "Current TPS: " . $tpsColor . $server->getTicksPerSecond() . " (".$server->getTickUsage()."%)"); + $sender->sendMessage(TextFormat::GOLD . "Current TPS: {$tpsColor}{$server->getTicksPerSecond()} ({$server->getTickUsage()}%)"); $sender->sendMessage(TextFormat::GOLD . "Network upload: " . TextFormat::RED . round($server->getNetwork()->getUpload() / 1024, 2) . " kB/s"); $sender->sendMessage(TextFormat::GOLD . "Network download: " . TextFormat::RED . round($server->getNetwork()->getDownload() / 1024, 2) . " kB/s"); @@ -99,11 +99,14 @@ class StatusCommand extends VanillaCommand{ } foreach($server->getLevels() as $level){ - $sender->sendMessage(TextFormat::GOLD . "World \"".$level->getFolderName()."\"".($level->getFolderName() !== $level->getName() ? " (".$level->getName().")" : "").": " . - TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " chunks, " . - TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " entities, " . - TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " tiles. ". - "Time " . (($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW) . round($level->getTickRateTime(), 2)."ms" . ($level->getTickRate() > 1 ? " (tick rate ". $level->getTickRate() .")" : "") + $levelName = $level->getFolderName() !== $level->getName() ? " (" . $level->getName() . ")" : ""; + $timeColor = ($level->getTickRate() > 1 or $level->getTickRateTime() > 40) ? TextFormat::RED : TextFormat::YELLOW; + $tickRate = $level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""; + $sender->sendMessage(TextFormat::GOLD . "World \"{$level->getFolderName()}\"$levelName: " . + TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " chunks, " . + TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " entities, " . + TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " tiles. " . + "Time $timeColor" . round($level->getTickRateTime(), 2) . "ms" . $tickRate ); } diff --git a/src/pocketmine/command/defaults/TellCommand.php b/src/pocketmine/command/defaults/TellCommand.php index 1c6902e6e..353333920 100644 --- a/src/pocketmine/command/defaults/TellCommand.php +++ b/src/pocketmine/command/defaults/TellCommand.php @@ -59,8 +59,9 @@ class TellCommand extends VanillaCommand{ } if($player instanceof Player){ - $sender->sendMessage("[".$sender->getName()." -> " . $player->getDisplayName() . "] " . implode(" ", $args)); - $player->sendMessage("[" . ($sender instanceof Player ? $sender->getDisplayName() : $sender->getName()) . " -> ".$player->getName()."] " . implode(" ", $args)); + $sender->sendMessage("[{$sender->getName()} -> {$player->getDisplayName()}] " . implode(" ", $args)); + $name = $sender instanceof Player ? $sender->getDisplayName() : $sender->getName(); + $player->sendMessage("[$name -> {$player->getName()}] " . implode(" ", $args)); }else{ $sender->sendMessage(new TranslationContainer("commands.generic.player.notFound")); } diff --git a/src/pocketmine/entity/AttributeMap.php b/src/pocketmine/entity/AttributeMap.php index 0c1960211..ba1450ad2 100644 --- a/src/pocketmine/entity/AttributeMap.php +++ b/src/pocketmine/entity/AttributeMap.php @@ -42,7 +42,7 @@ class AttributeMap implements \ArrayAccess{ * @return Attribute[] */ public function needSend() : array{ - return array_filter($this->attributes, function (Attribute $attribute){ + return array_filter($this->attributes, function(Attribute $attribute){ return $attribute->isSyncable() and $attribute->isDesynchronized(); }); } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 57d6f90cb..6a8423b02 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1533,7 +1533,7 @@ abstract class Entity extends Location implements Metadatable{ public function setDataProperty($id, $type, $value, $send = true){ if($this->getDataProperty($id) !== $value){ $this->dataProperties[$id] = [$type, $value]; - if($send === true) { + if($send === true){ $this->sendData($this->hasSpawned, [$id => $this->dataProperties[$id]]); } diff --git a/src/pocketmine/event/entity/EntityDamageByEntityEvent.php b/src/pocketmine/event/entity/EntityDamageByEntityEvent.php index 2ee816d20..ac511a242 100644 --- a/src/pocketmine/event/entity/EntityDamageByEntityEvent.php +++ b/src/pocketmine/event/entity/EntityDamageByEntityEvent.php @@ -61,12 +61,14 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{ public function getDamager(){ return $this->damager; } + /** * @return float */ public function getKnockBack(){ return $this->knockBack; } + /** * @param float $knockBack */ diff --git a/src/pocketmine/event/inventory/CraftItemEvent.php b/src/pocketmine/event/inventory/CraftItemEvent.php index a069c3dfa..b90ec02bb 100644 --- a/src/pocketmine/event/inventory/CraftItemEvent.php +++ b/src/pocketmine/event/inventory/CraftItemEvent.php @@ -40,8 +40,8 @@ class CraftItemEvent extends Event implements Cancellable{ /** * @param \pocketmine\Player $player - * @param Item[] $input - * @param Recipe $recipe + * @param Item[] $input + * @param Recipe $recipe */ public function __construct(Player $player, array $input, Recipe $recipe){ $this->player = $player; diff --git a/src/pocketmine/event/player/PlayerCreationEvent.php b/src/pocketmine/event/player/PlayerCreationEvent.php index 1b41cd7d4..1ba47dea2 100644 --- a/src/pocketmine/event/player/PlayerCreationEvent.php +++ b/src/pocketmine/event/player/PlayerCreationEvent.php @@ -47,8 +47,8 @@ class PlayerCreationEvent extends Event{ /** * @param SourceInterface $interface - * @param Player::class $baseClass - * @param Player::class $playerClass + * @param Player::class $baseClass + * @param Player::class $playerClass * @param mixed $clientId * @param string $address * @param int $port diff --git a/src/pocketmine/event/server/LowMemoryEvent.php b/src/pocketmine/event/server/LowMemoryEvent.php index b14a6ae13..8dfe8d3d1 100644 --- a/src/pocketmine/event/server/LowMemoryEvent.php +++ b/src/pocketmine/event/server/LowMemoryEvent.php @@ -20,6 +20,7 @@ */ namespace pocketmine\event\server; + use pocketmine\utils\Utils; diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 6975c450f..8ed844aaa 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -124,7 +124,7 @@ abstract class BaseInventory implements Inventory{ $this->clear($i); } }else{ - if (!$this->setItem($i, $items[$i])){ + if(!$this->setItem($i, $items[$i])){ $this->clear($i); } } @@ -248,7 +248,7 @@ abstract class BaseInventory implements Inventory{ $itemSlots = []; foreach($slots as $slot){ if(!($slot instanceof Item)){ - throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot)); + throw new \InvalidArgumentException("Expected Item[], got " . gettype($slot)); } if($slot->getId() !== 0 and $slot->getCount() > 0){ $itemSlots[] = clone $slot; @@ -308,7 +308,7 @@ abstract class BaseInventory implements Inventory{ $itemSlots = []; foreach($slots as $slot){ if(!($slot instanceof Item)){ - throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot)); + throw new \InvalidArgumentException("Expected Item[], got " . gettype($slot)); } if($slot->getId() !== 0 and $slot->getCount() > 0){ $itemSlots[] = clone $slot; diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index 87db62d85..753df96aa 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -47,45 +47,45 @@ class CraftingManager{ MainLogger::getLogger()->info("Loading recipes..."); foreach($recipes->getAll() as $recipe){ switch($recipe["Type"]){ - case 0: - // TODO: handle multiple result items - if(count($recipe["Result"]) == 1){ - $first = $recipe["Result"][0]; - $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"])); + case 0: + // TODO: handle multiple result items + if(count($recipe["Result"]) == 1){ + $first = $recipe["Result"][0]; + $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"])); - foreach($recipe["Ingredients"] as $ingredient){ - $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"])); - } - $this->registerRecipe($result); - } - break; - case 1: - // TODO: handle multiple result items - if(count($recipe["Result"]) == 1){ - $first = $recipe["Result"][0]; - $result = new ShapedRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]); - - $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]); - foreach($shape as $y => $row){ - foreach($row as $x => $ingredient){ - $result->addIngredient($x, $y, Item::get($ingredient["ID"], ($ingredient["Damage"] < 0 ? null : $ingredient["Damage"]), $ingredient["Count"])); + foreach($recipe["Ingredients"] as $ingredient){ + $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"])); } + $this->registerRecipe($result); } - $this->registerRecipe($result); - } - break; - case 2: - $result = $recipe["Result"]; - $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]); - $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1))); - break; - case 3: - $result = $recipe["Result"]; - $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]); - $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1))); - break; - default: - break; + break; + case 1: + // TODO: handle multiple result items + if(count($recipe["Result"]) == 1){ + $first = $recipe["Result"][0]; + $result = new ShapedRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]); + + $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]); + foreach($shape as $y => $row){ + foreach($row as $x => $ingredient){ + $result->addIngredient($x, $y, Item::get($ingredient["ID"], ($ingredient["Damage"] < 0 ? null : $ingredient["Damage"]), $ingredient["Count"])); + } + } + $this->registerRecipe($result); + } + break; + case 2: + $result = $recipe["Result"]; + $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]); + $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1))); + break; + case 3: + $result = $recipe["Result"]; + $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]); + $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1))); + break; + default: + break; } } } diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index c8f5c3b91..a0a471916 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -80,7 +80,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ for($i = 0; $i < $this->size; ++$i){ if(!isset($items[$i])){ - if ($i < $this->left->size){ + if($i < $this->left->size){ if(isset($this->left->slots[$i])){ $this->clear($i); } diff --git a/src/pocketmine/inventory/Inventory.php b/src/pocketmine/inventory/Inventory.php index 792e3dded..cadf65fa8 100644 --- a/src/pocketmine/inventory/Inventory.php +++ b/src/pocketmine/inventory/Inventory.php @@ -55,8 +55,8 @@ interface Inventory{ * 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 + * @param int $index + * @param Item $item * * @return bool */ @@ -161,7 +161,7 @@ interface Inventory{ /** * Will clear a specific slot * - * @param int $index + * @param int $index * * @return bool */ @@ -212,8 +212,8 @@ interface Inventory{ public function onClose(Player $who); /** - * @param int $index - * @param Item $before + * @param int $index + * @param Item $before */ public function onSlotChange($index, $before); } diff --git a/src/pocketmine/item/ItemIds.php b/src/pocketmine/item/ItemIds.php index 166e64a57..bf8460096 100644 --- a/src/pocketmine/item/ItemIds.php +++ b/src/pocketmine/item/ItemIds.php @@ -29,7 +29,7 @@ interface ItemIds extends BlockIds{ const IRON_SHOVEL = 256; const IRON_PICKAXE = 257; const IRON_AXE = 258; - const FLINT_AND_STEEL = 259; const FLINT_STEEL = 259; + const FLINT_AND_STEEL = 259, FLINT_STEEL = 259; const APPLE = 260; const BOW = 261; const ARROW = 262; @@ -50,13 +50,13 @@ interface ItemIds extends BlockIds{ const DIAMOND_SHOVEL = 277; const DIAMOND_PICKAXE = 278; const DIAMOND_AXE = 279; - const STICK = 280; const STICKS = 280; + const STICK = 280, STICKS = 280; const BOWL = 281; const MUSHROOM_STEW = 282; - const GOLD_SWORD = 283; const GOLDEN_SWORD = 283; - const GOLD_SHOVEL = 284; const GOLDEN_SHOVEL = 284; - const GOLD_PICKAXE = 285; const GOLDEN_PICKAXE = 285; - const GOLD_AXE = 286; const GOLDEN_AXE = 286; + const GOLD_SWORD = 283, GOLDEN_SWORD = 283; + const GOLD_SHOVEL = 284, GOLDEN_SHOVEL = 284; + const GOLD_PICKAXE = 285, GOLDEN_PICKAXE = 285; + const GOLD_AXE = 286, GOLDEN_AXE = 286; const STRING = 287; const FEATHER = 288; const GUNPOWDER = 289; @@ -64,8 +64,8 @@ interface ItemIds extends BlockIds{ const STONE_HOE = 291; const IRON_HOE = 292; const DIAMOND_HOE = 293; - const GOLD_HOE = 294; const GOLDEN_HOE = 294; - const SEEDS = 295; const WHEAT_SEEDS = 295; + const GOLD_HOE = 294, GOLDEN_HOE = 294; + const SEEDS = 295, WHEAT_SEEDS = 295; const WHEAT = 296; const BREAD = 297; const LEATHER_CAP = 298; @@ -94,21 +94,20 @@ interface ItemIds extends BlockIds{ const PAINTING = 321; const GOLDEN_APPLE = 322; const SIGN = 323; - const WOODEN_DOOR = 324; const OAK_DOOR = 324; + const WOODEN_DOOR = 324, OAK_DOOR = 324; const BUCKET = 325; const MINECART = 328; const SADDLE = 329; const IRON_DOOR = 330; - const REDSTONE = 331; - const REDSTONE_DUST = 331; + const REDSTONE = 331, REDSTONE_DUST = 331; const SNOWBALL = 332; const BOAT = 333; const LEATHER = 334; const BRICK = 336; const CLAY = 337; - const SUGARCANE = 338; const SUGAR_CANE = 338; const SUGAR_CANES = 338; + const SUGARCANE = 338, SUGAR_CANE = 338, SUGAR_CANES = 338; const PAPER = 339; const BOOK = 340; const SLIMEBALL = 341; @@ -130,18 +129,18 @@ interface ItemIds extends BlockIds{ const COOKIE = 357; const FILLED_MAP = 358; const SHEARS = 359; - const MELON = 360; const MELON_SLICE = 360; + const MELON = 360, MELON_SLICE = 360; const PUMPKIN_SEEDS = 361; const MELON_SEEDS = 362; const RAW_BEEF = 363; - const STEAK = 364; const COOKED_BEEF = 364; + const STEAK = 364, COOKED_BEEF = 364; const RAW_CHICKEN = 365; const COOKED_CHICKEN = 366; const ROTTEN_FLESH = 367; const BLAZE_ROD = 369; const GHAST_TEAR = 370; - const GOLD_NUGGET = 371; const GOLDEN_NUGGET = 371; + const GOLD_NUGGET = 371, GOLDEN_NUGGET = 371; const NETHER_WART = 372; const POTION = 373; const GLASS_BOTTLE = 374; @@ -154,19 +153,19 @@ interface ItemIds extends BlockIds{ const GLISTERING_MELON = 382; const SPAWN_EGG = 383; - const BOTTLE_O_ENCHANTING = 384; const ENCHANTING_BOTTLE = 384; + const BOTTLE_O_ENCHANTING = 384, ENCHANTING_BOTTLE = 384; const FIRE_CHARGE = 385; const EMERALD = 388; const ITEM_FRAME = 389; const FLOWER_POT = 390; - const CARROT = 391; const CARROTS = 391; - const POTATO = 392; const POTATOES = 392; - const BAKED_POTATO = 393; const BAKED_POTATOES = 393; + const CARROT = 391, CARROTS = 391; + const POTATO = 392, POTATOES = 392; + const BAKED_POTATO = 393, BAKED_POTATOES = 393; const POISONOUS_POTATO = 394; - const MAP = 395; const EMPTY_MAP = 395; + const MAP = 395, EMPTY_MAP = 395; const GOLDEN_CARROT = 396; - const MOB_HEAD = 397; const SKULL = 397; + const MOB_HEAD = 397, SKULL = 397; const CARROT_ON_A_STICK = 398; const PUMPKIN_PIE = 400; @@ -177,9 +176,7 @@ interface ItemIds extends BlockIds{ const QUARTZ = 406; const NETHER_QUARTZ = 406; const MINECART_WITH_TNT = 407; - const MINECART_WITH_HOPPER = 408; - - const HOPPER = 410; + const MINECART_WITH_HOPPER = 408, HOPPER = 410; const RAW_RABBIT = 411; const COOKED_RABBIT = 412; const RABBIT_STEW = 413; @@ -189,7 +186,7 @@ interface ItemIds extends BlockIds{ const IRON_HORSE_ARMOR = 417; const GOLD_HORSE_ARMOR = 418; const DIAMOND_HORSE_ARMOR = 419; - const LEAD = 420; const LEASH = 420; + const LEAD = 420, LEASH = 420; const NAMETAG = 421; const RAW_MUTTON = 423; @@ -204,7 +201,7 @@ interface ItemIds extends BlockIds{ const SPLASH_POTION = 438; const BEETROOT = 457; - const BEETROOT_SEEDS = 458; const BEETROOT_SEED = 458; + const BEETROOT_SEEDS = 458, BEETROOT_SEED = 458; const BEETROOT_SOUP = 459; const RAW_SALMON = 460; const CLOWN_FISH = 461; @@ -214,4 +211,4 @@ interface ItemIds extends BlockIds{ const ENCHANTED_GOLDEN_APPLE = 466; const CAMERA = 498; #blamemojang - } \ No newline at end of file +} diff --git a/src/pocketmine/lang/BaseLang.php b/src/pocketmine/lang/BaseLang.php index be1bbb170..ef079e700 100644 --- a/src/pocketmine/lang/BaseLang.php +++ b/src/pocketmine/lang/BaseLang.php @@ -86,7 +86,7 @@ class BaseLang{ */ public function translateString($str, array $params = [], $onlyPrefix = null){ $baseText = $this->get($str); - $baseText = $this->parseTranslation( ($baseText !== null and ($onlyPrefix === null or strpos($str, $onlyPrefix) === 0)) ? $baseText : $str, $onlyPrefix); + $baseText = $this->parseTranslation(($baseText !== null and ($onlyPrefix === null or strpos($str, $onlyPrefix) === 0)) ? $baseText : $str, $onlyPrefix); foreach($params as $i => $p){ $baseText = str_replace("{%$i}", $this->parseTranslation((string) $p), $baseText, $onlyPrefix); @@ -98,7 +98,7 @@ class BaseLang{ public function translate(TextContainer $c){ if($c instanceof TranslationContainer){ $baseText = $this->internalGet($c->getText()); - $baseText = $this->parseTranslation( $baseText !== null ? $baseText : $c->getText()); + $baseText = $this->parseTranslation($baseText !== null ? $baseText : $c->getText()); foreach($c->getParameters() as $i => $p){ $baseText = str_replace("{%$i}", $this->parseTranslation($p), $baseText); diff --git a/src/pocketmine/level/ChunkManager.php b/src/pocketmine/level/ChunkManager.php index 5725a34e9..aac28257d 100644 --- a/src/pocketmine/level/ChunkManager.php +++ b/src/pocketmine/level/ChunkManager.php @@ -19,7 +19,7 @@ * */ -declare(strict_types=1); +declare(strict_types = 1); namespace pocketmine\level; @@ -77,8 +77,8 @@ interface ChunkManager{ public function getChunk(int $chunkX, int $chunkZ); /** - * @param int $chunkX - * @param int $chunkZ + * @param int $chunkX + * @param int $chunkZ * @param FullChunk $chunk */ public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null); diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 0bfdcc234..b6d102bdf 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -19,7 +19,7 @@ * */ -declare(strict_types=1); +declare(strict_types = 1); /** * All Level related classes are here, like Generators, Populators, Noise, ... @@ -267,7 +267,7 @@ class Level implements ChunkManager, Metadatable{ } 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; + return PHP_INT_SIZE === 8 ? (($x & 0xFFFFFFF) << 35) | (($y & 0x7f) << 28) | ($z & 0xFFFFFFF) : $x . ":" . $y . ":" . $z; } public static function chunkBlockHash(int $x, int $y, int $z) : int{ @@ -378,14 +378,14 @@ class Level implements ChunkManager, Metadatable{ public function registerGenerator(){ $size = $this->server->getScheduler()->getAsyncTaskPoolSize(); for($i = 0; $i < $size; ++$i){ - $this->server->getScheduler()->scheduleAsyncTaskToWorker(new GeneratorRegisterTask($this, $this->generatorInstance), $i); + $this->server->getScheduler()->scheduleAsyncTaskToWorker(new GeneratorRegisterTask($this, $this->generatorInstance), $i); } } public function unregisterGenerator(){ $size = $this->server->getScheduler()->getAsyncTaskPoolSize(); for($i = 0; $i < $size; ++$i){ - $this->server->getScheduler()->scheduleAsyncTaskToWorker(new GeneratorUnregisterTask($this, $this->generatorInstance), $i); + $this->server->getScheduler()->scheduleAsyncTaskToWorker(new GeneratorUnregisterTask($this, $this->generatorInstance), $i); } } @@ -447,7 +447,7 @@ class Level implements ChunkManager, Metadatable{ }else{ $this->server->batchPackets($players, $pk, false); } - } + } } } @@ -707,7 +707,7 @@ class Level implements ChunkManager, Metadatable{ foreach($this->moveToSend as $index => $entry){ Level::getXZ($index, $chunkX, $chunkZ); - foreach($entry as $e) { + foreach($entry as $e){ $pk = new MoveEntityPacket(); $pk->eid = $e[0]; $pk->x = $e[1]; @@ -901,7 +901,6 @@ class Level implements ChunkManager, Metadatable{ Level::getXZ($index, $chunkX, $chunkZ); - if(!isset($this->chunks[$index]) or ($chunk = $this->getChunk($chunkX, $chunkZ, false)) === null){ unset($this->chunkTickList[$index]); continue; diff --git a/src/pocketmine/level/SimpleChunkManager.php b/src/pocketmine/level/SimpleChunkManager.php index 0de2d6d7a..4f0d5b8ec 100644 --- a/src/pocketmine/level/SimpleChunkManager.php +++ b/src/pocketmine/level/SimpleChunkManager.php @@ -19,7 +19,7 @@ * */ -declare(strict_types=1); +declare(strict_types = 1); namespace pocketmine\level; @@ -107,8 +107,8 @@ class SimpleChunkManager implements ChunkManager{ } /** - * @param int $chunkX - * @param int $chunkZ + * @param int $chunkX + * @param int $chunkZ * @param FullChunk $chunk */ public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null){ @@ -128,7 +128,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int */ - public function getSeed() { + public function getSeed(){ return $this->seed; } } \ No newline at end of file diff --git a/src/pocketmine/level/format/FullChunk.php b/src/pocketmine/level/format/FullChunk.php index d5f3e155a..df59d950d 100644 --- a/src/pocketmine/level/format/FullChunk.php +++ b/src/pocketmine/level/format/FullChunk.php @@ -173,9 +173,9 @@ interface FullChunk{ public function getHeightMap($x, $z); /** - * @param int $x 0-15 - * @param int $z 0-15 - * @param $value 0-255 + * @param int $x 0-15 + * @param int $z 0-15 + * @param $value 0-255 */ public function setHeightMap($x, $z, $value); diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index 25ecfd3ac..5cdc24ef9 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -40,8 +40,8 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ * @param ChunkSection[] $sections * @param int[] $biomeColors * @param int[] $heightMap - * @param CompoundTag[] $entities - * @param CompoundTag[] $tiles + * @param CompoundTag[] $entities + * @param CompoundTag[] $tiles * * @throws ChunkException */ diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index 9403656e4..0cc8aa6a0 100644 --- a/src/pocketmine/level/format/generic/BaseFullChunk.php +++ b/src/pocketmine/level/format/generic/BaseFullChunk.php @@ -82,8 +82,8 @@ abstract class BaseFullChunk implements FullChunk{ * @param string $blockLight * @param int[] $biomeColors * @param int[] $heightMap - * @param CompoundTag[] $entities - * @param CompoundTag[] $tiles + * @param CompoundTag[] $entities + * @param CompoundTag[] $tiles */ protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = []){ $this->provider = $provider; diff --git a/src/pocketmine/level/format/mcregion/RegionLoader.php b/src/pocketmine/level/format/mcregion/RegionLoader.php index 3c857d2e1..768018e0c 100644 --- a/src/pocketmine/level/format/mcregion/RegionLoader.php +++ b/src/pocketmine/level/format/mcregion/RegionLoader.php @@ -131,7 +131,7 @@ class RegionLoader{ protected function saveChunk($x, $z, $chunkData){ $length = strlen($chunkData) + 1; if($length + 4 > self::MAX_SECTOR_LENGTH){ - throw new ChunkException("Chunk is too big! ".($length + 4)." > ".self::MAX_SECTOR_LENGTH); + throw new ChunkException("Chunk is too big! " . ($length + 4) . " > " . self::MAX_SECTOR_LENGTH); } $sectors = (int) ceil(($length + 4) / 4096); $index = self::getChunkOffset($x, $z); diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 9785a8823..a77cb5364 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -159,7 +159,7 @@ class Flat extends Generator{ } public function generateChunk($chunkX, $chunkZ){ - if($this->chunk === null) { + if($this->chunk === null){ if(isset($this->options["preset"]) and $this->options["preset"] != ""){ $this->parsePreset($this->options["preset"], $chunkX, $chunkZ); }else{ diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index 2a68ea10a..401890484 100644 --- a/src/pocketmine/level/generator/Generator.php +++ b/src/pocketmine/level/generator/Generator.php @@ -88,7 +88,7 @@ abstract class Generator{ if($samplingRate === 0){ throw new \InvalidArgumentException("samplingRate cannot be 0"); } - if ($xSize % $samplingRate !== 0) { + if($xSize % $samplingRate !== 0){ throw new \InvalidArgumentCountException("xSize % samplingRate must return 0"); } diff --git a/src/pocketmine/level/generator/noise/Noise.php b/src/pocketmine/level/generator/noise/Noise.php index 72cd16248..2b02ab52d 100644 --- a/src/pocketmine/level/generator/noise/Noise.php +++ b/src/pocketmine/level/generator/noise/Noise.php @@ -61,7 +61,7 @@ abstract class Noise{ ); } - public static function trilinearLerp($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2) { + public static function trilinearLerp($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2){ $dx1 = (($x2 - $x) / ($x2 - $x1)); $dx2 = (($x - $x1) / ($x2 - $x1)); $dy1 = (($y2 - $y) / ($y2 - $y1)); diff --git a/src/pocketmine/level/generator/normal/Normal.php b/src/pocketmine/level/generator/normal/Normal.php index b678a9f6e..141f6208a 100644 --- a/src/pocketmine/level/generator/normal/Normal.php +++ b/src/pocketmine/level/generator/normal/Normal.php @@ -101,10 +101,10 @@ class Normal extends Generator{ $hash *= $hash + 223; $xNoise = $hash >> 20 & 3; $zNoise = $hash >> 22 & 3; - if ($xNoise == 3) { + if($xNoise == 3){ $xNoise = 1; } - if($zNoise == 3) { + if($zNoise == 3){ $zNoise = 1; } diff --git a/src/pocketmine/level/generator/normal/biome/DesertBiome.php b/src/pocketmine/level/generator/normal/biome/DesertBiome.php index 3ffd6d5dc..2a4e3db54 100644 --- a/src/pocketmine/level/generator/normal/biome/DesertBiome.php +++ b/src/pocketmine/level/generator/normal/biome/DesertBiome.php @@ -22,7 +22,6 @@ namespace pocketmine\level\generator\normal\biome; - class DesertBiome extends SandyBiome{ public function __construct(){ diff --git a/src/pocketmine/level/particle/FloatingTextParticle.php b/src/pocketmine/level/particle/FloatingTextParticle.php index d15be5f6e..680a3204e 100644 --- a/src/pocketmine/level/particle/FloatingTextParticle.php +++ b/src/pocketmine/level/particle/FloatingTextParticle.php @@ -37,8 +37,8 @@ class FloatingTextParticle extends Particle{ /** * @param Vector3 $pos - * @param int $text - * @param string $title + * @param int $text + * @param string $title */ public function __construct(Vector3 $pos, $text, $title = ""){ parent::__construct($pos->x, $pos->y, $pos->z); diff --git a/src/pocketmine/nbt/tag/NamedTag.php b/src/pocketmine/nbt/tag/NamedTag.php index 64302786b..1324c55e3 100644 --- a/src/pocketmine/nbt/tag/NamedTag.php +++ b/src/pocketmine/nbt/tag/NamedTag.php @@ -27,7 +27,7 @@ abstract class NamedTag extends Tag{ protected $__name; /** - * @param string $name + * @param string $name * @param bool|float|double|int|ByteTag|ShortTag|array|CompoundTag|ListTag|string $value */ public function __construct($name = "", $value = null){ diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 3a4500680..e123c301e 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -138,7 +138,7 @@ class Network{ public function processInterfaces(){ foreach($this->interfaces as $interface){ - try { + try{ $interface->process(); }catch(\Throwable $e){ $logger = $this->server->getLogger(); diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index f44c40afe..02cbc9a9e 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -169,10 +169,10 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $info = $this->server->getQueryInformation(); $this->interface->sendOption("name", - "MCPE;".addcslashes($name, ";") .";". - Info::CURRENT_PROTOCOL.";". - \pocketmine\MINECRAFT_VERSION_NETWORK.";". - $info->getPlayerCount().";". + "MCPE;" . addcslashes($name, ";") . ";" . + Info::CURRENT_PROTOCOL . ";" . + \pocketmine\MINECRAFT_VERSION_NETWORK . ";" . + $info->getPlayerCount() . ";" . $info->getMaxPlayerCount() ); } diff --git a/src/pocketmine/network/protocol/AddEntityPacket.php b/src/pocketmine/network/protocol/AddEntityPacket.php index b7a839d76..d1da7c8fd 100644 --- a/src/pocketmine/network/protocol/AddEntityPacket.php +++ b/src/pocketmine/network/protocol/AddEntityPacket.php @@ -59,8 +59,8 @@ class AddEntityPacket extends DataPacket{ $this->putFloat($this->speedX); $this->putFloat($this->speedY); $this->putFloat($this->speedZ); - $this->putFloat($this->yaw * (256/360)); - $this->putFloat($this->pitch * (256/360)); + $this->putFloat($this->yaw * (256 / 360)); + $this->putFloat($this->pitch * (256 / 360)); $this->putInt($this->modifiers); $meta = Binary::writeMetadata($this->metadata); $this->put($meta); diff --git a/src/pocketmine/network/protocol/LoginPacket.php b/src/pocketmine/network/protocol/LoginPacket.php index 284591d89..3370e10e1 100644 --- a/src/pocketmine/network/protocol/LoginPacket.php +++ b/src/pocketmine/network/protocol/LoginPacket.php @@ -49,7 +49,7 @@ class LoginPacket extends DataPacket{ $this->setBuffer($str, 0); $chainData = json_decode($this->get($this->getLInt())); - foreach ($chainData->{"chain"} as $chain){ + foreach($chainData->{"chain"} as $chain){ $webtoken = $this->decodeToken($chain); if(isset($webtoken["extraData"])){ if(isset($webtoken["extraData"]["displayName"])){ diff --git a/src/pocketmine/network/protocol/MoveEntityPacket.php b/src/pocketmine/network/protocol/MoveEntityPacket.php index 82eb8c65e..ffcb4aa61 100644 --- a/src/pocketmine/network/protocol/MoveEntityPacket.php +++ b/src/pocketmine/network/protocol/MoveEntityPacket.php @@ -40,9 +40,9 @@ class MoveEntityPacket extends DataPacket{ $this->x = $this->getFloat(); $this->y = $this->getFloat(); $this->z = $this->getFloat(); - $this->pitch = $this->getByte()*(360.0/256); - $this->yaw = $this->getByte()*(360.0/256); - $this->headYaw = $this->getByte()*(360.0/256); + $this->pitch = $this->getByte() * (360.0 / 256); + $this->yaw = $this->getByte() * (360.0 / 256); + $this->headYaw = $this->getByte() * (360.0 / 256); } public function encode(){ @@ -51,9 +51,9 @@ class MoveEntityPacket extends DataPacket{ $this->putFloat($this->x); $this->putFloat($this->y); $this->putFloat($this->z); - $this->putByte($this->pitch/(360.0/256)); - $this->putByte($this->yaw/(360.0/256)); - $this->putByte($this->headYaw/(360.0/256)); + $this->putByte($this->pitch / (360.0 / 256)); + $this->putByte($this->yaw / (360.0 / 256)); + $this->putByte($this->headYaw / (360.0 / 256)); } } diff --git a/src/pocketmine/network/rcon/RCON.php b/src/pocketmine/network/rcon/RCON.php index beb5c3c2b..b32e53c4d 100644 --- a/src/pocketmine/network/rcon/RCON.php +++ b/src/pocketmine/network/rcon/RCON.php @@ -83,7 +83,7 @@ class RCON{ }elseif($this->workers[$n]->isWaiting()){ if($this->workers[$n]->response !== ""){ $this->server->getLogger()->info($this->workers[$n]->response); - $this->workers[$n]->synchronized(function (RCONInstance $thread){ + $this->workers[$n]->synchronized(function(RCONInstance $thread){ $thread->notify(); }, $this->workers[$n]); }else{ @@ -98,7 +98,7 @@ class RCON{ } $this->workers[$n]->response = TextFormat::clean($response->getMessage()); - $this->workers[$n]->synchronized(function (RCONInstance $thread){ + $this->workers[$n]->synchronized(function(RCONInstance $thread){ $thread->notify(); }, $this->workers[$n]); } diff --git a/src/pocketmine/network/rcon/RCONInstance.php b/src/pocketmine/network/rcon/RCONInstance.php index 64e1009a3..6fdfbfec1 100644 --- a/src/pocketmine/network/rcon/RCONInstance.php +++ b/src/pocketmine/network/rcon/RCONInstance.php @@ -141,7 +141,7 @@ class RCONInstance extends Thread{ if($payload === $this->password){ socket_getpeername($client, $addr, $port); $this->response = "[INFO] Successful Rcon connection from: /$addr:$port"; - $this->synchronized(function (){ + $this->synchronized(function(){ $this->waiting = true; $this->wait(); }); @@ -162,7 +162,7 @@ class RCONInstance extends Thread{ } if(strlen($payload) > 0){ $this->cmd = ltrim($payload); - $this->synchronized(function (){ + $this->synchronized(function(){ $this->waiting = true; $this->wait(); }); diff --git a/src/pocketmine/scheduler/FileWriteTask.php b/src/pocketmine/scheduler/FileWriteTask.php index d76174d1a..494eb4a37 100644 --- a/src/pocketmine/scheduler/FileWriteTask.php +++ b/src/pocketmine/scheduler/FileWriteTask.php @@ -36,7 +36,7 @@ class FileWriteTask extends AsyncTask{ public function onRun(){ try{ file_put_contents($this->path, $this->contents, (int) $this->flags); - }catch (\Throwable $e){ + }catch(\Throwable $e){ } } diff --git a/src/pocketmine/scheduler/SendUsageTask.php b/src/pocketmine/scheduler/SendUsageTask.php index 686ba6d62..bd7d3003d 100644 --- a/src/pocketmine/scheduler/SendUsageTask.php +++ b/src/pocketmine/scheduler/SendUsageTask.php @@ -142,7 +142,7 @@ class SendUsageTask extends AsyncTask{ try{ Utils::postURL($this->endpoint, $this->data, 5, [ "Content-Type: application/json", - "Content-Length: ". strlen($this->data) + "Content-Length: " . strlen($this->data) ]); }catch(\Throwable $e){ diff --git a/src/pocketmine/tile/EnchantTable.php b/src/pocketmine/tile/EnchantTable.php index 0ddc33df9..3db36b337 100644 --- a/src/pocketmine/tile/EnchantTable.php +++ b/src/pocketmine/tile/EnchantTable.php @@ -47,10 +47,10 @@ class EnchantTable extends Spawnable implements Nameable{ public function getSpawnCompound(){ $c = new CompoundTag("", [ - new StringTag("id", Tile::ENCHANT_TABLE), - new IntTag("x", (int) $this->x), - new IntTag("y", (int) $this->y), - new IntTag("z", (int) $this->z) + new StringTag("id", Tile::ENCHANT_TABLE), + new IntTag("x", (int) $this->x), + new IntTag("y", (int) $this->y), + new IntTag("z", (int) $this->z) ]); if($this->hasName()){ diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index c7c2c48b7..b106b5262 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -67,10 +67,10 @@ abstract class Tile extends Position{ public $tickTimer; /** - * @param string $type - * @param FullChunk $chunk - * @param CompoundTag $nbt - * @param $args + * @param string $type + * @param FullChunk $chunk + * @param CompoundTag $nbt + * @param $args * * @return Tile */ diff --git a/src/pocketmine/utils/Binary.php b/src/pocketmine/utils/Binary.php index 5c129df4d..4fdfffd9b 100644 --- a/src/pocketmine/utils/Binary.php +++ b/src/pocketmine/utils/Binary.php @@ -23,6 +23,7 @@ * Various Utilities used around the code */ namespace pocketmine\utils; + use pocketmine\entity\Entity; class Binary{ diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index 1226ee308..25712b72e 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -20,6 +20,7 @@ */ namespace pocketmine\utils; + use pocketmine\scheduler\FileWriteTask; use pocketmine\Server; diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 65f02874e..4259f1edf 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -189,7 +189,7 @@ class MainLogger extends \AttachableThreadedLogger{ $threadName = (new \ReflectionClass($thread))->getShortName() . " thread"; } - $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] ". TextFormat::RESET . $color ."[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET); + $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET); $cleanMessage = TextFormat::clean($message); if(!Terminal::hasFormattingCodes()){ diff --git a/src/pocketmine/utils/Random.php b/src/pocketmine/utils/Random.php index 409d76359..13d8f54b8 100644 --- a/src/pocketmine/utils/Random.php +++ b/src/pocketmine/utils/Random.php @@ -71,7 +71,7 @@ class Random{ $this->seed = $seed; $this->x = self::X ^ $seed; $this->y = self::Y ^ ($seed << 17) | (($seed >> 15) & 0x7fffffff) & 0xffffffff; - $this->z = self::Z ^ ($seed << 31) | (($seed >> 1) & 0x7fffffff) & 0xffffffff; + $this->z = self::Z ^ ($seed << 31) | (($seed >> 1) & 0x7fffffff) & 0xffffffff; $this->w = self::W ^ ($seed << 18) | (($seed >> 14) & 0x7fffffff) & 0xffffffff; } @@ -100,7 +100,7 @@ class Random{ $this->y = $this->z; $this->z = $this->w; $this->w = ($this->w ^ (($this->w >> 19) & 0x7fffffff) - ^ ($t ^ (($t >> 8) & 0x7fffffff))) & 0xffffffff; + ^ ($t ^ (($t >> 8) & 0x7fffffff))) & 0xffffffff; return $this->w; } diff --git a/src/pocketmine/utils/TextFormat.php b/src/pocketmine/utils/TextFormat.php index b0055fe82..4fbb44c97 100644 --- a/src/pocketmine/utils/TextFormat.php +++ b/src/pocketmine/utils/TextFormat.php @@ -59,7 +59,7 @@ abstract class TextFormat{ * @return array */ public static function tokenize($string){ - return preg_split("/(". TextFormat::ESCAPE ."[0123456789abcdefklmnor])/", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); + return preg_split("/(" . TextFormat::ESCAPE . "[0123456789abcdefklmnor])/", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); } /** @@ -72,7 +72,7 @@ abstract class TextFormat{ */ public static function clean($string, $removeFormat = true){ if($removeFormat){ - return str_replace(TextFormat::ESCAPE, "", preg_replace(["/". TextFormat::ESCAPE ."[0123456789abcdefklmnor]/", "/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/"], "", $string)); + return str_replace(TextFormat::ESCAPE, "", preg_replace(["/" . TextFormat::ESCAPE . "[0123456789abcdefklmnor]/", "/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/"], "", $string)); } return str_replace("\x1b", "", preg_replace("/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/", "", $string)); }