Remove debug message, use recipe method for salvage.

This commit is contained in:
GJ 2013-09-19 15:17:19 -04:00
parent 5d7d779a49
commit 566a381e95
2 changed files with 49 additions and 23 deletions

View File

@ -2,7 +2,11 @@ package com.gmail.nossr50.skills.repair;
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.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@ -79,6 +83,8 @@ public class Repair {
} }
protected static int getSalvagedAmount(ItemStack inHand) { protected static int getSalvagedAmount(ItemStack inHand) {
// Temporary workaround until they get their stuff fixed.
if (mcMMO.p.getServer().getName().equals("MCPC+")) {
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
return 3; return 3;
} }
@ -104,4 +110,26 @@ public class Repair {
return 0; return 0;
} }
} }
Recipe recipe = mcMMO.p.getServer().getRecipesFor(inHand).get(0);
int salvageAmount = 0;
Material salvageMaterial = getSalvagedItem(inHand);
if (recipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
if (ingredient != null && ingredient.getType() == salvageMaterial) {
salvageAmount += ingredient.getAmount();
}
}
}
else if (recipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
if (ingredient != null && ingredient.getType() == salvageMaterial) {
salvageAmount += ingredient.getAmount();
}
}
}
return salvageAmount;
}
} }

View File

@ -164,8 +164,6 @@ public class RepairConfig extends ConfigLoader {
} }
} }
System.out.println("Minimum quantity of " + key + ": " + minimumQuantity);
if (minimumQuantity <= 0) { if (minimumQuantity <= 0) {
reason.add("Minimum quantity of " + key + " must be greater than 0!"); reason.add("Minimum quantity of " + key + " must be greater than 0!");
} }