Cache occupied block

This commit is contained in:
Shevchik 2015-01-17 15:50:56 +04:00
parent 10d0661066
commit 3d63334cbb

View File

@ -44,9 +44,9 @@ public class PlayerSitData {
player.sendMessage(plugin.msgSitting); player.sendMessage(plugin.msgSitting);
} }
SitData sitdata = new SitData(); SitData sitdata = new SitData();
Location arrowloc = sitlocation.getBlock().getLocation().add(0.5, 0 , 0.5); Entity arrow = plugin.getNMSAccess().spawnArrow(sitlocation.getBlock().getLocation().add(0.5, 0 , 0.5));
Entity arrow = plugin.getNMSAccess().spawnArrow(arrowloc);
sitdata.arrow = arrow; sitdata.arrow = arrow;
sitdata.block = blocktooccupy;
sitdata.teleportloc = player.getLocation(); sitdata.teleportloc = player.getLocation();
int task = Bukkit.getScheduler().scheduleSyncRepeatingTask( int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(
plugin, plugin,
@ -70,7 +70,7 @@ public class PlayerSitData {
public void reSitPlayer(final Player player) { public void reSitPlayer(final Player player) {
SitData sitdata = sit.get(player); SitData sitdata = sit.get(player);
sitdata.sitting = false; sitdata.sitting = false;
final Entity prevarrow = sit.get(player).arrow; Entity prevarrow = sit.get(player).arrow;
Entity arrow = plugin.getNMSAccess().spawnArrow(prevarrow.getLocation()); Entity arrow = plugin.getNMSAccess().spawnArrow(prevarrow.getLocation());
arrow.setPassenger(player); arrow.setPassenger(player);
sitdata.arrow = arrow; sitdata.arrow = arrow;
@ -98,7 +98,7 @@ public class PlayerSitData {
sitdata.arrow.remove(); sitdata.arrow.remove();
player.teleport(playerunsitevent.getTeleportLocation().clone()); player.teleport(playerunsitevent.getTeleportLocation().clone());
player.setSneaking(false); player.setSneaking(false);
sitblock.values().remove(player); sitblock.remove(sitdata.block);
Bukkit.getScheduler().cancelTask(sitdata.resittask); Bukkit.getScheduler().cancelTask(sitdata.resittask);
sit.remove(player); sit.remove(player);
if (plugin.notifyplayer) { if (plugin.notifyplayer) {
@ -113,6 +113,7 @@ public class PlayerSitData {
private Entity arrow; private Entity arrow;
private Location teleportloc; private Location teleportloc;
private int resittask; private int resittask;
private Block block;
} }