mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Remove debug message, use recipe method for salvage.
This commit is contained in:
parent
5d7d779a49
commit
566a381e95
@ -2,7 +2,11 @@ package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -79,29 +83,53 @@ public class Repair {
|
||||
}
|
||||
|
||||
protected static int getSalvagedAmount(ItemStack inHand) {
|
||||
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
|
||||
return 3;
|
||||
// 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) {
|
||||
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) {
|
||||
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 (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && ingredient.getType() == salvageMaterial) {
|
||||
salvageAmount += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return salvageAmount;
|
||||
}
|
||||
}
|
||||
|
@ -164,8 +164,6 @@ public class RepairConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Minimum quantity of " + key + ": " + minimumQuantity);
|
||||
|
||||
if (minimumQuantity <= 0) {
|
||||
reason.add("Minimum quantity of " + key + " must be greater than 0!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user