mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Allow repair of items without a recipe.
This commit is contained in:
parent
dfe83ff497
commit
d1d6b80676
@ -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,19 +93,23 @@ 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 (recipe instanceof ShapelessRecipe) {
|
if (!recipes.isEmpty()) {
|
||||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
Recipe recipe = recipes.get(0);
|
||||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
|
||||||
quantity += ingredient.getAmount();
|
if (recipe instanceof ShapelessRecipe) {
|
||||||
|
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||||
|
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||||
|
quantity += ingredient.getAmount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (recipe instanceof ShapedRecipe) {
|
||||||
else if (recipe instanceof ShapedRecipe) {
|
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
quantity += ingredient.getAmount();
|
||||||
quantity += ingredient.getAmount();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user