Skip to content

Commit

Permalink
Fix toggle effect not working (#1527)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Sep 10, 2018
1 parent 21e0102 commit f6dd0c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/ch/njol/skript/effects/EffToggle.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;

Expand Down Expand Up @@ -129,11 +130,16 @@ protected void execute(final Event e) {
return;
}

// 1.13 and newer: use Openable BlockData
// 1.13 and newer: use BlockData
for (Block b : blocks.getArray(e)) {
BlockData data = b.getBlockData();
if (data instanceof Openable) // open = NOT was open
if (data instanceof Openable) { // open = NOT was open
((Openable) data).setOpen(!((Openable) data).isOpen());
b.setBlockData(data);
} else if (data instanceof Powerable) { // power = NOT power
((Powerable) data).setPowered(!((Powerable) data).isPowered());
b.setBlockData(data);
}
}
}

Expand Down

0 comments on commit f6dd0c9

Please sign in to comment.