From 3d63334cbb6494faf6d03f17b201b380723560ce Mon Sep 17 00:00:00 2001 From: Shevchik Date: Sat, 17 Jan 2015 15:50:56 +0400 Subject: [PATCH] Cache occupied block --- src/com/cnaude/chairs/core/PlayerSitData.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/cnaude/chairs/core/PlayerSitData.java b/src/com/cnaude/chairs/core/PlayerSitData.java index f9b609e..6b4983a 100644 --- a/src/com/cnaude/chairs/core/PlayerSitData.java +++ b/src/com/cnaude/chairs/core/PlayerSitData.java @@ -44,9 +44,9 @@ public class PlayerSitData { player.sendMessage(plugin.msgSitting); } SitData sitdata = new SitData(); - Location arrowloc = sitlocation.getBlock().getLocation().add(0.5, 0 , 0.5); - Entity arrow = plugin.getNMSAccess().spawnArrow(arrowloc); + Entity arrow = plugin.getNMSAccess().spawnArrow(sitlocation.getBlock().getLocation().add(0.5, 0 , 0.5)); sitdata.arrow = arrow; + sitdata.block = blocktooccupy; sitdata.teleportloc = player.getLocation(); int task = Bukkit.getScheduler().scheduleSyncRepeatingTask( plugin, @@ -70,7 +70,7 @@ public class PlayerSitData { public void reSitPlayer(final Player player) { SitData sitdata = sit.get(player); sitdata.sitting = false; - final Entity prevarrow = sit.get(player).arrow; + Entity prevarrow = sit.get(player).arrow; Entity arrow = plugin.getNMSAccess().spawnArrow(prevarrow.getLocation()); arrow.setPassenger(player); sitdata.arrow = arrow; @@ -98,7 +98,7 @@ public class PlayerSitData { sitdata.arrow.remove(); player.teleport(playerunsitevent.getTeleportLocation().clone()); player.setSneaking(false); - sitblock.values().remove(player); + sitblock.remove(sitdata.block); Bukkit.getScheduler().cancelTask(sitdata.resittask); sit.remove(player); if (plugin.notifyplayer) { @@ -113,6 +113,7 @@ public class PlayerSitData { private Entity arrow; private Location teleportloc; private int resittask; + private Block block; }