Fixed piston

This commit is contained in:
boy0001 2015-04-09 23:12:35 +10:00
parent b0050dd2e8
commit 6ec4668177

View File

@ -18,6 +18,7 @@ import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LargeFireball;
@ -662,7 +663,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (plot != null) {
BlockFace face = event.getDirection();
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
for (final Block b : event.getBlocks()) {
List<Block> blocks = event.getBlocks();
for (final Block b : blocks) {
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
Plot newPlot = MainUtil.getPlot(bloc);
if (!plot.equals(newPlot)) {
@ -670,6 +672,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return;
}
}
org.bukkit.Location lastLoc;
if (blocks.size() > 0) {
lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative);
}
else {
lastLoc = event.getBlock().getLocation().add(relative);
}
Entity[] ents = lastLoc.getChunk().getEntities();
for (Entity entity : ents) {
if (entity instanceof FallingBlock) {
org.bukkit.Location eloc = entity.getLocation();
if (eloc.distanceSquared(lastLoc) < 2) {
event.setCancelled(true);
return;
}
}
}
}
}