From 74bff83e381f000f975a830a296cecabbb070809 Mon Sep 17 00:00:00 2001 From: wizjany Date: Tue, 26 Mar 2019 22:30:24 -0400 Subject: [PATCH] Don't let items types be null. Better fail-fast if registry doesn't load? or why-ever else this happens --- .../main/java/com/sk89q/worldedit/blocks/BaseItem.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java index 114609e63..a81ee9ab2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java @@ -25,6 +25,8 @@ import com.sk89q.worldedit.world.item.ItemType; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents an item, without an amount value. See {@link BaseItemStack} * for an instance with stack amount information. @@ -32,7 +34,7 @@ import javax.annotation.Nullable; *

This class may be removed in the future.

*/ public class BaseItem implements NbtValued { - + private ItemType itemType; @Nullable private CompoundTag nbtData; @@ -43,6 +45,7 @@ public class BaseItem implements NbtValued { * @param itemType Type of the item */ public BaseItem(ItemType itemType) { + checkNotNull(itemType); this.itemType = itemType; } @@ -52,7 +55,8 @@ public class BaseItem implements NbtValued { * @param itemType Type of the item * @param tag NBT Compound tag */ - public BaseItem(ItemType itemType, CompoundTag tag) { + public BaseItem(ItemType itemType, @Nullable CompoundTag tag) { + checkNotNull(itemType); this.itemType = itemType; this.nbtData = tag; }