diff --git a/src/com/cnaude/chairs/Chairs.java b/src/com/cnaude/chairs/Chairs.java index 9a64b81..962138c 100644 --- a/src/com/cnaude/chairs/Chairs.java +++ b/src/com/cnaude/chairs/Chairs.java @@ -147,11 +147,11 @@ public class Chairs extends JavaPlugin { } },100); } - protected void unSitPlayer(final Player player) + protected void unSitPlayer(final Player player, boolean ignoretp) { player.eject(); final Location tploc = sitstopteleportloc.get(player.getName()); - if (tploc != null) + if (tploc != null && !ignoretp) { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ public void run() diff --git a/src/com/cnaude/chairs/EventListener.java b/src/com/cnaude/chairs/EventListener.java index 17b0439..5df81a3 100644 --- a/src/com/cnaude/chairs/EventListener.java +++ b/src/com/cnaude/chairs/EventListener.java @@ -16,6 +16,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.material.Stairs; import org.bukkit.material.Step; import org.bukkit.material.WoodenStep; @@ -49,7 +50,16 @@ public class EventListener implements Listener { if (plugin.sit.containsKey(player.getName())) { plugin.savePlayerSitstoploc(player.getName()); - plugin.unSitPlayer(player); + plugin.unSitPlayer(player,true); + } + } + + @EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) + public void onTeleport(PlayerTeleportEvent e) + { + if (plugin.sit.containsKey(e.getPlayer().getName())) + { + plugin.unSitPlayer(e.getPlayer(), true); } } @@ -60,7 +70,7 @@ public class EventListener implements Listener { if (plugin.sitblock.containsKey(b)) { Player player = Bukkit.getPlayerExact(plugin.sitblock.get(b)); - plugin.unSitPlayer(player); + plugin.unSitPlayer(player,false); } } diff --git a/src/com/cnaude/chairs/PacketListener.java b/src/com/cnaude/chairs/PacketListener.java index 8c34102..df22854 100644 --- a/src/com/cnaude/chairs/PacketListener.java +++ b/src/com/cnaude/chairs/PacketListener.java @@ -41,7 +41,7 @@ public class PacketListener { //just eject player if he is sitting on chair if (pluginInstance.sit.containsKey(player.getName())) { - pluginInstance.unSitPlayer(player); + pluginInstance.unSitPlayer(player,false); } } } @@ -68,7 +68,7 @@ public class PacketListener { Player player = e.getPlayer(); if (pluginInstance.sit.containsKey(player.getName())) { - pluginInstance.unSitPlayer(player); + pluginInstance.unSitPlayer(player,false); } } }