From 4e06336c99b7138b657e3f235ce59dcdf43e961f Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 21 Jan 2014 21:12:50 -0600 Subject: [PATCH] Simple way of stopping players from getting respawned outside the jail. Something more complicated might be needed, but I will add that as the time arises. --- .../graywolf336/jail/listeners/PlayerListener.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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()); + } + } + } }