diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 5b663220d..1c3d187b9 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -116,21 +116,25 @@ public class Repair { return getRepairAndSalvageQuantities(inHand, getSalvagedItem(inHand), (byte) -1); } + public static int getRepairAndSalvageQuantities(ItemStack item) { + return getRepairAndSalvageQuantities(item, null, (byte) -1); + } + public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) { int quantity = 0; - MaterialData repairData = new MaterialData(repairMaterial, repairMetadata); + MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null; Recipe recipe = mcMMO.p.getServer().getRecipesFor(item).get(0); if (recipe instanceof ShapelessRecipe) { for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) { - if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) { + if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) { quantity += ingredient.getAmount(); } } } else if (recipe instanceof ShapedRecipe) { for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) { - if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) { + if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) { quantity += ingredient.getAmount(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java b/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java index 325653365..ccdd237ce 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java @@ -136,6 +136,10 @@ public class RepairConfig extends ConfigLoader { // Minimum Quantity int minimumQuantity = (itemMaterial != null && repairMaterial != null ? Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity")); + if (minimumQuantity <= 0 && itemMaterial != null) { + minimumQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial)); + } + if (minimumQuantity <= 0) { reason.add("Minimum quantity of " + key + " must be greater than 0!"); }