Having an issue I cannot seem to understand. https://pastebin.com/mSY88wcf The while loop stops running if the string is null and I am not sure as to why considering it is an if statement. I have tried several ways of solving this but I am unable to figure it out. Edit: I need it to check the display name and NOT the ItemStack because the lore will be different for every "coin"
Need specifics. I dont see any stacktrace or line numbers.. https://bukkit.org/threads/how-to-r...ubleshoot-your-own-plugins-by-yourself.32457/
Apologies, https://pastebin.com/QtU8fARX line 275 is this: if(p.getInventory().getItem(i).getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Big Coin"))
Its probably returning a null ItemMeta. ps : I recommend separating each method by one line to determine which part of that statement is returning null .
I had the same issue in the past, you have to check first if the item has an ItemMeta attached to it - in fact, a newly created item does not have an ItemMeta unless you apply enchantments, rename it or set an ItemMeta by yourself. To do this, you have to put this check before any other thing : Code (Java): if (!p.getInventory().getItem(i).hasItemMeta()) { // Some code } In theory this will solve your issue
I understand that it is returning null, I believe it is the display name returning null. I just need a way around that, I am unable to find one. Will try Zodiak
If the item doesn't have an ItemMeta it will still throw a NPE because you're trying to use functions on a null instance of ItemMeta.
Of course, you'd check if it has an ItemMeta and then check that it has a displayname. I didn't speak against that, lol.