Skip to content

Commit

Permalink
Fixes #2352 obsidian scooping NPE (#2358)
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento authored May 8, 2024
1 parent d889179 commit b8e1f33
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.RayTraceResult;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.flags.FlagListener;
Expand Down Expand Up @@ -68,12 +69,20 @@ boolean onPlayerInteract(final PlayerInteractEvent e) {
return lookForLava(e);
}

/**
* @param e PlayerInteractEvent
* @return false if obsidian not scooped, true if scooped
*/
private boolean lookForLava(PlayerInteractEvent e) {
Player player = e.getPlayer();
ItemStack bucket = e.getItem();

// Get block player is looking at
Block b = e.getPlayer().rayTraceBlocks(5, FluidCollisionMode.ALWAYS).getHitBlock();
RayTraceResult rtBlocks = e.getPlayer().rayTraceBlocks(5, FluidCollisionMode.ALWAYS);
if (rtBlocks == null) {
return false;
}
Block b = rtBlocks.getHitBlock();
if (!b.getType().equals(Material.OBSIDIAN)) {
// This should not be needed but might catch some attempts
return false;
Expand Down

0 comments on commit b8e1f33

Please sign in to comment.