Skip to content

Commit

Permalink
GH-572 Add support to respawn points (#574)
Browse files Browse the repository at this point in the history
* Add support to respawn

* Add missing comment
  • Loading branch information
P1otrulla authored Dec 10, 2023
1 parent 2c55b55 commit d6f1514
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public static class Teleport implements SpawnSettings {
@Description("# Teleports the player to spawn after death")
public boolean teleportToSpawnOnDeath = true;

@Description("# Teleports the player to respawn point after death")
public boolean teleportToRespawnPoint = true;

@Description("# Time of teleportation to spawn")
public Duration teleportTimeToSpawn = Duration.ofSeconds(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class SpawnRespawnController implements Listener {
void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();

if (this.config.teleport.teleportToRespawnPoint && this.hasRespawnPoint(player)) {
return;
}

Position spawnPosition = this.locations.spawn;

if (this.config.teleport.teleportToSpawnOnDeath && !Objects.equals(spawnPosition.getWorld(), Position.NONE_WORLD)) {
Expand All @@ -41,4 +45,8 @@ void onPlayerRespawn(PlayerRespawnEvent event) {
}
}

boolean hasRespawnPoint(Player player) {
return player.getBedSpawnLocation() != null;
}

}
2 changes: 1 addition & 1 deletion eternalcore-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ eternalShadowCompiler {

tasks {
runServer {
minecraftVersion("1.20.1")
minecraftVersion("1.20")
}
}

0 comments on commit d6f1514

Please sign in to comment.