diff --git a/src/com/cnaude/chairs/Chairs.java b/src/com/cnaude/chairs/Chairs.java index 38d7d4c..1f83a4a 100644 --- a/src/com/cnaude/chairs/Chairs.java +++ b/src/com/cnaude/chairs/Chairs.java @@ -116,11 +116,18 @@ public class Chairs extends JavaPlugin { protected void reSitPlayer(final Player player) { player.eject(); - sit.get(player.getName()).remove(); + final Entity prevarrow = sit.get(player.getName()); Block block = sitblockbr.get(player.getName()); - Entity arrow = block.getWorld().spawnArrow(block.getLocation().add(0.5, 0, 0.5), new Vector(0, 0, 0), 0, 0); - arrow.setPassenger(player); - sit.put(player.getName(), arrow); + final Entity arrow = block.getWorld().spawnArrow(block.getLocation().add(0.5, 0, 0.5), new Vector(0, 0, 0), 0, 0); + arrow.setPassenger(player); + sit.put(player.getName(), arrow); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() + { + public void run() + { + prevarrow.remove(); + } + },40); } protected void ejectPlayer(final Player player) { diff --git a/src/com/cnaude/chairs/PacketListener.java b/src/com/cnaude/chairs/PacketListener.java index 027a4ea..3848b14 100644 --- a/src/com/cnaude/chairs/PacketListener.java +++ b/src/com/cnaude/chairs/PacketListener.java @@ -17,6 +17,7 @@ public class PacketListener { this.pm = pm; this.pluginInstance = plugin; playerDismountListener(); + falledPlayerDismountListener(); } @@ -50,6 +51,31 @@ public class PacketListener { } + private void falledPlayerDismountListener() + { + pm.getAsynchronousManager().registerAsyncHandler( + new PacketAdapter(PacketAdapter + .params(pluginInstance, Packets.Client.ENTITY_ACTION) + .clientSide() + .listenerPriority(ListenerPriority.HIGHEST) + .optionIntercept() + ) + { + @Override + public void onPacketReceiving(final PacketEvent e) + { + if (!e.isCancelled()) + { + Player player = e.getPlayer(); + if (pluginInstance.sit.containsKey(player.getName())) + { + pluginInstance.ejectPlayer(player); + } + } + } + }).syncStart(); + } + diff --git a/target/Chairs.jar b/target/Chairs.jar index 1c1ac2c..7f19ca7 100644 Binary files a/target/Chairs.jar and b/target/Chairs.jar differ