diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-12-22 18:23:42 +0200 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-12-22 18:23:42 +0200 |
commit | 484dbb3e78c2d22ba129dbecef49a4314e978036 (patch) | |
tree | 7e8511fb3e3e062afc436a83eeb2f011f066928a /src/main/java/io | |
parent | 23df2a0eeb7e9990c7be7d3eaf27dc353f4de889 (diff) | |
download | LibGui-484dbb3e78c2d22ba129dbecef49a4314e978036.tar.gz LibGui-484dbb3e78c2d22ba129dbecef49a4314e978036.tar.bz2 LibGui-484dbb3e78c2d22ba129dbecef49a4314e978036.zip |
Remove possible null values for ValidatedSlot.filter
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java | 8 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java index 16efebd..6d1475c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java @@ -14,11 +14,17 @@ import java.util.Objects; import java.util.function.Predicate; public class ValidatedSlot extends Slot { + /** + * The default {@linkplain #setFilter(Predicate) item filter} that allows all items. + * + * @since 5.1.1 + */ + public static final Predicate<ItemStack> DEFAULT_ITEM_FILTER = stack -> true; private static final VisualLogger LOGGER = new VisualLogger(ValidatedSlot.class); private final int slotNumber; private boolean insertingAllowed = true; private boolean takingAllowed = true; - private Predicate<ItemStack> filter; + private Predicate<ItemStack> filter = DEFAULT_ITEM_FILTER; protected final Multimap<WItemSlot, WItemSlot.ChangeListener> listeners = HashMultimap.create(); private boolean visible = true; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java index a05b364..288c922 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java @@ -67,7 +67,6 @@ import java.util.function.Predicate; */ public class WItemSlot extends WWidget { private static final VisualLogger LOGGER = new VisualLogger(WItemSlot.class); - private static final Predicate<ItemStack> DEFAULT_FILTER = stack -> true; private final List<ValidatedSlot> peers = new ArrayList<>(); @Nullable @Environment(EnvType.CLIENT) @@ -83,7 +82,7 @@ public class WItemSlot extends WWidget { private boolean takingAllowed = true; private int focusedSlot = -1; private int hoveredSlot = -1; - private Predicate<ItemStack> filter = DEFAULT_FILTER; + private Predicate<ItemStack> filter = ValidatedSlot.DEFAULT_ITEM_FILTER; private final Set<ChangeListener> listeners = new HashSet<>(); public WItemSlot(Inventory inventory, int startIndex, int slotsWide, int slotsHigh, boolean big) { |