mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 02:04:44 +02:00
Repair / Salvage fixes
This commit is contained in:
@ -1,17 +1,20 @@
|
||||
package com.gmail.nossr50.config.skills.salvage;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MaterialMapStore;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class SalvageConfig extends ConfigLoader {
|
||||
@ -36,6 +39,24 @@ public class SalvageConfig extends ConfigLoader {
|
||||
ConfigurationSection section = config.getConfigurationSection("Salvageables");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
//Original version of 1.16 support had maximum quantities that were bad, this fixes it
|
||||
if(mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
|
||||
mcMMO.p.getLogger().info("Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
|
||||
for(String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
|
||||
config.set("Salvageables." + namespacedkey.toUpperCase() + ".MaximumQuantity", 4);
|
||||
}
|
||||
|
||||
try {
|
||||
config.save(getFile());
|
||||
// mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES);
|
||||
mcMMO.p.getLogger().info("Fixed incorrect Salvage quantities for Netherite gear!");
|
||||
} catch (IOException e) {
|
||||
mcMMO.p.getLogger().info("Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (String key : keys) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
@ -131,7 +152,7 @@ public class SalvageConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
// Maximum Quantity
|
||||
int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(itemMaterial, salvageMaterial) : config.getInt("Salvageables." + key + ".MaximumQuantity", 2));
|
||||
int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(itemMaterial, salvageMaterial) : config.getInt("Salvageables." + key + ".MaximumQuantity", 1));
|
||||
|
||||
if (maximumQuantity <= 0 && itemMaterial != null) {
|
||||
maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", 1);
|
||||
|
@ -15,5 +15,6 @@ public enum UpgradeType {
|
||||
ADD_SKILL_TOTAL,
|
||||
ADD_UNIQUE_PLAYER_DATA,
|
||||
FIX_SPELLING_NETHERITE_SALVAGE,
|
||||
FIX_SPELLING_NETHERITE_REPAIR
|
||||
FIX_SPELLING_NETHERITE_REPAIR,
|
||||
FIX_NETHERITE_SALVAGE_QUANTITIES
|
||||
}
|
||||
|
@ -1088,6 +1088,15 @@ public class MaterialMapStore {
|
||||
toolBlackList.add("respawn_anchor");
|
||||
}
|
||||
|
||||
public HashSet<String> getNetheriteArmor() {
|
||||
return netheriteArmor;
|
||||
}
|
||||
|
||||
public HashSet<String> getNetheriteTools() {
|
||||
return netheriteTools;
|
||||
}
|
||||
|
||||
|
||||
public int getTier(Material material) {
|
||||
return getTier(material.getKey().getKey());
|
||||
}
|
||||
|
Reference in New Issue
Block a user