diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java index fb791f8d7..eb0bb85d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java @@ -11,6 +11,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoNode; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; @@ -81,11 +82,11 @@ class ItemFilter implements Predicate { SlimefunItem item = SlimefunItem.getByID(id); BlockMenu menu = BlockStorage.getInventory(b.getLocation()); - if (item == null || menu == null) { + if (!(item instanceof CargoNode) || menu == null) { // Don't filter for a non-existing item (safety check) clear(false); - } else if (id.equals("CARGO_NODE_OUTPUT")) { - // Output Nodes have no filter, allow everything + } else if (((CargoNode) item).hasItemFilter()) { + // Node does not have a filter, allow everything clear(true); } else { this.items.clear(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java index c0bc2f39c..7145619be 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java @@ -44,6 +44,11 @@ abstract class AbstractFilterNode extends AbstractCargoNode { addItemHandler(onBreak()); } + @Override + public boolean hasItemFilter() { + return true; + } + @Nonnull private BlockBreakHandler onBreak() { return new SimpleBlockBreakHandler() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java index c5828d573..0c2fc06bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java @@ -14,7 +14,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * @author TheBusyBiscuit * */ -@FunctionalInterface public interface CargoNode { /** @@ -27,4 +26,11 @@ public interface CargoNode { */ int getSelectedChannel(@Nonnull Block b); + /** + * This returns whether this {@link CargoNode} has item filtering capabilities. + * + * @return Whether this {@link CargoNode} can filter items + */ + boolean hasItemFilter(); + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java index 6d33b69e2..bfaefdcfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -18,10 +20,16 @@ public class CargoOutputNode extends AbstractCargoNode { private static final int[] BORDER = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }; + @ParametersAreNonnullByDefault public CargoOutputNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); } + @Override + public boolean hasItemFilter() { + return false; + } + @Override protected void onPlace(BlockPlaceEvent e) { // We only require the default values