Skip to content

Commit b7e89b4

Browse files
authored
Better handling of bucket emptying and filling (#203)
1 parent 4d571ca commit b7e89b4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,17 +413,33 @@ public void onBlockIgnite(final BlockIgniteEvent e) {
413413

414414
@EventHandler
415415
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent e) {
416+
final Protection protection = plugin.findProtection(e.getBlock());
417+
if (protection == null) {
418+
return;
419+
}
416420
final Player player = e.getPlayer();
417-
if (!plugin.canAccess(e.getBlockClicked(), player, Permission.INTERACT) || !plugin.canAccess(e.getBlock(), player, Permission.DESTROY)) {
421+
if (e.getBlock().equals(e.getBlockClicked()) && Tag.CAULDRONS.isTagged(e.getBlock().getType())) {
422+
if (!plugin.canAccess(protection, player, Permission.INTERACT, Permission.DEPOSIT)) {
423+
e.setCancelled(true);
424+
}
425+
} else if (!e.getBlock().equals(e.getBlockClicked())) {
426+
// Prevent accidental deletion of protected blocks by them getting replaced.
427+
// Purposefully not checking for destroy permissions, that logic is for BlockBreakEvent.
418428
e.setCancelled(true);
419429
}
420430
}
421431

422432
@EventHandler
423433
public void onPlayerBucketFill(final PlayerBucketFillEvent e) {
434+
final Protection protection = plugin.findProtection(e.getBlock());
435+
if (protection == null) {
436+
return;
437+
}
424438
final Player player = e.getPlayer();
425-
if (!plugin.canAccess(e.getBlockClicked(), player, Permission.INTERACT) || !plugin.canAccess(e.getBlock(), player, Permission.DESTROY)) {
426-
e.setCancelled(true);
439+
if (e.getBlock().equals(e.getBlockClicked()) && Tag.CAULDRONS.isTagged(e.getBlock().getType())) {
440+
if (!plugin.canAccess(protection, player, Permission.INTERACT, Permission.WITHDRAW)) {
441+
e.setCancelled(true);
442+
}
427443
}
428444
}
429445

0 commit comments

Comments
 (0)