mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
Fix NPE for AIR in meta operations in ItemStack
This commit is contained in:
parent
1ff89d3d71
commit
29b3f9b2bb
1 changed files with 13 additions and 1 deletions
|
@ -110,6 +110,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ */
|
||||
+ public void setLore(@Nullable List<String> lore) {
|
||||
+ ItemMeta itemMeta = getItemMeta();
|
||||
+ if (itemMeta == null) {
|
||||
+ throw new IllegalStateException("Cannot set lore on " + getType());
|
||||
+ }
|
||||
+ itemMeta.setLore(lore);
|
||||
+ setItemMeta(itemMeta);
|
||||
+ }
|
||||
|
@ -121,6 +124,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ */
|
||||
+ public void addItemFlags(@NotNull ItemFlag... itemFlags) {
|
||||
+ ItemMeta itemMeta = getItemMeta();
|
||||
+ if (itemMeta == null) {
|
||||
+ throw new IllegalStateException("Cannot add flags on " + getType());
|
||||
+ }
|
||||
+ itemMeta.addItemFlags(itemFlags);
|
||||
+ setItemMeta(itemMeta);
|
||||
+ }
|
||||
|
@ -132,6 +138,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ */
|
||||
+ public void removeItemFlags(@NotNull ItemFlag... itemFlags) {
|
||||
+ ItemMeta itemMeta = getItemMeta();
|
||||
+ if (itemMeta == null) {
|
||||
+ throw new IllegalStateException("Cannot remove flags on " + getType());
|
||||
+ }
|
||||
+ itemMeta.removeItemFlags(itemFlags);
|
||||
+ setItemMeta(itemMeta);
|
||||
+ }
|
||||
|
@ -144,6 +153,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ @NotNull
|
||||
+ public Set<ItemFlag> getItemFlags() {
|
||||
+ ItemMeta itemMeta = getItemMeta();
|
||||
+ if (itemMeta == null) {
|
||||
+ return java.util.Collections.emptySet();
|
||||
+ }
|
||||
+ return itemMeta.getItemFlags();
|
||||
+ }
|
||||
+
|
||||
|
@ -155,7 +167,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ */
|
||||
+ public boolean hasItemFlag(@NotNull ItemFlag flag) {
|
||||
+ ItemMeta itemMeta = getItemMeta();
|
||||
+ return itemMeta.hasItemFlag(flag);
|
||||
+ return itemMeta != null && itemMeta.hasItemFlag(flag);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue