diff --git a/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java b/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java index 27e0892d..f3dd1934 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/PistonProtectionListener.java @@ -1,5 +1,7 @@ package com.gamingmesh.jobs.listeners; +import java.util.List; + import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -10,6 +12,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.stuff.Debug; public class PistonProtectionListener implements Listener { @@ -30,10 +33,10 @@ public class PistonProtectionListener implements Listener { int x = dir.getModX(), y = dir.getModY(), z = dir.getModZ(); - for (Block one : event.getBlocks()) { + for (int i = event.getBlocks().size() - 1; i >= 0; i--) { + Block one = event.getBlocks().get(i); Location oldLoc = one.getLocation(); Location newLoc = oldLoc.clone().add(x, y, z); - Long bp = Jobs.getBpManager().getTime(oldLoc); if (bp != null) { Jobs.getBpManager().addP(newLoc, bp, true, true); @@ -59,8 +62,9 @@ public class PistonProtectionListener implements Listener { int x = dir.getModX(), y = dir.getModY(), z = dir.getModZ(); - - for (Block one : Jobs.getNms().getPistonRetractBlocks(event)) { + List blocks = Jobs.getNms().getPistonRetractBlocks(event); + for (int i = blocks.size() - 1; i >= 0; i--) { + Block one = blocks.get(i); Location oldLoc = one.getLocation(); Location newLoc = oldLoc.clone().add(x, y, z); Long bp = Jobs.getBpManager().getTime(oldLoc);