From 4710e5b10da79d143ec0f550c05537b5519b0253 Mon Sep 17 00:00:00 2001 From: Shevchik Date: Sun, 15 Dec 2013 19:27:25 +0400 Subject: [PATCH] Fix unsit on teleport --- src/com/cnaude/chairs/TryUnsitEventListener.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/com/cnaude/chairs/TryUnsitEventListener.java b/src/com/cnaude/chairs/TryUnsitEventListener.java index ea342ba..b28fbb2 100644 --- a/src/com/cnaude/chairs/TryUnsitEventListener.java +++ b/src/com/cnaude/chairs/TryUnsitEventListener.java @@ -3,6 +3,7 @@ package com.cnaude.chairs; import java.util.HashSet; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -35,11 +36,21 @@ public class TryUnsitEventListener implements Listener { @EventHandler(priority=EventPriority.LOWEST) public void onPlayerTeleport(PlayerTeleportEvent event) { - Player player = event.getPlayer(); + final Player player = event.getPlayer(); if (plugin.sit.containsKey(player.getName())) { plugin.unSitPlayer(player, false, false); } + event.setCancelled(true); + final Location loc = event.getTo(); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() + { + public void run() + { + player.teleport(loc); + player.setSneaking(false); + } + },1); } @EventHandler(priority=EventPriority.LOWEST)