diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/Filter.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/Filter.java index f54593b..cede6be 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/Filter.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/Filter.java @@ -33,7 +33,11 @@ public class Filter { if(isFilteredByMeta(itemStack)) return Type.REJECT; else return Type.ACCEPT; } - if(isFilteredByMeta(itemStack)) return Type.ACCEPT; + if(filterByItemMeta) { + if (isFilteredByMeta(itemStack)) return Type.ACCEPT; + } else { + if (filter.isSimilar(itemStack)) return Type.ACCEPT; + } return Type.NONE; } diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/HopperFilter.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/HopperFilter.java index 002f869..6355221 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/HopperFilter.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/HopperFilter.java @@ -9,15 +9,19 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class HopperFilter { public static boolean isInFilter(List filters, ItemStack item){ if(filters == null) return true; if(filters.size() == 0) return true; - boolean hasAcceptFilter = filters.stream().filter(filter -> filter.getFilteringMethod() == Filter.Type.ACCEPT).anyMatch(filter -> filter.getFilterType(item).equals(Filter.Type.ACCEPT)); + List acceptFilters = filters.stream().filter(filter -> filter.getFilteringMethod() == Filter.Type.ACCEPT).collect(Collectors.toList()); + boolean hasAcceptFilter = acceptFilters.stream().anyMatch(filter -> filter.getFilterType(item).equals(Filter.Type.ACCEPT)); boolean isRejected = filters.stream().filter(filter -> filter.getFilteringMethod() == Filter.Type.REJECT).anyMatch(filter -> filter.getFilterType(item).equals(Filter.Type.REJECT)); - return hasAcceptFilter && !isRejected; + if(acceptFilters.size() > 0) return hasAcceptFilter && !isRejected; + else return !isRejected; } public static List getHopperFilters(Block block){