From e62c12b99d01e344c68af4521c91c454114961ea Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 18 Apr 2021 12:16:33 +0100 Subject: [PATCH] Fixed grindstone giving experience when no enchantments were removed --- .../merging/grindstone/GrindstoneListeners.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java index a05fb91a..529ccdbf 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/grindstone/GrindstoneListeners.java @@ -3,6 +3,8 @@ package com.willfp.ecoenchants.enchantments.support.merging.grindstone; import com.willfp.eco.core.EcoPlugin; import com.willfp.eco.core.PluginDependent; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -70,10 +72,15 @@ public class GrindstoneListeners extends PluginDependent implements Listener { newOut.setItemMeta(meta); } - final ItemStack finalOut = newOut; - this.getPlugin().getScheduler().run(() -> { - inventory.setItem(2, finalOut); + inventory.setItem(2, newOut); + if (!toKeep.isEmpty()) { + for (Entity entity : player.getNearbyEntities(10, 10, 10)) { + if (entity.getType() == EntityType.EXPERIENCE_ORB) { + entity.remove(); + } + } + } }); }, 1); }