Hello, I am creating a plugin for the limit of items in inventory and everything is fine, I only encountered a small problem ... I did the GetType method it works, but it also takes a normal item, and I would like it to take only the item with the given name "Treatment" "and this subject is a blaze rod Code: if (pinv.getType() == Material.BLAZE_ROD) { blazeSize += sinv.getAmount(); } Code: if (gheadSize > 1) { limit = true; final int toRemove = gheadSize - 1; u.getStore().setGheads(u.getStore().getGheads() + toRemove); p.getInventory().removeItem(new ItemStack[] { HeadManager.getHeadItemStack(toRemove)}); } HeadManager Code: public class HeadManager { private static final List<UUID> heads; public static void removeHead(final UUID uuid) { HeadManager.heads.remove(uuid); } public static List<UUID> getHeads() { return HeadManager.heads; } public static void throwHead(final Player player) { ItemsUtil.removeItemInHand(player); } public static ItemStack getHeadItemStack(final int size) { return new ItemBuilder(Material.BLAZE_ROD, size).addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setName(ChatUtil.fixColors("&e& Treatment ")); } public static boolean isHead(final ItemStack item) { return item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatUtil.fixColors("&e& Treatment ")); } static { heads = new ArrayList<UUID>(); } }
@pvtr_ Check if there is itemmeta. Get the itemmeta. Check if there is a displayname. Check the displayname.
@pvtr_ And that is why I gave you 4 separate things to do... https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/ItemStack.html#hasItemMeta--
It now downloads the same name with the blaze rod, but also tries to download the unnamed and pops up the message but does not download it anyway Code: if (pinv.getType() == Material.BLAZE_ROD) { if (pinv.hasItemMeta() && pinv.getItemMeta().hasDisplayName() && pinv.getItemMeta().getDisplayName().equalsIgnoreCase(ChatUtil.fixColors("&e&lGLOWA"))); { gheadSize += pinv.getAmount(); } }