Skip to content

Commit

Permalink
fix: use current location rather than previous location when respawning
Browse files Browse the repository at this point in the history
  • Loading branch information
Thatsmusic99 committed Jun 5, 2023
1 parent 5caad3c commit 74c715f
Showing 1 changed file with 3 additions and 6 deletions.
Expand Up @@ -91,15 +91,12 @@ public void onDeath(PlayerDeathEvent e) {
@EventHandler(priority = EventPriority.HIGHEST)
public void onRespawn(PlayerRespawnEvent e) {
if (e.getPlayer().hasMetadata("NPC")) return;
CoreClass.debug("Respawn event triggered for " + e.getPlayer().getName() + ".");
ATPlayer atPlayer = ATPlayer.getPlayer(e.getPlayer());
Location location = e.getPlayer().getLocation();
CoreClass.debug("Respawn event triggered for " + e.getPlayer().getName() + ". Location: " + location);
if (NewConfig.get().USE_SPAWN.get()) {
CoreClass.debug("Spawning feature is enabled.");
if (atPlayer.getPreviousLocation() == null) return;
if (atPlayer.getPreviousLocation().getWorld() == null) return;
CoreClass.debug("Player has a previous location to go back to.");
ConfigSection deathManagement = NewConfig.get().DEATH_MANAGEMENT.get();
String spawnCommand = deathManagement.getString(atPlayer.getPreviousLocation().getWorld().getName());
String spawnCommand = deathManagement.getString(location.getWorld().getName());
if (spawnCommand == null || spawnCommand.equals("{default}")) {
spawnCommand = deathManagement.getString("default");
if (spawnCommand == null) return;
Expand Down

0 comments on commit 74c715f

Please sign in to comment.