From ed4f820ff328f3f1d1dfdf8d6cdc5c3c0ed26ffd Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 17 Aug 2024 16:10:23 +0300 Subject: [PATCH] readded return in reset spawn pos & some fixes to formatting --- src/API/PluginAPI.php | 4 ++-- src/Player.php | 7 ++++--- src/entity/Entity.php | 2 +- src/entity/animal/Chicken.php | 4 ++-- src/entity/object/Arrow.php | 4 ++-- src/functions.php | 18 +++++++++--------- src/material/block/StairBlock.php | 4 ++-- src/material/block/solid/GrassBlock.php | 4 ++-- src/utils/Utils.php | 2 +- 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/API/PluginAPI.php b/src/API/PluginAPI.php index a9eb0158..5e98b6ce 100644 --- a/src/API/PluginAPI.php +++ b/src/API/PluginAPI.php @@ -55,8 +55,8 @@ class PluginAPI extends stdClass{ return; } foreach($this->plugins as $p){ - if(method_exists($p[0], "__destruct")){$p[0]->__destruct();} - } + if(method_exists($p[0], "__destruct")) $p[0]->__destruct(); + } unset($this->plugins); } diff --git a/src/Player.php b/src/Player.php index 6743ac42..7ffc2077 100755 --- a/src/Player.php +++ b/src/Player.php @@ -413,7 +413,7 @@ class Player{ * @return Item */ public function getSlot($slot){ - return $this->inventory[(int)$slot] ?? BlockAPI::getItem(AIR, 0, 0); + return $this->inventory[(int)$slot] ?? BlockAPI::getItem(AIR, 0, 0); } /** @@ -720,7 +720,7 @@ class Player{ * @return Item */ public function getArmor($slot){ - return $this->armor[(int)$slot] ?? BlockAPI::getItem(AIR, 0, 0); + return $this->armor[(int)$slot] ?? BlockAPI::getItem(AIR, 0, 0); } public function setArmor($slot, Item $armor, $send = true){ @@ -1029,7 +1029,8 @@ class Player{ } } } - reset_spawn_pos: + return; + reset_spawn_pos: $this->spawnPosition = $this->server->api->level->getDefault()->getSpawn(); } } diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 7c4a05e0..e3d70fa1 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1496,7 +1496,7 @@ class Entity extends Position { if($this->class === ENTITY_PLAYER){ $this->player->teleport(new Vector3($this->x, $this->y, $this->z), false, false, true, false); - } + } } public function moveEntityWithOffset($oX, $oY, $oZ) diff --git a/src/entity/animal/Chicken.php b/src/entity/animal/Chicken.php index f4e7e266..2b19cd1a 100644 --- a/src/entity/animal/Chicken.php +++ b/src/entity/animal/Chicken.php @@ -36,8 +36,8 @@ class Chicken extends Animal{ } public function fall(){} //chickens have no fall dmg? - - public function dropAnEgg(){ + + public function dropAnEgg(){ if($this->closed){ return; } diff --git a/src/entity/object/Arrow.php b/src/entity/object/Arrow.php index 1b84c920..693b6377 100644 --- a/src/entity/object/Arrow.php +++ b/src/entity/object/Arrow.php @@ -139,7 +139,7 @@ class Arrow extends Entity{ ++$this->groundTicks; if($this->groundTicks >= 1200){ //TODO customizeable? $this->close(); - } + } }else{ $this->inGround = false; $this->speedX *= lcg_value() * 0.2; @@ -277,4 +277,4 @@ class Arrow extends Entity{ $player->dataPacket($pk); } } -} \ No newline at end of file +} diff --git a/src/functions.php b/src/functions.php index 4717289a..a3e6e3bf 100644 --- a/src/functions.php +++ b/src/functions.php @@ -118,7 +118,7 @@ function arg($name, $default = false){ $arguments = arguments($argv); } - return $arguments["commands"][$name] ?? $default; + return $arguments["commands"][$name] ?? $default; } function arguments($args){ @@ -159,7 +159,7 @@ function arguments($args){ $ret['input'][] = $arg; - } + } return $ret; } @@ -175,13 +175,13 @@ function console($message, $EOL = true, $log = true, $level = 1){ if(ENABLE_ANSI === true){ $add = ""; if(preg_match("/\[([a-zA-Z0-9]*)\]/", $message, $matches) > 0){ - $add .= match ($matches[1]) { - "ERROR", "SEVERE" => FORMAT_RED, - "INTERNAL", "DEBUG" => FORMAT_WHITE, - "WARNING" => FORMAT_YELLOW, - "NOTICE" => FORMAT_AQUA, - default => FORMAT_GRAY, - }; + $add .= match ($matches[1]) { + "ERROR", "SEVERE" => FORMAT_RED, + "INTERNAL", "DEBUG" => FORMAT_WHITE, + "WARNING" => FORMAT_YELLOW, + "NOTICE" => FORMAT_AQUA, + default => FORMAT_GRAY, + }; } $message = TextFormat::toANSI($time . $add . $message . FORMAT_RESET); }else{ diff --git a/src/material/block/StairBlock.php b/src/material/block/StairBlock.php index 4a29e2a4..9af56b50 100644 --- a/src/material/block/StairBlock.php +++ b/src/material/block/StairBlock.php @@ -80,7 +80,7 @@ class StairBlock extends TransparentBlock{ for($v15 = 0; $v15 < /*count($v11}*/ 2; ++$v15){ $v16 = $v11[$v15]; if($v16 == $v12){ - //wat + //wat } } @@ -360,4 +360,4 @@ class StairBlock extends TransparentBlock{ return array(); } } -} \ No newline at end of file +} diff --git a/src/material/block/solid/GrassBlock.php b/src/material/block/solid/GrassBlock.php index 66d4ddbe..c258af29 100644 --- a/src/material/block/solid/GrassBlock.php +++ b/src/material/block/solid/GrassBlock.php @@ -45,7 +45,7 @@ class GrassBlock extends SolidBlock{ ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(295,0,1)); return; } - } + } public static function onRandomTick(Level $level, $x, $y, $z){ if(!StaticBlock::getIsTransparent($level->level->getBlockID($x, $y + 1, $z)) && mt_rand(0, 2) == 1){ $level->fastSetBlockUpdate($x, $y, $z, DIRT, 0); @@ -64,4 +64,4 @@ class GrassBlock extends SolidBlock{ } } -} \ No newline at end of file +} diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 705eeda3..c2cfb754 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -564,7 +564,7 @@ class Utils{ } public static function readBool($b){ - return !(Utils::readByte($b, false) === 0); + return Utils::readByte($b, false) != 0; } public static function writeBool($b){