Commit 6c908234 authored by Amosar's avatar Amosar

Fix issue with delay variable not respected

parent 3559ff9f
......@@ -25,13 +25,15 @@ public class ObserverListener implements Listener {
} else {
RedstoneClock redstoneClock = RedstoneClockController.getRedstoneClock(e.getBlock().getLocation());
if (redstoneClock.getLastStatus() == 1) {
if (!redstoneClock.isEnd()) {
if (!redstoneClock.isTimedOut()) {
if (redstoneClock.getNumberOfClock() >= Main.getInstance().getConfig().getInt("MaxPulses")) {
Util.removeRedstoneClock(e.getBlock());
} else {
redstoneClock.addOneToClock();
redstoneClock.updateStatus(0);
}
} else {
RedstoneClockController.removeRedstoneByObject(redstoneClock);
}
} else {
redstoneClock.updateStatus(1);
......
......@@ -16,13 +16,15 @@ public class PistonListener implements Listener {
if (RedstoneClockController.contains(e.getBlock().getLocation())) {
RedstoneClock redstoneClock = RedstoneClockController.getRedstoneClock(e.getBlock().getLocation());
if (redstoneClock.getLastStatus() == 1) {
if (!redstoneClock.isEnd()) {
if (!redstoneClock.isTimedOut()) {
if (redstoneClock.getNumberOfClock() >= Main.getInstance().getConfig().getInt("MaxPulses")) {
Util.removeRedstoneClock(e.getBlock());
} else {
redstoneClock.addOneToClock();
redstoneClock.updateStatus(0);
}
} else {
RedstoneClockController.removeRedstoneByObject(redstoneClock);
}
}
} else {
......
......@@ -21,13 +21,16 @@ class Util {
e1.printStackTrace();
}
} else {
if (!RedstoneClockController.getRedstoneClock(block.getLocation()).isEnd()) {
if (RedstoneClockController.getRedstoneClock(block.getLocation()).getNumberOfClock()
RedstoneClock redstoneClock = RedstoneClockController.getRedstoneClock(block.getLocation());
if (!redstoneClock.isTimedOut()) {
if (redstoneClock.getNumberOfClock()
>= Main.getInstance().getConfig().getInt("MaxPulses")) {
removeRedstoneClock(block);
} else {
RedstoneClockController.getRedstoneClock(block.getLocation()).addOneToClock();
redstoneClock.addOneToClock();
}
} else {
RedstoneClockController.removeRedstoneByObject(redstoneClock);
}
}
}
......
......@@ -38,7 +38,7 @@ public class RedstoneClock {
return value;
}
public boolean isEnd() {
public boolean isTimedOut() {
return (System.currentTimeMillis() / 1000) >= endTime;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment