diff --git a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java index 6682721..8fbe30a 100644 --- a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java +++ b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java @@ -13,6 +13,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailManager; @@ -116,4 +117,17 @@ public class PlayerListener implements Listener { } } } + + @EventHandler + public void onPlayerRespawn(PlayerRespawnEvent event) { + if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) { + Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName()); + + if(j.isJailedInACell(event.getPlayer().getName())) { + event.setRespawnLocation(j.getCellPrisonerIsIn(event.getPlayer().getName()).getTeleport()); + }else { + event.setRespawnLocation(j.getTeleportIn()); + } + } + } }