diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index add8713..f426199 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -294,7 +294,7 @@ public class BlockEventHandler implements Listener //If block is a chest, don't allow a DoubleChest to form across a claim boundary denyConnectingDoubleChestsAcrossClaimBoundary(claim, block, player); - + if (claim != null) { playerData.lastClaim = claim; @@ -861,7 +861,7 @@ public class BlockEventHandler implements Listener Block block = event.getHitBlock(); // Ensure projectile affects block. - if (block == null || block.getType() != Material.CHORUS_FLOWER) + if (block == null || !(block.getType() == Material.CHORUS_FLOWER || block.getType() == Material.TARGET)) return; Claim claim = dataStore.getClaimAt(block.getLocation(), false, null); @@ -871,8 +871,8 @@ public class BlockEventHandler implements Listener Player shooter = null; Projectile projectile = event.getEntity(); - if (projectile.getShooter() instanceof Player) - shooter = (Player) projectile.getShooter(); + if (projectile.getShooter() instanceof Player player) + shooter = player; if (shooter == null) { @@ -880,13 +880,20 @@ public class BlockEventHandler implements Listener return; } - Supplier allowContainer = claim.checkPermission(shooter, ClaimPermission.Inventory, event); + Supplier allowAction = claim.checkPermission( + shooter, + switch (block.getType()) + { + case CHORUS_FLOWER -> ClaimPermission.Inventory; + case TARGET -> ClaimPermission.Access; + default -> ClaimPermission.Build; + }, + event); - if (allowContainer != null) + if (allowAction != null) { event.setCancelled(true); - GriefPrevention.sendMessage(shooter, TextMode.Err, allowContainer.get()); - return; + GriefPrevention.sendMessage(shooter, TextMode.Err, allowAction.get()); } }