Skip to content

Commit 49cf7c6

Browse files
authored
Fix modifying blocks always being cancelled (#208)
1 parent 117af59 commit 49cf7c6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bukkit/src/main/java/org/popcraft/bolt/listeners/BlockListener.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,19 @@ public void onBlockPlace(final BlockPlaceEvent e) {
203203
}
204204
final Block block = replaced.getBlock();
205205
final Protection protection = plugin.findProtection(block);
206-
if (protection != null) {
206+
if (protection == null) {
207+
return;
208+
}
209+
if (Tag.REPLACEABLE.isTagged(e.getBlockReplacedState().getType())) {
207210
// Prevent accidental deletion of protected blocks by them getting replaced.
208211
// Purposefully not checking for destroy permissions, that logic is for BlockBreakEvent.
209212
e.setCancelled(true);
213+
} else {
214+
// This is, bafflingly, fired in cases like stripping a log (which *also* called EntityChangeBlockEvent)
215+
// but also fired in other cases, like placing a slab on top of another.
216+
if (!plugin.canAccess(block, e.getPlayer(), Permission.INTERACT)) {
217+
e.setCancelled(true);
218+
}
210219
}
211220
}
212221

0 commit comments

Comments
 (0)