Fix unsit on teleport

This commit is contained in:
Shevchik 2013-12-15 19:27:25 +04:00
parent ef9f272a57
commit 4710e5b10d

View File

@ -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)