Hello I'm writing a Lootchest plugin, it works too, but every time you right-click an item there's an error code.
My code:
if (e.getAction () == Action.RIGHT_CLICK_AIR || e.getAction () == Action.RIGHT_CLICK_BLOCK) {
if (e.hasItem ()) {
if (e.getItem (). HasItemMeta ()) {
if (e.getItem (). GetItemMeta (). GetDisplayName (). Equals ("§8 [§2Loot§2Chest§8]")) {
} else {return;}
}
else {return;}
} else {return;}
}
The error code:
I had the same problem.
I had added the following query
if (e.getItem () == null ||
e.getItem (). GetItemMeta () == null || e.getItem (). GetItemMeta (). GetDisplayName () == null) {
return;
}
In which line is the error? (Line 51 in class)
Yep, he encountered a null pointer exception. Your code should work.
Thanks, my rescue haha