searchNearbyPipes(bl, visitedPipes, items, filters, exceptions);
else if (bl.getType() == Material.PISTON_BASE) {
PistonBaseMaterial p = (PistonBaseMaterial) bl.getState().getData();
ChangedSign sign = getSignOnPiston(bl);
HashSet<ItemStack> pFilters = new HashSet<ItemStack>();
HashSet<ItemStack> pExceptions = new HashSet<ItemStack>();
if(sign != null) {
for(String line3 : RegexUtil.COMMA_PATTERN.split(sign.getLine(2))) {
pFilters.add(ItemSyntax.getItem(line3.trim()));
}
for(String line4 : RegexUtil.COMMA_PATTERN.split(sign.getLine(3))) {
pExceptions.add(ItemSyntax.getItem(line4.trim()));
}
pFilters.removeAll(Collections.singleton(null));
pExceptions.removeAll(Collections.singleton(null));
}
List<ItemStack> filteredItems = new ArrayList<ItemStack>(VerifyUtil.withoutNulls(ItemUtil.filterItems(items, pFilters, pExceptions)));
if(filteredItems.isEmpty())
continue;
List<ItemStack> newItems = new ArrayList<ItemStack>();
Block fac = bl.getRelative(p.getFacing());
if (InventoryUtil.doesBlockHaveInventory(fac)) {
newItems.addAll(InventoryUtil.addItemsToInventory((InventoryHolder) fac.getState(), filteredItems.toArray(new ItemStack[filteredItems.size()])));
} else if(fac.getType() == Material.JUKEBOX) {
Jukebox juke = (Jukebox) fac.getState();
List<ItemStack> its = new ArrayList<ItemStack>(filteredItems);
if(!juke.isPlaying()) {
Iterator<ItemStack> iter = its.iterator();
while(iter.hasNext()) {
ItemStack st = iter.next();
if(!st.getType().isRecord()) continue;
juke.setPlaying(st.getType());
iter.remove();
break;
}
}
newItems.addAll(its);
} else {
PipePutEvent event = new PipePutEvent(bl, new ArrayList<ItemStack>(filteredItems), fac);
Bukkit.getPluginManager().callEvent(event);
newItems.addAll(event.getItems());
}
items.removeAll(filteredItems);
items.addAll(newItems);
if (!items.isEmpty()) searchNearbyPipes(block, visitedPipes, items, filters, exceptions);
} else if (bl.getType() == Material.DROPPER) {
ChangedSign sign = getSignOnPiston(bl);
HashSet<ItemStack> pFilters = new HashSet<ItemStack>();
HashSet<ItemStack> pExceptions = new HashSet<ItemStack>();
if(sign != null) {
for(String line3 : RegexUtil.COMMA_PATTERN.split(sign.getLine(2))) {
pFilters.add(ItemSyntax.getItem(line3.trim()));
}
for(String line4 : RegexUtil.COMMA_PATTERN.split(sign.getLine(3))) {
pExceptions.add(ItemSyntax.getItem(line4.trim()));
}
pFilters.removeAll(Collections.singleton(null));
pExceptions.removeAll(Collections.singleton(null));