Add skipping conditions for redstone current change.

This commit is contained in:
asofold 2016-12-07 21:18:29 +01:00
parent ef9492b0bc
commit 06c2cadf7f

View File

@ -114,11 +114,9 @@ public class BlockChangeListener implements Listener {
}
final List<Block> blocks;
if (retractHasBlocks) {
// TODO: Legacy: Set flag in constructor (getRetractLocation).
blocks = event.getBlocks();
}
else {
// TODO: Use getRetractLocation.
@SuppressWarnings("deprecation")
final Location retLoc = event.getRetractLocation();
if (retLoc == null) {
@ -163,6 +161,11 @@ public class BlockChangeListener implements Listener {
if (!enabled) {
return;
}
final int oldCurrent = event.getOldCurrent();
final int newCurrent = event.getNewCurrent();
if (oldCurrent == newCurrent || oldCurrent > 0 && newCurrent > 0) {
return;
}
// TODO: Fine grained enabling state (pistons, doors, other).
final Block block = event.getBlock();
// TODO: Abstract method for a block and a set of materials (redstone, interact, ...).