Allow repair of items without a recipe.

This commit is contained in:
GJ 2013-11-08 10:51:17 -05:00
parent dfe83ff497
commit d1d6b80676

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.skills.repair; package com.gmail.nossr50.skills.repair;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe; import org.bukkit.inventory.Recipe;
@ -91,7 +93,10 @@ public class Repair {
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) { public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
int quantity = 0; int quantity = 0;
MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null; MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null;
Recipe recipe = mcMMO.p.getServer().getRecipesFor(item).get(0); List<Recipe> recipes = mcMMO.p.getServer().getRecipesFor(item);
if (!recipes.isEmpty()) {
Recipe recipe = recipes.get(0);
if (recipe instanceof ShapelessRecipe) { if (recipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) { for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
@ -107,6 +112,7 @@ public class Repair {
} }
} }
} }
}
return quantity; return quantity;
} }