Skip to content

Commit

Permalink
Fix for #20, #17 and #10
Browse files Browse the repository at this point in the history
This commit fixes some little bugs, this is a part of theSpawn V1.4.0. It was commit before the release of V1.4.0 because some Issues has reported some bugs with this.
  • Loading branch information
supercrafter333 authored Aug 19, 2021
1 parent 2f14f53 commit 8fb71d4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/supercrafter333/theSpawn/theSpawn.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ public function onPlayerLogin(PlayerLoginEvent $event)
$hub = $this->getHub();
if ($hub !== null) {
$event->getPlayer()->teleport($hub);
}
} elseif ($this->getServer()->getDefaultLevel()->getSafeSpawn() !== null) {
$event->getPlayer()->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
} else return;
}
}

Expand All @@ -220,10 +222,17 @@ public function onPlayerRespawn(PlayerRespawnEvent $event)
$spawn = new Config($this->getDataFolder() . "theSpawns.yml", Config::YAML);
$levelname = $s->getLevel()->getName();
$level = $this->getServer()->getLevelByName($levelname);
if ($spawn->exists($levelname)) {
if ($level === null) {
if ($this->getHub() instanceof Position) {
$event->setRespawnPosition($this->getHub());
} else {
$event->setRespawnPosition($this->getServer()->getDefaultLevel()->getSafeSpawn());
}
}
if ($this->getSpawn($level) instanceof Position) {
$event->setRespawnPosition($this->getSpawn($level));
$s->getLevel()->addSound(new PopSound($s));
} elseif ($this->getHub() !== false) {
} elseif ($this->getHub() instanceof Position) {
$event->setRespawnPosition($this->getHub());
$s->getLevel()->addSound(new PopSound($s));
} else {
Expand All @@ -232,7 +241,6 @@ public function onPlayerRespawn(PlayerRespawnEvent $event)
} else {
$event->setRespawnPosition($level->getSafeSpawn());
}
$s->getLevel()->addSound(new PopSound($s));
}
/*if ($this->getSpawn($levelname)) {
if ($this->getServer()->isLevelLoaded($levelname) == true && !$level == null) {
Expand Down

0 comments on commit 8fb71d4

Please sign in to comment.