2.2.044 Fix copper repair and salvage

This commit is contained in:
nossr50
2025-11-02 12:25:25 -08:00
parent f71fe0de70
commit 80a61d2d89
6 changed files with 84 additions and 46 deletions

View File

@@ -1,3 +1,6 @@
Version 2.2.044
Fixed copper armor and tools not working with Repair or Salvage
Version 2.2.043
Added support for the new copper tools and armor added in Minecraft 1.21.9
Added many missing buttons, trapdoors, doors, fence gates, etc to the ability/tool blacklists (see notes)

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.2.044-SNAPSHOT</version>
<version>2.2.044</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@@ -1,5 +1,20 @@
package com.gmail.nossr50.config.skills.repair;
import static com.gmail.nossr50.util.ItemUtils.isCopperArmor;
import static com.gmail.nossr50.util.ItemUtils.isCopperTool;
import static com.gmail.nossr50.util.ItemUtils.isDiamondArmor;
import static com.gmail.nossr50.util.ItemUtils.isDiamondTool;
import static com.gmail.nossr50.util.ItemUtils.isGoldArmor;
import static com.gmail.nossr50.util.ItemUtils.isGoldTool;
import static com.gmail.nossr50.util.ItemUtils.isIronArmor;
import static com.gmail.nossr50.util.ItemUtils.isIronTool;
import static com.gmail.nossr50.util.ItemUtils.isLeatherArmor;
import static com.gmail.nossr50.util.ItemUtils.isNetheriteArmor;
import static com.gmail.nossr50.util.ItemUtils.isNetheriteTool;
import static com.gmail.nossr50.util.ItemUtils.isStoneTool;
import static com.gmail.nossr50.util.ItemUtils.isStringTool;
import static com.gmail.nossr50.util.ItemUtils.isWoodTool;
import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.skills.ItemType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
@@ -63,27 +78,27 @@ public class RepairConfig extends BukkitConfig {
String repairMaterialTypeString = config.getString(
"Repairables." + key + ".MaterialType", "OTHER");
if (!config.contains("Repairables." + key + ".MaterialType") && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (!config.contains("Repairables." + key + ".MaterialType")) {
final ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isWoodTool(repairItem)) {
if (isWoodTool(repairItem)) {
repairMaterialType = MaterialType.WOOD;
} else if (ItemUtils.isStoneTool(repairItem)) {
} else if (isStoneTool(repairItem)) {
repairMaterialType = MaterialType.STONE;
} else if (ItemUtils.isStringTool(repairItem)) {
} else if (isStringTool(repairItem)) {
repairMaterialType = MaterialType.STRING;
} else if (ItemUtils.isLeatherArmor(repairItem)) {
} else if (isLeatherArmor(repairItem)) {
repairMaterialType = MaterialType.LEATHER;
} else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
} else if (isIronArmor(repairItem) || isIronTool(repairItem)) {
repairMaterialType = MaterialType.IRON;
} else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
} else if (isGoldArmor(repairItem) || isGoldTool(repairItem)) {
repairMaterialType = MaterialType.GOLD;
} else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(
repairItem)) {
} else if (isDiamondArmor(repairItem) || isDiamondTool(repairItem)) {
repairMaterialType = MaterialType.DIAMOND;
} else if (ItemUtils.isNetheriteArmor(repairItem) || ItemUtils.isNetheriteTool(
repairItem)) {
} else if (isNetheriteArmor(repairItem) || isNetheriteTool(repairItem)) {
repairMaterialType = MaterialType.NETHERITE;
} else if (isCopperTool(repairItem) || isCopperArmor(repairItem)) {
repairMaterialType = MaterialType.COPPER;
}
} else {
try {
@@ -105,9 +120,7 @@ public class RepairConfig extends BukkitConfig {
}
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability()
: (short) config.getInt(
"Repairables." + key + ".MaximumDurability"));
short maximumDurability = itemMaterial.getMaxDurability();
if (maximumDurability <= 0) {
maximumDurability = (short) config.getInt(
@@ -169,7 +182,7 @@ public class RepairConfig extends BukkitConfig {
//Report unsupported
StringBuilder stringBuilder = new StringBuilder();
if (notSupported.size() > 0) {
if (!notSupported.isEmpty()) {
stringBuilder.append(
"mcMMO found the following materials in the Repair config that are not supported by the version of Minecraft running on this server: ");

View File

@@ -1,5 +1,21 @@
package com.gmail.nossr50.config.skills.salvage;
import static com.gmail.nossr50.util.ItemUtils.isCopperArmor;
import static com.gmail.nossr50.util.ItemUtils.isCopperTool;
import static com.gmail.nossr50.util.ItemUtils.isDiamondArmor;
import static com.gmail.nossr50.util.ItemUtils.isDiamondTool;
import static com.gmail.nossr50.util.ItemUtils.isGoldArmor;
import static com.gmail.nossr50.util.ItemUtils.isGoldTool;
import static com.gmail.nossr50.util.ItemUtils.isIronArmor;
import static com.gmail.nossr50.util.ItemUtils.isIronTool;
import static com.gmail.nossr50.util.ItemUtils.isLeatherArmor;
import static com.gmail.nossr50.util.ItemUtils.isNetheriteArmor;
import static com.gmail.nossr50.util.ItemUtils.isNetheriteTool;
import static com.gmail.nossr50.util.ItemUtils.isPrismarineTool;
import static com.gmail.nossr50.util.ItemUtils.isStoneTool;
import static com.gmail.nossr50.util.ItemUtils.isStringTool;
import static com.gmail.nossr50.util.ItemUtils.isWoodTool;
import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.datatypes.skills.ItemType;
@@ -50,9 +66,9 @@ public class SalvageConfig extends BukkitConfig {
mcMMO.p.getLogger().log(
Level.INFO,
"Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
for (String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
for (String namespacedKey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
config.set(
"Salvageables." + namespacedkey.toUpperCase(Locale.ENGLISH)
"Salvageables." + namespacedKey.toUpperCase(Locale.ENGLISH)
+ ".MaximumQuantity",
4); //TODO: Doesn't make sense to default to 4 for everything
}
@@ -84,34 +100,32 @@ public class SalvageConfig extends BukkitConfig {
// Salvage Material Type
MaterialType salvageMaterialType = MaterialType.OTHER;
String salvageMaterialTypeString = config.getString(
final String salvageMaterialTypeString = config.getString(
"Salvageables." + key + ".MaterialType", "OTHER");
if (!config.contains("Salvageables." + key + ".MaterialType") && itemMaterial != null) {
ItemStack salvageItem = new ItemStack(itemMaterial);
if (!config.contains("Salvageables." + key + ".MaterialType")) {
final ItemStack salvageItem = new ItemStack(itemMaterial);
if (ItemUtils.isWoodTool(salvageItem)) {
if (isWoodTool(salvageItem)) {
salvageMaterialType = MaterialType.WOOD;
} else if (ItemUtils.isStoneTool(salvageItem)) {
} else if (isStoneTool(salvageItem)) {
salvageMaterialType = MaterialType.STONE;
} else if (ItemUtils.isStringTool(salvageItem)) {
} else if (isStringTool(salvageItem)) {
salvageMaterialType = MaterialType.STRING;
} else if (ItemUtils.isPrismarineTool(salvageItem)) {
} else if (isPrismarineTool(salvageItem)) {
salvageMaterialType = MaterialType.PRISMARINE;
} else if (ItemUtils.isLeatherArmor(salvageItem)) {
} else if (isLeatherArmor(salvageItem)) {
salvageMaterialType = MaterialType.LEATHER;
} else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(
salvageItem)) {
} else if (isIronArmor(salvageItem) || isIronTool(salvageItem)) {
salvageMaterialType = MaterialType.IRON;
} else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(
salvageItem)) {
} else if (isGoldArmor(salvageItem) || isGoldTool(salvageItem)) {
salvageMaterialType = MaterialType.GOLD;
} else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(
salvageItem)) {
} else if (isDiamondArmor(salvageItem) || isDiamondTool(salvageItem)) {
salvageMaterialType = MaterialType.DIAMOND;
} else if (ItemUtils.isNetheriteTool(salvageItem) || ItemUtils.isNetheriteArmor(
salvageItem)) {
} else if (isNetheriteTool(salvageItem) || isNetheriteArmor(salvageItem)) {
salvageMaterialType = MaterialType.NETHERITE;
} else if (isCopperTool(salvageItem) || isCopperArmor(salvageItem)) {
salvageMaterialType = MaterialType.COPPER;
}
} else {
try {
@@ -124,8 +138,7 @@ public class SalvageConfig extends BukkitConfig {
}
// Salvage Material
String salvageMaterialName = config.getString(
"Salvageables." + key + ".SalvageMaterial");
String salvageMaterialName = config.getString("Salvageables." + key + ".SalvageMaterial");
Material salvageMaterial = (salvageMaterialName == null
? salvageMaterialType.getDefaultMaterial()
: Material.matchMaterial(salvageMaterialName));
@@ -136,16 +149,14 @@ public class SalvageConfig extends BukkitConfig {
}
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability()
: (short) config.getInt(
"Salvageables." + key + ".MaximumDurability"));
short maximumDurability = itemMaterial.getMaxDurability();
// Item Type
ItemType salvageItemType = ItemType.OTHER;
String salvageItemTypeString = config.getString("Salvageables." + key + ".ItemType",
"OTHER");
if (!config.contains("Salvageables." + key + ".ItemType") && itemMaterial != null) {
if (!config.contains("Salvageables." + key + ".ItemType")) {
ItemStack salvageItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(salvageItem)) {
@@ -170,11 +181,11 @@ public class SalvageConfig extends BukkitConfig {
}
// Maximum Quantity
int maximumQuantity = itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(
itemMaterial,
salvageMaterial) : config.getInt("Salvageables." + key + ".MaximumQuantity", 1);
int maximumQuantity = SkillUtils.getRepairAndSalvageQuantities(
itemMaterial,
salvageMaterial);
if (maximumQuantity <= 0 && itemMaterial != null) {
if (maximumQuantity <= 0) {
maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", 1);
}
@@ -206,7 +217,7 @@ public class SalvageConfig extends BukkitConfig {
//Report unsupported
StringBuilder stringBuilder = new StringBuilder();
if (notSupported.size() > 0) {
if (!notSupported.isEmpty()) {
stringBuilder.append(
"mcMMO found the following materials in the Salvage config that are not supported by the version of Minecraft running on this server: ");

View File

@@ -8,6 +8,7 @@ public enum MaterialType {
WOOD,
STONE,
IRON,
COPPER,
GOLD,
DIAMOND,
NETHERITE,
@@ -45,6 +46,8 @@ public enum MaterialType {
}
case PRISMARINE:
return Material.PRISMARINE_CRYSTALS;
case COPPER:
return Material.COPPER_INGOT;
case OTHER:
default:

View File

@@ -380,6 +380,10 @@ public final class ItemUtils {
return mcMMO.getMaterialMapStore().isIronArmor(item.getType().getKey().getKey());
}
public static boolean isCopperArmor(ItemStack item) {
return mcMMO.getMaterialMapStore().isCopperArmor(item.getType().getKey().getKey());
}
/**
* Checks to see if an item is a diamond armor piece.
*
@@ -452,6 +456,10 @@ public final class ItemUtils {
return mcMMO.getMaterialMapStore().isPrismarineTool(item.getType().getKey().getKey());
}
public static boolean isCopperTool(ItemStack item) {
return mcMMO.getMaterialMapStore().isCopperTool(item.getType().getKey().getKey());
}
/**
* Checks to see if an item is a gold tool.
*