mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-23 09:41:20 +01:00
Fixed nullpointer if lore is empty when using the item browser
This commit is contained in:
parent
cf7fa29c81
commit
fca3ead680
@ -130,6 +130,23 @@ public class ItemBrowser extends PluginInventory {
|
||||
}
|
||||
NBTItem nbtItem = NBTItem.get(item);
|
||||
|
||||
ItemStack stack;
|
||||
List<BaseComponent> lore = nbtItem.getLoreComponents();
|
||||
if(lore == null) {
|
||||
stack = nbtItem.toItem();
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
List<String> newLore = meta.getLore();
|
||||
newLore.add("");
|
||||
if (deleteMode) {
|
||||
newLore.add(ChatColor.RED + AltChar.cross + " CLICK TO DELETE " + AltChar.cross);
|
||||
meta.setDisplayName(ChatColor.RED + "DELETE: " + meta.getDisplayName());
|
||||
}
|
||||
newLore.add(ChatColor.YELLOW + AltChar.smallListDash + " Left click to obtain this item.");
|
||||
newLore.add(ChatColor.YELLOW + AltChar.smallListDash + " Right click to edit this item.");
|
||||
meta.setLore(newLore);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else {
|
||||
List<BaseComponent> newLore = new ArrayList<>();
|
||||
newLore.add(toComponent(""));
|
||||
if (deleteMode) {
|
||||
@ -148,11 +165,12 @@ public class ItemBrowser extends PluginInventory {
|
||||
newLore.add(toComponent(ChatColor.YELLOW + AltChar.smallListDash + " Right click to edit this item."));
|
||||
}
|
||||
|
||||
List<BaseComponent> lore = nbtItem.getLoreComponents();
|
||||
lore.addAll(newLore);
|
||||
nbtItem.setLoreComponents(lore);
|
||||
stack = nbtItem.toItem();
|
||||
}
|
||||
|
||||
cached.put(template.getId(), nbtItem.toItem());
|
||||
cached.put(template.getId(), stack);
|
||||
|
||||
inv.setItem(slots[n++], cached.get(template.getId()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user