Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Use bed location for respawning if it is set
Browse files Browse the repository at this point in the history
Resolves GH-174

Signed-off-by: Evan Maddock <maddock.evan@vivaldi.net>
  • Loading branch information
EbonJaeger committed Apr 9, 2020
1 parent 47f486a commit d167fe4
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,25 @@ class PlayerRespawnListener @Inject constructor(private val groupManager: GroupM
{

@EventHandler(priority = EventPriority.LOW)
fun onPlayerRespawn(event: PlayerRespawnEvent)
{
if (!settings.getProperty(PluginSettings.MANAGE_DEATH_RESPAWN)) return
fun onPlayerRespawn(event: PlayerRespawnEvent) {
// Do nothing if managing respawns is disabled in the config
if (!settings.getProperty(PluginSettings.MANAGE_DEATH_RESPAWN)) {
return
}

val group = groupManager.getGroupFromWorld(event.player.location.world!!.name) // The server will never provide a null world in a Location

// Check for a bed location in the group
val bedLocation = event.player.bedSpawnLocation
if (bedLocation != null) {
// Set the spawn location to the bed and return if it's in the same group
if (group.containsWorld(bedLocation.world!!.name)) {
event.respawnLocation = bedLocation
return
}
}

// Set the respawn location to the world set in the config
val respawnWorld = group.respawnWorld
if (respawnWorld != null && group.containsWorld(respawnWorld)) {
val world = Bukkit.getWorld(respawnWorld)
Expand Down

0 comments on commit d167fe4

Please sign in to comment.