From 0518df44840db4af20567bacf2ec5297d6260d84 Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Wed, 8 Mar 2023 00:16:12 +0300 Subject: [PATCH] /place testing and fixed players on join --- src/API/LevelAPI.php | 6 ++++++ src/Player.php | 7 ++++--- src/structure/Structure.php | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index 3e9d3c11..7e3d18d3 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -18,6 +18,7 @@ class LevelAPI{ $this->server->api->console->register("save-on", "", [$this, "commandHandler"]); $this->server->api->console->register("save-off", "", [$this, "commandHandler"]); $this->server->api->console->register("setwspawn", "Set the spawn position for your current world. ", [$this, "commandHandler"]); + $this->server->api->console->register("place", "", [$this, "commandHandler"]); $this->default = $this->server->api->getProperty("level-name"); if($this->loadLevel($this->default) === false){ $this->generateLevel($this->default, $this->server->seed); @@ -160,6 +161,11 @@ class LevelAPI{ public function commandHandler($cmd, $params, $issuer, $alias){ $output = ""; switch($cmd){ + case "place": + if(!isset($params[0]) or $params[0] == "") return "/$cmd "; + $class = $params[0]; + (new $class())->build($issuer->entity->level, $issuer->entity->x, $issuer->entity->y, $issuer->entity->z); + break; case "setwspawn": if(!($issuer instanceof Player)){ return ("Please run this command in-game. "); diff --git a/src/Player.php b/src/Player.php index 2006adbf..ea6df2f7 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1482,11 +1482,10 @@ class Player{ //$this->server->schedule(20, array($this, "teleport"), $pos); //$this->teleport($pos, isset($pData["yaw"]) ? $pData["yaw"] : false, isset($pData["pitch"]) ? $pData["pitch"] : false, true, true); $this->entity->setHealth($this->data->get("health"), "spawn", true); - $this->server->api->player->spawnAllPlayers($this); - $this->server->api->player->spawnToAllPlayers($this); + $this->server->api->chat->broadcast($this->username." joined the game"); + $this->server->api->entity->spawnAll($this); $this->server->api->entity->spawnToAll($this->entity); - $this->server->api->chat->broadcast($this->username." joined the game"); $this->server->schedule(5, [$this->entity, "update"], [], true); $this->server->schedule(2, [$this->entity, "updateMovement"], [], true); @@ -1507,6 +1506,8 @@ class Player{ $this->blocked = false; $this->spawned = true; $this->server->handle("player.spawn", $this); + $this->server->api->player->spawnAllPlayers($this); + $this->server->api->player->spawnToAllPlayers($this); break; case ProtocolInfo::ROTATE_HEAD_PACKET: if($this->spawned === false){ diff --git a/src/structure/Structure.php b/src/structure/Structure.php index b41e6471..80a1eef1 100644 --- a/src/structure/Structure.php +++ b/src/structure/Structure.php @@ -123,6 +123,7 @@ abstract class Structure{ } $offsetZ = 0; } + console("builded! ".$this->name); } } \ No newline at end of file