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,29 +83,53 @@ public class Repair {
} }
protected static int getSalvagedAmount(ItemStack inHand) { protected static int getSalvagedAmount(ItemStack inHand) {
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) { // Temporary workaround until they get their stuff fixed.
return 3; if (mcMMO.p.getServer().getName().equals("MCPC+")) {
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
return 3;
}
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
return 1;
}
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
return 2;
}
else if (ItemUtils.isHelmet(inHand)) {
return 5;
}
else if (ItemUtils.isChestplate(inHand)) {
return 8;
}
else if (ItemUtils.isLeggings(inHand)) {
return 7;
}
else if (ItemUtils.isBoots(inHand)) {
return 4;
}
else {
return 0;
}
} }
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
return 1; 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 (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) { else if (recipe instanceof ShapedRecipe) {
return 2; for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
} if (ingredient != null && ingredient.getType() == salvageMaterial) {
else if (ItemUtils.isHelmet(inHand)) { salvageAmount += ingredient.getAmount();
return 5; }
} }
else if (ItemUtils.isChestplate(inHand)) {
return 8;
}
else if (ItemUtils.isLeggings(inHand)) {
return 7;
}
else if (ItemUtils.isBoots(inHand)) {
return 4;
}
else {
return 0;
} }
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!");
} }