diff --git a/defaultconfigs/1.18/enchant_conflict.yml b/defaultconfigs/1.18/enchant_conflict.yml index 31506d2b..8e691bb8 100644 --- a/defaultconfigs/1.18/enchant_conflict.yml +++ b/defaultconfigs/1.18/enchant_conflict.yml @@ -160,13 +160,6 @@ restriction_sweeping_edge: enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ] notAffectedGroups: [ enchanted_book, swords ] -# Do not exist in 1.18, that mean useInFuture will be set to true -# useInFuture set to true also mean it will not warn if there is an issue -restriction_swift_sneak: - useInFuture: true - enchantments: [ minecraft:swift_sneak ] - notAffectedGroups: [ enchanted_book, leggings ] - restriction_thorns: enchantments: [ minecraft:thorns ] notAffectedGroups: [ enchanted_book, armors ] diff --git a/defaultconfigs/1.21.11/enchant_conflict.yml b/defaultconfigs/1.21.11/enchant_conflict.yml index 18341d36..20f735c5 100644 --- a/defaultconfigs/1.21.11/enchant_conflict.yml +++ b/defaultconfigs/1.21.11/enchant_conflict.yml @@ -275,10 +275,7 @@ restriction_sweeping_edge: - enchanted_book - swords -# Do not exist in 1.18, that mean useInFuture will be set to true -# useInFuture set to true also mean it will not warn if there is an issue restriction_swift_sneak: - useInFuture: true enchantments: - minecraft:swift_sneak notAffectedGroups: diff --git a/defaultconfigs/1.21.9/enchant_conflict.yml b/defaultconfigs/1.21.9/enchant_conflict.yml index 8ab9e3bc..ae9c955a 100644 --- a/defaultconfigs/1.21.9/enchant_conflict.yml +++ b/defaultconfigs/1.21.9/enchant_conflict.yml @@ -272,10 +272,7 @@ restriction_sweeping_edge: - enchanted_book - swords -# Do not exist in 1.18, that mean useInFuture will be set to true -# useInFuture set to true also mean it will not warn if there is an issue restriction_swift_sneak: - useInFuture: true enchantments: - minecraft:swift_sneak notAffectedGroups: diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java index c548f228..92418a3a 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java @@ -30,10 +30,11 @@ public class UpdateHandler { new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate, new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate, new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate, - new Version(1, 17, 7), PUpdate_1_17_7::handleUpdate + new Version(1, 18, 0), PUpdate_1_18::handleUpdate ); private static final List mcUpdateMap = List.of( + new Update_1_19(), new Update_1_20_5(), new Update_1_21(), new Update_1_21_9(), diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_19.java b/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_19.java new file mode 100644 index 00000000..fc598658 --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/minecraft/Update_1_19.java @@ -0,0 +1,40 @@ +package xyz.alexcrea.cuanvil.update.minecraft; + +import org.jetbrains.annotations.NotNull; +import xyz.alexcrea.cuanvil.config.ConfigHolder; +import xyz.alexcrea.cuanvil.update.Version; + +import java.util.HashSet; +import java.util.Set; + +import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList; + +public class Update_1_19 extends MCUpdate { + + public Update_1_19() { + super(new Version(1, 19)); + } + + @Override + protected void doUpdate() { + var tosave = new HashSet(); + updateName(tosave); + + for (ConfigHolder holder : tosave) { + holder.saveToDisk(true); + } + } + + public static void updateName(@NotNull Set tosave) { + var conflict = ConfigHolder.CONFLICT_HOLDER.getConfig(); + + addAbsentToList(conflict, "restriction_swift_sneak.enchantments", "minecraft:swift_sneak"); + addAbsentToList(conflict, "restriction_swift_sneak.notAffectedGroups", "leggings", "enchanted_book"); + + ConfigHolder.ITEM_GROUP_HOLDER.reload(); + + tosave.add(ConfigHolder.DEFAULT_CONFIG); + tosave.add(ConfigHolder.CONFLICT_HOLDER); + } + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_17_7.java b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_18.java similarity index 74% rename from src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_17_7.java rename to src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_18.java index 972825dd..b52ec7ac 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_17_7.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_18.java @@ -3,19 +3,20 @@ package xyz.alexcrea.cuanvil.update.plugin; 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_19; import xyz.alexcrea.cuanvil.update.minecraft.Update_1_20_5; import javax.annotation.Nonnull; import java.util.Set; -public class PUpdate_1_17_7 { +public class PUpdate_1_18 { public static void handleUpdate(@Nonnull Set toSave) { - // fix only needed for 1.20.5 and above Version current = UpdateUtils.currentMinecraftVersion(); - if (new Version(1, 20, 5).greaterThan(current)) return; + if (new Version(1, 19, 0).greaterThan(current)) return; + Update_1_19.updateName(toSave); + if (new Version(1, 20, 5).greaterThan(current)) return; Update_1_20_5.updateName(toSave); } - } diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt index 39def31f..ee9c718b 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt @@ -3,7 +3,6 @@ package xyz.alexcrea.cuanvil.group import io.delilaheve.CustomAnvil import org.bukkit.NamespacedKey import org.bukkit.configuration.ConfigurationSection -import org.bukkit.enchantments.Enchantment import org.bukkit.inventory.ItemStack import xyz.alexcrea.cuanvil.api.EnchantmentApi import xyz.alexcrea.cuanvil.enchant.AdditionalTestEnchantment @@ -33,10 +32,6 @@ class EnchantConflictManager { // Path for the maximum number of enchantment before validating the conflict const val ENCH_MAX_PATH = "maxEnchantmentBeforeConflict" - // Path for a flag: if the enchantment will be used in the last supported version - // TODO maybe replace this system by a list of "future" enchantment. - private const val FUTURE_USE_PATH = "useInFuture" - // Default name for a joining group const val DEFAULT_GROUP_NAME = "joinedGroup" } @@ -101,8 +96,6 @@ class EnchantConflictManager { itemManager: ItemGroupManager, conflictName: String ): EnchantConflictGroup { - // Is it planed for the future - val futureUse = section.getBoolean(FUTURE_USE_PATH, false) // Create conflict val conflict = createConflictObject(section, itemManager, conflictName) // Read and add enchantment to conflict @@ -110,17 +103,13 @@ class EnchantConflictManager { for (enchantName in enchantList) { val enchants = getEnchantByIdentifier(enchantName) if (enchants.isEmpty()) { - if (!futureUse) { //TODO future use will be deprecated once the new update system is finished - CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName") - } + CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName") continue } conflict.addEnchantments(enchants) } if (conflict.getEnchants().isEmpty()) { - if (!futureUse) { //TODO future use will be deprecated once the new update system is finished - CustomAnvil.instance.logger.warning("Conflict $conflictName do not have valid enchantment, it will not do anything") - } + CustomAnvil.instance.logger.warning("Conflict $conflictName do not have valid enchantment, it will not do anything") } val conflictsAfterLevel = section.getConfigurationSection(CONFLICT_AFTER_LEVEL_LIST_PATH) diff --git a/src/main/resources/enchant_conflict.yml b/src/main/resources/enchant_conflict.yml index 31506d2b..8e691bb8 100644 --- a/src/main/resources/enchant_conflict.yml +++ b/src/main/resources/enchant_conflict.yml @@ -160,13 +160,6 @@ restriction_sweeping_edge: enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ] notAffectedGroups: [ enchanted_book, swords ] -# Do not exist in 1.18, that mean useInFuture will be set to true -# useInFuture set to true also mean it will not warn if there is an issue -restriction_swift_sneak: - useInFuture: true - enchantments: [ minecraft:swift_sneak ] - notAffectedGroups: [ enchanted_book, leggings ] - restriction_thorns: enchantments: [ minecraft:thorns ] notAffectedGroups: [ enchanted_book, armors ]