From c5630791c06e56d63b55885813672088fce973d0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 2 Sep 2020 12:19:18 +0200 Subject: [PATCH] Added item break sound to some tools --- CHANGELOG.md | 1 + .../slimefun4/core/attributes/DamageableItem.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84675ddc2..51ab92717 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ * Added Nitwit Rune * Added Synthetic Shulker Shells * Added Climbing Pick +* Added item breaking sounds to some slimefun tools #### Changes * Performance improvement for Programmable Android rotations diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java index 40580562d..d4421b997 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java @@ -1,6 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -43,7 +47,7 @@ public interface DamageableItem extends ItemAttribute { * @param item * The {@link ItemStack} to damage */ - default void damageItem(Player p, ItemStack item) { + default void damageItem(@Nonnull Player p, @Nullable ItemStack item) { if (isDamageable() && item != null && item.getType() != Material.AIR && item.getAmount() > 0) { if (item.getEnchantments().containsKey(Enchantment.DURABILITY) && Math.random() * 100 <= (60 + Math.floorDiv(40, (item.getEnchantmentLevel(Enchantment.DURABILITY) + 1)))) { return; @@ -53,6 +57,7 @@ public interface DamageableItem extends ItemAttribute { Damageable damageable = (Damageable) meta; if (damageable.getDamage() >= item.getType().getMaxDurability()) { + p.playSound(p.getEyeLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); item.setAmount(0); } else {