mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-27 21:26:29 +01:00
Check for null items when editing events, fixes #444
This commit is contained in:
parent
e908af7599
commit
c5dabefc32
@ -404,7 +404,9 @@ public class EventFactory implements ConversationAbandonedListener {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetItems") + "\n";
|
||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(CK.E_ITEMS);
|
||||
for (ItemStack is : items) {
|
||||
text += ChatColor.GRAY + " - " + ItemUtil.getString(is) + "\n";
|
||||
if (is != null) {
|
||||
text += ChatColor.GRAY + " - " + ItemUtil.getString(is) + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(CK.E_EXPLOSIONS) == null) {
|
||||
|
@ -403,10 +403,13 @@ public class ItemUtil {
|
||||
* Format is ([display]name:durability) x (amount)
|
||||
*
|
||||
* @param is ItemStack to check
|
||||
* @return true display or item name, plus durability and amount
|
||||
* @return true display or item name, plus durability and amount, if stack is not null
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static String getString(ItemStack is) {
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
String text;
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount();
|
||||
@ -424,9 +427,12 @@ public class ItemUtil {
|
||||
* Returns a formatted display name. If none exists, returns item name.
|
||||
*
|
||||
* @param is ItemStack to check
|
||||
* @return true display or item name
|
||||
* @return true display or item name, if stack is not null
|
||||
*/
|
||||
public static String getName(ItemStack is) {
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
String text = "";
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName();
|
||||
|
Loading…
Reference in New Issue
Block a user