From a15b437249cf3eb17875fc5bed2dcce5b4637f9f Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 21 Sep 2024 17:08:58 -0700 Subject: [PATCH] NPE fix for #2512 --- .../listeners/flags/protection/BreakBlocksListener.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java index f80aa0d85..6ac05ad87 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java @@ -84,6 +84,9 @@ public class BreakBlocksListener extends FlagListener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteract(final PlayerInteractEvent e) { + if (e.getClickedBlock() == null) { + return; + } Player p = e.getPlayer(); Location l = e.getClickedBlock().getLocation(); Material m = e.getClickedBlock().getType(); @@ -95,7 +98,7 @@ public class BreakBlocksListener extends FlagListener { if (((CaveVinesPlant) e.getClickedBlock().getBlockData()).isBerries()) { this.checkIsland(e, p, l, Flags.HARVEST); } - } + } case SWEET_BERRY_BUSH -> this.checkIsland(e, p, l, Flags.HARVEST); case ROOTED_DIRT -> this.checkIsland(e, p, l, Flags.BREAK_BLOCKS); default -> { // Do nothing