Rework armor.yml to take item names instead of IDs in advance of 1.7 changes.

** YOU WILL NEED TO REDO YOUR armor.yml FILE **
This commit is contained in:
GJ
2013-09-20 10:03:02 -04:00
committed by TfT_02
parent 933b6f278b
commit 792ecd6aad
12 changed files with 114 additions and 165 deletions

View File

@@ -5,6 +5,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
@@ -112,25 +113,29 @@ public class Repair {
}
}
Recipe recipe = mcMMO.p.getServer().getRecipesFor(inHand).get(0);
int salvageAmount = 0;
Material salvageMaterial = getSalvagedItem(inHand);
return getRepairAndSalvageQuantities(inHand, getSalvagedItem(inHand), (byte) -1);
}
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
int quantity = 0;
MaterialData repairData = new MaterialData(repairMaterial, repairMetadata);
Recipe recipe = mcMMO.p.getServer().getRecipesFor(item).get(0);
if (recipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
if (ingredient != null && ingredient.getType() == salvageMaterial) {
salvageAmount += ingredient.getAmount();
if (ingredient != 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() == salvageMaterial) {
salvageAmount += ingredient.getAmount();
if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) {
quantity += ingredient.getAmount();
}
}
}
return salvageAmount;
return quantity;
}
}