Add check if item has meta as that could've returned null (Fixes #427)

This commit is contained in:
Phoenix616 2021-03-27 18:44:04 +01:00
parent 66201a9062
commit 76e3f5b3c8
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0

View File

@ -1,9 +1,7 @@
package com.Acrobot.ChestShop.Listeners; package com.Acrobot.ChestShop.Listeners;
import com.Acrobot.Breeze.Utils.StringUtil; import com.Acrobot.Breeze.Utils.StringUtil;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Events.ItemInfoEvent; import com.Acrobot.ChestShop.Events.ItemInfoEvent;
import com.Acrobot.ChestShop.Utils.ItemUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -19,18 +17,14 @@ import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import static com.Acrobot.Breeze.Utils.NumberUtil.toRoman; import static com.Acrobot.Breeze.Utils.NumberUtil.toRoman;
import static com.Acrobot.Breeze.Utils.NumberUtil.toTime; import static com.Acrobot.Breeze.Utils.NumberUtil.toTime;
import static com.Acrobot.Breeze.Utils.StringUtil.capitalizeFirstLetter; import static com.Acrobot.Breeze.Utils.StringUtil.capitalizeFirstLetter;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_book; import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_book;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_book_generation; import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_book_generation;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_fullname;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_lore; import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_lore;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_repaircost; import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_repaircost;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo_shopname;
/** /**
* @author Acrobot * @author Acrobot
@ -123,9 +117,11 @@ public class ItemInfoListener implements Listener {
@EventHandler @EventHandler
public static void addLoreInfo(ItemInfoEvent event) { public static void addLoreInfo(ItemInfoEvent event) {
if (event.getItem().hasItemMeta()) {
ItemMeta meta = event.getItem().getItemMeta(); ItemMeta meta = event.getItem().getItemMeta();
if (meta.hasLore()) { if (meta.hasLore()) {
iteminfo_lore.send(event.getSender(), "lore", String.join("\n", meta.getLore())); iteminfo_lore.send(event.getSender(), "lore", String.join("\n", meta.getLore()));
} }
} }
} }
}