diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java index 34f385c..a563b7f 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java @@ -31,7 +31,8 @@ public class UpdateHandler { new Version(1, 6, 7), PUpdate_1_6_7::handleUpdate, new Version(1, 8, 0), PUpdate_1_8_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 mcUpdateMap = List.of( diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_11.java b/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_11.java index a060394..90c17bf 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_11.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_11.java @@ -17,6 +17,7 @@ public class Update_1_21_11 extends MCUpdate{ var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); var conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig(); + var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); // Create spear group 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_fire_aspect.notAffectedGroups", "spears"); + // Unit repair for spears + + // Create lunge enchant value and group baseConfig.set("enchant_limits.minecraft:lunge", 3); 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.ITEM_GROUP_HOLDER.saveToDisk(true); ConfigHolder.CONFLICT_HOLDER.saveToDisk(true); + ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(true); // imply reload of CONFLICT_HOLDER // We also do not need to reload base config as there is no object related to it. diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_9.java b/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_9.java index a4e21a7..d289b9b 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_9.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_21_9.java @@ -1,6 +1,6 @@ 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.update.UpdateUtils; import xyz.alexcrea.cuanvil.update.Version; @@ -17,6 +17,7 @@ public class Update_1_21_9 extends MCUpdate{ protected void doUpdate() { var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig(); var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); + var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); // Add cooper items to groups 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, "swords.items", "copper_sword"); + // Add unit repair + addCopperUnitRepair(unitConfig); + // Set version string as current baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, version.toString()); // Save ConfigHolder.DEFAULT_CONFIG.saveToDisk(true); ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true); + ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(true); // imply reload of CONFLICT_HOLDER // We also do not need to reload base config as there is no object related to it. 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); + } + } diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_15_6.java b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_15_6.java new file mode 100644 index 0000000..fde7cfc --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_15_6.java @@ -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 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); + } + +}