From 492cb63065f404f3c141415e268ed00a4878b184 Mon Sep 17 00:00:00 2001 From: zrdzn Date: Tue, 14 Jun 2022 21:26:54 +0200 Subject: [PATCH] GH-24 Change the way silktouch enchantment works --- .../minecraft/lovelydrop/drop/DropListener.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java index 2d67adb..ed5b9cd 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java @@ -20,6 +20,7 @@ import io.github.zrdzn.minecraft.lovelydrop.user.UserCache; import io.github.zrdzn.minecraft.spigot.SpigotAdapter; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; @@ -65,10 +66,6 @@ public void onSourceBreak(BlockBreakEvent event) { return; } - if (pickaxe.containsEnchantment(Enchantment.SILK_TOUCH)) { - return; - } - Block block = event.getBlock(); MaterialData source = null; @@ -126,6 +123,11 @@ public void onSourceBreak(BlockBreakEvent event) { return; } + MaterialData finalData = item.getType(); + if (item.getType().getItemType() == Material.COBBLESTONE && pickaxe.containsEnchantment(Enchantment.SILK_TOUCH)) { + finalData = new MaterialData(Material.STONE); + } + player.giveExp(property.getExperience()); Entry amountEntry = property.getAmount(); @@ -135,7 +137,7 @@ public void onSourceBreak(BlockBreakEvent event) { amount = random.nextInt(amountEntry.getKey(), amountEntry.getValue()); } - ItemStack droppedItem = item.getType().toItemStack(amount); + ItemStack droppedItem = finalData.toItemStack(amount); ItemMeta droppedItemMeta = droppedItem.getItemMeta();