Skip to content

Commit

Permalink
Add air checks to NBT methods, fixes #1737
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Mar 13, 2018
1 parent a2c84ca commit 7e2961c
Showing 1 changed file with 9 additions and 9 deletions.
Expand Up @@ -3,13 +3,13 @@
import net.aufdemrand.denizen.nms.NMSHandler;
import net.aufdemrand.denizen.nms.util.jnbt.*;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

public class CustomNBT {

Expand All @@ -36,7 +36,7 @@ public static class AttributeReturn {
}

public static List<AttributeReturn> getAttributes(ItemStack itemStack) {
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return null;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand Down Expand Up @@ -111,7 +111,7 @@ else if (mat.contains("chestp")) {
}

public static ItemStack addAttribute(ItemStack itemStack, String attr, String slot, int op, double amt) {
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return null;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand Down Expand Up @@ -146,7 +146,7 @@ public static ItemStack addAttribute(ItemStack itemStack, String attr, String sl
}

public static ItemStack addCustomNBT(ItemStack itemStack, String key, String value, String basekey) {
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return null;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand All @@ -169,7 +169,7 @@ public static ItemStack addCustomNBT(ItemStack itemStack, String key, String val
}

public static ItemStack clearAttributes(ItemStack itemStack) {
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return null;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand All @@ -181,7 +181,7 @@ public static ItemStack clearAttributes(ItemStack itemStack) {
}

public static ItemStack removeCustomNBT(ItemStack itemStack, String key, String basekey) {
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return null;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand All @@ -204,7 +204,7 @@ public static ItemStack removeCustomNBT(ItemStack itemStack, String key, String
}

public static boolean hasCustomNBT(ItemStack itemStack, String key, String basekey) {
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return false;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand All @@ -221,7 +221,7 @@ public static boolean hasCustomNBT(ItemStack itemStack, String key, String basek
}

public static String getCustomNBT(ItemStack itemStack, String key, String basekey) {
if (itemStack == null || key == null) {
if (itemStack == null || itemStack.getType() == Material.AIR || key == null) {
return null;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand All @@ -236,7 +236,7 @@ public static String getCustomNBT(ItemStack itemStack, String key, String baseke

public static List<String> listNBT(ItemStack itemStack, String basekey) {
List<String> nbt = new ArrayList<String>();
if (itemStack == null) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return nbt;
}
CompoundTag compoundTag = NMSHandler.getInstance().getItemHelper().getNbtData(itemStack);
Expand Down

0 comments on commit 7e2961c

Please sign in to comment.