From 26d9dbcbd34ce75881eb77b0edca08d42581812d Mon Sep 17 00:00:00 2001 From: Brianna Date: Fri, 17 Jan 2020 15:18:24 -0500 Subject: [PATCH] Added config blacklist for auto crafting. --- .../hopper/levels/modules/ModuleAutoCrafting.java | 6 +++++- .../java/com/songoda/epichoppers/settings/Settings.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java index 67a7515..f2bf12f 100644 --- a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java +++ b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleAutoCrafting.java @@ -132,8 +132,11 @@ public class ModuleAutoCrafting extends Module { cachedCrafting.remove(hopper); } - Recipes getRecipes(ItemStack toCraft) { + private Recipes getRecipes(ItemStack toCraft) { Recipes recipes = cachedRecipes.get(toCraft); + if (Settings.AUTOCRAFT_BLACKLIST.getStringList().stream() + .anyMatch(r -> r.equalsIgnoreCase(toCraft.getType().name()))) + return new Recipes(); if (recipes == null) { try { recipes = new Recipes(Bukkit.getServer().getRecipesFor(toCraft)); @@ -145,6 +148,7 @@ public class ModuleAutoCrafting extends Module { while (recipeIterator.hasNext()) { try { Recipe recipe = recipeIterator.next(); + ItemStack stack = recipe.getResult(); if (Methods.isSimilarMaterial(stack, toCraft)) recipes.addRecipe(recipe); diff --git a/src/main/java/com/songoda/epichoppers/settings/Settings.java b/src/main/java/com/songoda/epichoppers/settings/Settings.java index 3f9e4db..09f0c1a 100644 --- a/src/main/java/com/songoda/epichoppers/settings/Settings.java +++ b/src/main/java/com/songoda/epichoppers/settings/Settings.java @@ -63,6 +63,9 @@ public class Settings { "Normally, crafting hoppers won't grab items that would fill that slot.", "This option ejects items if that last slot is forcibly filled"); + public static final ConfigSetting AUTOCRAFT_BLACKLIST = new ConfigSetting(config, "Main.AutoCraft Blacklist", Arrays.asList("BEDROCK", "EGG"), + "Anything listed here will not be able to be auto crafted."); + public static final ConfigSetting AUTOSELL_PRICES = new ConfigSetting(config, "Main.AutoSell Prices", Arrays.asList("STONE,0.50", "COBBLESTONE,0.20", "IRON_ORE,0.35", "COAL_ORE,0.20"), "These are the prices used by the auto sell module.");