Actually fix maximumQuantity reading from config

Now we try to automatically detect the maximum quantity if possible and
fall back to the config if the user has set a value there.

Also fixed the feedback message which said „Minimum quantity” instead
of „Maximum quantity”
This commit is contained in:
TfT_02 2014-05-25 23:20:19 +02:00
parent 3c6c2837bd
commit 3f34cc7365

View File

@ -123,14 +123,20 @@ public class SalvageConfig extends ConfigLoader {
} }
// Maximum Quantity // Maximum Quantity
int maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", -1); int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata) : config.getInt("Salvageables." + key + ".MaximumQuantity", 2));
if (maximumQuantity <= 0 && itemMaterial != null) { if (maximumQuantity <= 0 && itemMaterial != null) {
maximumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata); maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", 2);
}
int configMaximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", -1);
if (configMaximumQuantity > 0) {
maximumQuantity = configMaximumQuantity;
} }
if (maximumQuantity <= 0) { if (maximumQuantity <= 0) {
reason.add("Minimum quantity of " + key + " must be greater than 0!"); reason.add("Maximum quantity of " + key + " must be greater than 0!");
} }
if (noErrorsInSalvageable(reason)) { if (noErrorsInSalvageable(reason)) {