Skip to content

Commit

Permalink
added null check when renaming items (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbSnavy authored May 30, 2023
1 parent 3ec401b commit 060737e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/redempt/redlib/itemutils/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 060737e

Please sign in to comment.