From cbc0c4bc8bf0afd56005699ce70f86ec9b637646 Mon Sep 17 00:00:00 2001 From: kernitus <2789734+kernitus@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:32:05 +0000 Subject: [PATCH] fix: error when right clicking air while holding block in <1.13 Closes #754 --- .../OldCombatMechanics/module/ModuleSwordBlocking.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/kernitus/plugin/OldCombatMechanics/module/ModuleSwordBlocking.java b/src/main/java/kernitus/plugin/OldCombatMechanics/module/ModuleSwordBlocking.java index 3374e748..c9f34152 100644 --- a/src/main/java/kernitus/plugin/OldCombatMechanics/module/ModuleSwordBlocking.java +++ b/src/main/java/kernitus/plugin/OldCombatMechanics/module/ModuleSwordBlocking.java @@ -10,6 +10,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -82,8 +83,11 @@ public void onRightClick(PlayerInteractEvent e) { // TODO right-clicking on a mob also only fires one hand if (action == Action.RIGHT_CLICK_BLOCK && e.getHand() == EquipmentSlot.HAND) return; if (e.isBlockInHand()){ - if(lastInteractedBlocks != null) - lastInteractedBlocks.put(e.getClickedBlock().getLocation(), player.getUniqueId()); + if(lastInteractedBlocks != null) { + final Block clickedBlock = e.getClickedBlock(); + if(clickedBlock != null) + lastInteractedBlocks.put(clickedBlock.getLocation(), player.getUniqueId()); + } return; // Handle failed block place in separate listener }