From 9436ce451a0e77e72f275b453fd1f4928c2dd585 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 26 Jan 2021 10:07:12 +0100 Subject: [PATCH] Fixes #2460 --- CHANGELOG.md | 1 + .../items/electric/machines/BookBinder.java | 2 +- .../items/tools/ExplosiveTool.java | 35 ++++++------------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 318bcfb4c..905e11673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ * Fixed #2754 * Fixed machines not respecting max size from inventories * Fixed #2761 +* Fixed #2460 ## Release Candidate 19 (11 Jan 2021) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/BookBinder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/BookBinder.java index 1052c3b57..5f8355715 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/BookBinder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/BookBinder.java @@ -106,7 +106,7 @@ public class BookBinder extends AContainer { Map enchantments = new HashMap<>(); boolean conflicts = false; enchantments.putAll(ech1); - + for (Map.Entry entry : ech2.entrySet()) { for (Map.Entry conflictsWith : enchantments.entrySet()) { if (entry.getKey().conflictsWith(conflictsWith.getKey())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index 9589ef7a5..da52e9750 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -3,17 +3,17 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; import java.util.ArrayList; import java.util.List; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; @@ -44,6 +44,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla private final ItemSetting damageOnUse = new ItemSetting<>("damage-on-use", true); private final ItemSetting callExplosionEvent = new ItemSetting<>("call-explosion-event", false); + @ParametersAreNonnullByDefault public ExplosiveTool(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -60,11 +61,12 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F); List blocks = findBlocks(b); - breakBlocks(p, tool, b, blocks, fortune, drops); + breakBlocks(p, tool, b, blocks, drops); }; } - private void breakBlocks(Player p, ItemStack item, Block b, List blocks, int fortune, List drops) { + @ParametersAreNonnullByDefault + private void breakBlocks(Player p, ItemStack item, Block b, List blocks, List drops) { if (callExplosionEvent.getValue().booleanValue()) { BlockExplodeEvent blockExplodeEvent = new BlockExplodeEvent(b, blocks, 0); Bukkit.getServer().getPluginManager().callEvent(blockExplodeEvent); @@ -72,14 +74,14 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla if (!blockExplodeEvent.isCancelled()) { for (Block block : blockExplodeEvent.blockList()) { if (canBreak(p, block)) { - breakBlock(p, item, block, fortune, drops); + breakBlock(p, item, block, drops); } } } } else { for (Block block : blocks) { if (canBreak(p, block)) { - breakBlock(p, item, block, fortune, drops); + breakBlock(p, item, block, drops); } } } @@ -123,7 +125,8 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla } } - private void breakBlock(Player p, ItemStack item, Block b, int fortune, List drops) { + @ParametersAreNonnullByDefault + private void breakBlock(Player p, ItemStack item, Block b, List drops) { SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK); Material material = b.getType(); @@ -136,24 +139,8 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) { drops.add(BlockStorage.retrieve(b)); } - } else if (material == Material.PLAYER_HEAD || SlimefunTag.SHULKER_BOXES.isTagged(material)) { - b.breakNaturally(item); } else { - // Check if the block was mined using Silk Touch - if (item.containsEnchantment(Enchantment.SILK_TOUCH)) { - b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(b.getType())); - } else { - boolean applyFortune = SlimefunTag.FORTUNE_COMPATIBLE_ORES.isTagged(material); - - for (ItemStack drop : b.getDrops(getItem())) { - // For some reason this check is necessary with Paper - if (drop != null && drop.getType() != Material.AIR) { - b.getWorld().dropItemNaturally(b.getLocation(), applyFortune ? new CustomItem(drop, fortune) : drop); - } - } - } - - b.setType(Material.AIR); + b.breakNaturally(item); } damageItem(p, item);