1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00

We need to invert block list to properly process moved blocks bp

This commit is contained in:
Zrips 2020-08-25 12:59:21 +03:00
parent 0df98f0246
commit 2d2b6ccb60

View File

@ -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<Block> 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);