diff --git a/src/com/cnaude/chairs/EventListener.java b/src/com/cnaude/chairs/EventListener.java index a0aeebe..d2568c4 100644 --- a/src/com/cnaude/chairs/EventListener.java +++ b/src/com/cnaude/chairs/EventListener.java @@ -11,8 +11,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.material.Stairs; import org.bukkit.material.Step; import org.bukkit.material.WoodenStep; @@ -39,36 +37,6 @@ public class EventListener implements Listener { return false; } - @EventHandler - public void onVehicleExitEvent(VehicleExitEvent event) { - Entity e = event.getVehicle().getPassenger(); - if (e instanceof Player) { - Player player = (Player) e; - if (plugin.sit.containsKey(player.getName())) { - unSit(player); - } - } - } - - @EventHandler - public void onPlayerMoveEvent(PlayerMoveEvent event) { - if (event.getFrom().distance(event.getTo()) > 0) { - Player player = event.getPlayer(); - if (plugin.sit.containsKey(player.getName())) { - if (plugin.sit.get(player.getName()).getLocation().distance(player.getLocation()) > 0.5) { - unSit(player); - } - } - } - } - - private void unSit(Player player) { - plugin.sit.get(player.getName()).remove(); - plugin.sit.remove(player.getName()); - if (plugin.notifyplayer && !plugin.msgStanding.isEmpty()) { - player.sendMessage(plugin.msgStanding); - } - } private boolean isSitting(Player player) { if (player.isInsideVehicle()) { @@ -80,6 +48,14 @@ public class EventListener implements Listener { } return false; } + + private void unSit(Player player) { + plugin.sit.get(player.getName()).remove(); + plugin.sit.remove(player.getName()); + if (plugin.notifyplayer && !plugin.msgStanding.isEmpty()) { + player.sendMessage(plugin.msgStanding); + } + } @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { diff --git a/src/com/cnaude/chairs/PacketListener.java b/src/com/cnaude/chairs/PacketListener.java index 22cce63..2182053 100644 --- a/src/com/cnaude/chairs/PacketListener.java +++ b/src/com/cnaude/chairs/PacketListener.java @@ -3,6 +3,7 @@ package com.cnaude.chairs; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_6_R2.entity.CraftArrow; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import com.comphenix.protocol.Packets; import com.comphenix.protocol.ProtocolManager; @@ -37,31 +38,42 @@ public class PacketListener { { if (!e.isCancelled()) { - final String playername = e.getPlayer().getName(); + final Player player = e.getPlayer(); if (e.getPacket().getBooleans().getValues().get(1)) { - e.getAsyncMarker().incrementProcessingDelay(); + final Entity arrow = pluginInstance.sit.get(player.getName()); + if (arrow != null) + { + net.minecraft.server.v1_6_R2.EntityArrow nmsarrow = ((CraftArrow) arrow).getHandle(); + nmsarrow.motX = 0; + nmsarrow.motY = 0; + nmsarrow.motZ = 0; + nmsarrow.boundingBox.b = -1; + } Bukkit.getScheduler().scheduleSyncDelayedTask(pluginInstance, new Runnable() { public void run() { - Entity arrow = pluginInstance.sit.get(playername); - if (arrow != null) - { - net.minecraft.server.v1_6_R2.EntityArrow nmsarrow = ((CraftArrow) arrow).getHandle(); - nmsarrow.motX = 0; - nmsarrow.motY = 0; - nmsarrow.motZ = 0; - nmsarrow.boundingBox.b = -1; - } - pm.getAsynchronousManager().signalPacketTransmission(e); + unSit(player); } - }); + },1); } } } - }).start(); + }).syncStart(); } + + + private void unSit(Player player) { + if (pluginInstance.sit.containsKey(player.getName())) + { + pluginInstance.sit.get(player.getName()).remove(); + pluginInstance.sit.remove(player.getName()); + if (pluginInstance.notifyplayer && !pluginInstance.msgStanding.isEmpty()) { + player.sendMessage(pluginInstance.msgStanding); + } + } + } } diff --git a/target/Chairs.jar b/target/Chairs.jar index 48b3186..b9d439d 100644 Binary files a/target/Chairs.jar and b/target/Chairs.jar differ