Unsit player on teleport

This commit is contained in:
Shevchik 2013-11-14 16:43:24 +04:00
parent 6f077baebd
commit 16fce317a1
3 changed files with 16 additions and 6 deletions

View File

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

View File

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

View File

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