From 060737efc84a599e365a36fd9f599e3d15ffbf0a Mon Sep 17 00:00:00 2001 From: Snavy <46828965+bbSnavy@users.noreply.github.com> Date: Tue, 30 May 2023 20:24:29 +0000 Subject: [PATCH] added null check when renaming items (#53) --- src/redempt/redlib/itemutils/ItemUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/redempt/redlib/itemutils/ItemUtils.java b/src/redempt/redlib/itemutils/ItemUtils.java index 29c4ff2..eda5b40 100644 --- a/src/redempt/redlib/itemutils/ItemUtils.java +++ b/src/redempt/redlib/itemutils/ItemUtils.java @@ -57,13 +57,16 @@ private static ItemStack getBaseSkull() { } /** - * Renames an ItemStack, functionally identical to {@link ItemUtils#setName(ItemStack, String)} but kept for legacy reasons + * Renames an ItemStack, functionally identical to {@link ItemUtils#setName(ItemStack, String)} but kept for legacy reasons. This has no effect on items without meta such as Air * @param item The ItemStack to be renamed * @param name The name to give the ItemStack * @return The renamed ItemStack */ public static ItemStack rename(ItemStack item, String name) { ItemMeta meta = item.getItemMeta(); + if (meta == null) { + return item; + } meta.setDisplayName(name); item.setItemMeta(meta); return item;