fix copper unit repair not being present

This commit is contained in:
alexcrea 2025-12-01 19:16:14 +01:00
parent 0aad19166f
commit eb24fb4be8
Signed by: alexcrea
GPG key ID: E346CD16413450E3
4 changed files with 54 additions and 2 deletions

View file

@ -31,7 +31,8 @@ public class UpdateHandler {
new Version(1, 6, 7), PUpdate_1_6_7::handleUpdate, new Version(1, 6, 7), PUpdate_1_6_7::handleUpdate,
new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate, new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate, new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate,
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate
); );
private static final List<MCUpdate> mcUpdateMap = List.of( private static final List<MCUpdate> mcUpdateMap = List.of(

View file

@ -17,6 +17,7 @@ public class Update_1_21_11 extends MCUpdate{
var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig();
var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig();
var conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig(); var conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig();
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
// Create spear group // Create spear group
groupConfig.set("spears.type", "include"); groupConfig.set("spears.type", "include");
@ -36,6 +37,9 @@ public class Update_1_21_11 extends MCUpdate{
addAbsentToList(conflictConfig, "restriction_knockback.notAffectedGroups", "spears"); addAbsentToList(conflictConfig, "restriction_knockback.notAffectedGroups", "spears");
addAbsentToList(conflictConfig, "restriction_fire_aspect.notAffectedGroups", "spears"); addAbsentToList(conflictConfig, "restriction_fire_aspect.notAffectedGroups", "spears");
// Unit repair for spears
// Create lunge enchant value and group // Create lunge enchant value and group
baseConfig.set("enchant_limits.minecraft:lunge", 3); baseConfig.set("enchant_limits.minecraft:lunge", 3);
baseConfig.set("enchant_values.minecraft:lunge.item", 2); baseConfig.set("enchant_values.minecraft:lunge.item", 2);
@ -51,6 +55,7 @@ public class Update_1_21_11 extends MCUpdate{
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);
ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true); ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true);
ConfigHolder.CONFLICT_HOLDER.saveToDisk(true); ConfigHolder.CONFLICT_HOLDER.saveToDisk(true);
ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(true);
// imply reload of CONFLICT_HOLDER // imply reload of CONFLICT_HOLDER
// We also do not need to reload base config as there is no object related to it. // We also do not need to reload base config as there is no object related to it.

View file

@ -1,6 +1,6 @@
package xyz.alexcrea.cuanvil.update.minecraft; package xyz.alexcrea.cuanvil.update.minecraft;
import io.delilaheve.CustomAnvil; import org.bukkit.configuration.file.FileConfiguration;
import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.update.UpdateUtils; import xyz.alexcrea.cuanvil.update.UpdateUtils;
import xyz.alexcrea.cuanvil.update.Version; import xyz.alexcrea.cuanvil.update.Version;
@ -17,6 +17,7 @@ public class Update_1_21_9 extends MCUpdate{
protected void doUpdate() { protected void doUpdate() {
var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig();
var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig();
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
// Add cooper items to groups // Add cooper items to groups
addAbsentToList(groupConfig, "helmets.items", "copper_helmet"); addAbsentToList(groupConfig, "helmets.items", "copper_helmet");
@ -30,16 +31,34 @@ public class Update_1_21_9 extends MCUpdate{
addAbsentToList(groupConfig, "axes.items", "copper_axe"); addAbsentToList(groupConfig, "axes.items", "copper_axe");
addAbsentToList(groupConfig, "swords.items", "copper_sword"); addAbsentToList(groupConfig, "swords.items", "copper_sword");
// Add unit repair
addCopperUnitRepair(unitConfig);
// Set version string as current // Set version string as current
baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, version.toString()); baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, version.toString());
// Save // Save
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);
ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true); ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true);
ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(true);
// imply reload of CONFLICT_HOLDER // imply reload of CONFLICT_HOLDER
// We also do not need to reload base config as there is no object related to it. // We also do not need to reload base config as there is no object related to it.
ConfigHolder.ITEM_GROUP_HOLDER.reload(); ConfigHolder.ITEM_GROUP_HOLDER.reload();
} }
public static void addCopperUnitRepair(FileConfiguration unitConfig) {
// Add unit repair
unitConfig.set("copper_ingot.copper_helmet", 0.25);
unitConfig.set("copper_ingot.copper_chestplate", 0.25);
unitConfig.set("copper_ingot.copper_leggings", 0.25);
unitConfig.set("copper_ingot.copper_boots", 0.25);
unitConfig.set("copper_ingot.copper_pickaxe", 0.25);
unitConfig.set("copper_ingot.copper_shovel", 0.25);
unitConfig.set("copper_ingot.copper_hoe", 0.25);
unitConfig.set("copper_ingot.copper_axe", 0.25);
unitConfig.set("copper_ingot.copper_sword", 0.25);
}
} }

View file

@ -0,0 +1,27 @@
package xyz.alexcrea.cuanvil.update.plugin;
import org.bukkit.configuration.file.FileConfiguration;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.update.UpdateUtils;
import xyz.alexcrea.cuanvil.update.Version;
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_9;
import javax.annotation.Nonnull;
import java.util.Set;
public class PUpdate_1_15_6 {
public static void handleUpdate(@Nonnull Set<ConfigHolder> toSave) {
// fix only needed for 1.21.9 and above
Version current = UpdateUtils.currentMinecraftVersion();
if (new Version(1, 21, 9).greaterThan(current)) return;
FileConfiguration unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
// Add unit repair
Update_1_21_9.addCopperUnitRepair(unitConfig);
toSave.add(ConfigHolder.UNIT_REPAIR_HOLDER);
}
}