diff --git a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java index 5b1156f..68c1b21 100644 --- a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java +++ b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/AST.java @@ -18,6 +18,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; @@ -25,6 +26,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import java.util.AbstractMap; +import java.util.Collection; import java.util.HashMap; import java.util.UUID; import java.util.logging.Level; @@ -162,6 +164,25 @@ public class AST extends JavaPlugin { PlayerInventory i = p.getInventory(); for(ArmorStandTool t : ArmorStandTool.values()) { i.remove(t.getItem()); + + Collection materialItems = i.all(t.getItem().getType()).values(); + ItemMeta toolMeta = t.getItem().getItemMeta(); + if (toolMeta == null) { + continue; + } + + String toolLocalizedName = toolMeta.getLocalizedName(); + for (ItemStack invItem : materialItems) { + ItemMeta inventoryItemMeta = invItem.getItemMeta(); + + if (inventoryItemMeta == null) { + continue; + } + + if (toolLocalizedName.equals(inventoryItemMeta.getLocalizedName())) { + i.remove(invItem); + } + } } } diff --git a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandTool.java b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandTool.java index e3545ef..e3d0c11 100644 --- a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandTool.java +++ b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandTool.java @@ -79,6 +79,7 @@ public enum ArmorStandTool { if(meta != null) { meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + meta.setLocalizedName("ArmorStandTool"); item.setItemMeta(meta); } this.config_id = config_id;