13
0
geforkt von Mirrors/Paper

Fix NPE for AIR in meta operations in ItemStack

Dieser Commit ist enthalten in:
Aleksander Jagiello 2021-02-03 18:04:27 +01:00
Ursprung 1ff89d3d71
Commit 29b3f9b2bb

Datei anzeigen

@ -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
}