#Need help debugging code
1 messages · Page 1 of 1 (latest)
@knotty carbon Sorry for another ping just moving this to a thread to make it easier. I actually have a log event in line 2 that tells me if it detects the action and it has gotten to that but it doesn't seem to ever pass the item check
Yes
It registers my clicks
But doesn't seem to be able to detect the item
and I have a slightly modified version of the code I originally used that was working. the modification being I learned that some of what I was doing(mainly using == to compare strings) was wrong and so I updated it to be using .equals instead.
The event actually doesn't get called if you aren't holding an item
And the method I use to check is to get the item in the players hand using p.getInventory().getItemInMainHand() then I get the display name from the Item Meta and I check that against a predefined value.
Items may not have item meta maybe. That would cause a NPE
So which check isn't passed ?
It detects the right click but then it doesn't seem to ever pass the item meta check
and I was using the same item before and haven't changed the item meta check data at all. The only change was how they are being compared.
Then output the item name, the name you want to be equals and see if the problem is here
You have to test your values
To search for everything
itemmeta is basically NBT data right
Alright so I figured out that it seems to be something with trying to format it or change it from being just a string. Do you have any idea how I could fix that problem
What do you mean ?
So in the itemmeta check that determines whether the item is the correct one or not if I try to change it from being one set of "" to being like ChatColor.Red + "" it will no longer work