From 1e644f0a94bff6a624bffc847901ec0e50025e93 Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:27:25 +0200 Subject: [PATCH] progress on update system --- .../cuanvil/config/ConfigHolderEnum.java | 22 ++ .../alexcrea/cuanvil/update/AtomicUpdate.java | 120 +++++++++ .../cuanvil/update/AtomicUpdateType.java | 10 + .../cuanvil/update/ConfigVersion.java | 10 + .../cuanvil/update/UpdateManager.java | 165 ++++++++++++ .../cuanvil/update/UpdateResource.java | 7 + .../xyz/alexcrea/cuanvil/update/Version.java | 71 +++++ .../cuanvil/recipe/AnvilCustomRecipe.kt | 4 +- .../resources/version/1.18/configs/config.yml | 246 ++++++++++++++++++ .../version/1.18/configs/custom_recipes.yml | 5 + .../version/1.18/configs/enchant_conflict.yml | 238 +++++++++++++++++ .../version/1.18/configs/item_groups.yml | 201 ++++++++++++++ .../version/1.18/configs/unit_repair_item.yml | 185 +++++++++++++ src/main/resources/version/1.18/versionList | 0 src/main/resources/version/1.20/updateList | 0 .../resources/version/1.20/versionUpgrade.yml | 12 + src/main/resources/version/versionList.txt | 3 + 17 files changed, 1297 insertions(+), 2 deletions(-) create mode 100644 src/main/java/xyz/alexcrea/cuanvil/config/ConfigHolderEnum.java create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdate.java create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdateType.java create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/ConfigVersion.java create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/UpdateManager.java create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/UpdateResource.java create mode 100644 src/main/java/xyz/alexcrea/cuanvil/update/Version.java create mode 100644 src/main/resources/version/1.18/configs/config.yml create mode 100644 src/main/resources/version/1.18/configs/custom_recipes.yml create mode 100644 src/main/resources/version/1.18/configs/enchant_conflict.yml create mode 100644 src/main/resources/version/1.18/configs/item_groups.yml create mode 100644 src/main/resources/version/1.18/configs/unit_repair_item.yml create mode 100644 src/main/resources/version/1.18/versionList create mode 100644 src/main/resources/version/1.20/updateList create mode 100644 src/main/resources/version/1.20/versionUpgrade.yml create mode 100644 src/main/resources/version/versionList.txt diff --git a/src/main/java/xyz/alexcrea/cuanvil/config/ConfigHolderEnum.java b/src/main/java/xyz/alexcrea/cuanvil/config/ConfigHolderEnum.java new file mode 100644 index 0000000..bfc82e0 --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/config/ConfigHolderEnum.java @@ -0,0 +1,22 @@ +package xyz.alexcrea.cuanvil.config; + +public enum ConfigHolderEnum { + + DEFAULT(ConfigHolder.DEFAULT_CONFIG), + ITEM_GROUP(ConfigHolder.ITEM_GROUP_HOLDER), + CONFLICT(ConfigHolder.CONFLICT_HOLDER), + UNIT_REPAIR(ConfigHolder.UNIT_REPAIR_HOLDER), + CUSTOM_RECIPE(ConfigHolder.CUSTOM_RECIPE_HOLDER) + ; + + private final ConfigHolder configHolder; + + ConfigHolderEnum(ConfigHolder configHolder) { + this.configHolder = configHolder; + } + + public ConfigHolder getConfigHolder() { + return configHolder; + } + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdate.java b/src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdate.java new file mode 100644 index 0000000..6b3ca71 --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdate.java @@ -0,0 +1,120 @@ +package xyz.alexcrea.cuanvil.update; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import xyz.alexcrea.cuanvil.config.ConfigHolder; +import xyz.alexcrea.cuanvil.config.ConfigHolderEnum; + +import java.util.List; + +public record AtomicUpdate ( + @NotNull AtomicUpdateType type, + @NotNull ConfigHolderEnum configType, + @NotNull String path, + @Nullable String expected, // Ignored on list + @Nullable String value // Ignored on unset. not null if not unset + +){ + + private static final String UPDATE_TYPE = "type"; + private static final String CONFIG_TYPE_PATH = "config_type"; + private static final String PATH_PATH = "path"; + private static final String EXPECTED_PATH = "expected"; + private static final String VALUE_PATH = "value"; + + public static @Nullable AtomicUpdate fromConfig(@NotNull ConfigurationSection section){ + String typeString = section.getString(UPDATE_TYPE); + String configTypeString = section.getString(CONFIG_TYPE_PATH); + String path = section.getString(PATH_PATH); + String expected = section.getString(EXPECTED_PATH); + String value = section.getString(VALUE_PATH); + + if((configTypeString == null) || + (typeString == null) || + (path == null)){ + return null; + } + + AtomicUpdateType type; + try { + type = AtomicUpdateType.valueOf(typeString.toUpperCase()); + } catch (Exception e) { return null; } + + if(type != AtomicUpdateType.UNSET && value == null){ + return null; + } + + ConfigHolderEnum configType; + try { + configType = ConfigHolderEnum.valueOf(configTypeString.toUpperCase()); + } catch (Exception e) { return null; } + + + return new AtomicUpdate(type, configType, path, expected, value); + } + + // Is string equal can take null, it also checks if the content is equal but ignore case + private boolean isStringEqual(@Nullable String val1, @Nullable String val2){ + if(val1 == null){ + return val2 == null; + } + return val1.equalsIgnoreCase(val2); + } + + public boolean isExpected(boolean ignoreIfOperationIsDone){ + switch (this.type){ + case SET -> { + String value = this.configType.getConfigHolder().getConfig().getString(this.path); + return (isStringEqual(value, this.expected)) || (ignoreIfOperationIsDone && isStringEqual(value, this.value)); + } + case UNSET -> { + String value = this.configType.getConfigHolder().getConfig().getString(this.path); + return (isStringEqual(value, this.expected)) || (ignoreIfOperationIsDone && (value == null)); + } + case LIST_ADD -> { + List values = this.configType.getConfigHolder().getConfig().getStringList(this.path); + return ignoreIfOperationIsDone || !values.contains(this.value); + } + + case LIST_REMOVE -> { + List values = this.configType.getConfigHolder().getConfig().getStringList(this.path); + return ignoreIfOperationIsDone || values.contains(this.value); + } + } + + return false; + } + + public boolean tryApplyUpdate(boolean forceUnexpected, boolean ignoreIfResultEqual){ + if(!forceUnexpected && !isExpected(ignoreIfResultEqual)){ + return false; + } + + ConfigHolder configHolder = this.configType.getConfigHolder(); + FileConfiguration config = configHolder.getConfig(); + + switch (this.type){ + case SET -> { + config.set(this.path, this.value); + } + case UNSET -> { + config.set(this.path, null); + } + case LIST_ADD -> { + List values = config.getStringList(this.path); + values.add(this.value); + config.set(this.path, this.value); + } + case LIST_REMOVE -> { + List values = config.getStringList(this.path); + values.remove(this.value); + config.set(this.path, this.value); + } + } + + return true; + } + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdateType.java b/src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdateType.java new file mode 100644 index 0000000..ae3393b --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/AtomicUpdateType.java @@ -0,0 +1,10 @@ +package xyz.alexcrea.cuanvil.update; + +public enum AtomicUpdateType { + + SET, + UNSET, + LIST_ADD, + LIST_REMOVE + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/ConfigVersion.java b/src/main/java/xyz/alexcrea/cuanvil/update/ConfigVersion.java new file mode 100644 index 0000000..3970cdd --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/ConfigVersion.java @@ -0,0 +1,10 @@ +package xyz.alexcrea.cuanvil.update; + +public class ConfigVersion { + + public ConfigVersion(Version configVersion){ + + } + + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/UpdateManager.java b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateManager.java new file mode 100644 index 0000000..4b117ff --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateManager.java @@ -0,0 +1,165 @@ +package xyz.alexcrea.cuanvil.update; + +import jdk.incubator.vector.VectorShape; +import kotlin.Pair; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.Nullable; +import xyz.alexcrea.cuanvil.config.ConfigHolder; + +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +public class UpdateManager { + private final static Version MAX_KNOW_MINECRAFT_VERSION = new Version(1, 20, 6); + + private final static String UPDATE_FOLDER = "version"; + private final static String VERSION_LIST_RESSOUCE = UPDATE_FOLDER+"/versionList.txt"; + + private List minecraftVersionList; + private Version minecraftVersion; + private Version usedMinecraftVersion; + private Version lastUsedMinecraftVersion; + private Version configVersion; + + public UpdateManager(){ + } + public void checkUpdate(Plugin plugin){ + readVersions(plugin); + + if(minecraftVersion == null){ + plugin.getLogger().warning("Could not detect minecraft version"); + return; + } + if(usedMinecraftVersion == null){ + plugin.getLogger().warning("Can't detect lowest compatible config version"); + + } + + if(minecraftVersion.compareTo(MAX_KNOW_MINECRAFT_VERSION) > 0){ + plugin.getLogger().warning("It look Like your minecraft version may not be supported."); + plugin.getLogger().warning("Last Known supported version is " + MAX_KNOW_MINECRAFT_VERSION + ", and your server version was detected as " + minecraftVersion); + plugin.getLogger().warning("The plugin may still work if there is no change since last supported version. But no guaranty."); + } + + + + } + + public void readVersions(Plugin plugin){ + if(minecraftVersionList == null || minecraftVersionList.isEmpty()){ + readMinecraftVersionList(plugin); + } + if(minecraftVersionList == null || minecraftVersionList.isEmpty()){ + return; + } + + // Should work //TODO test for paper and spigot + String versionString = Bukkit.getServer().getBukkitVersion().split("-")[0]; + System.out.println(versionString + " ; " + Bukkit.getServer().getBukkitVersion()); //TESTING + this.minecraftVersion = Version.versionOf(versionString); + if(this.minecraftVersion == null) return; + + this.usedMinecraftVersion = firstValidVersion(this.minecraftVersion); + + FileConfiguration config = ConfigHolder.DEFAULT_CONFIG.getConfig(); + String lastUsedMinecraftVersionString = config.getString("lowestMinecraftVersion"); + String configVersionString = config.getString("configVersion"); + + this.lastUsedMinecraftVersion = Version.versionOf(lastUsedMinecraftVersionString); + this.configVersion = Version.versionOf(configVersionString); + + if(this.lastUsedMinecraftVersion == null){ + this.lastUsedMinecraftVersion = new Version(0,0,0); + } + + } + + public Version firstValidVersion(Version toFind){ + for (Version version : this.minecraftVersionList) { // Assume sorted + if(version.compareTo(toFind) >= 0) return version; + } + return null; + } + + public void readMinecraftVersionList(Plugin plugin){ + this.minecraftVersionList = readVersionList(plugin, VERSION_LIST_RESSOUCE); + if(this.minecraftVersionList != null){ + this.minecraftVersionList.sort(Version::compareTo); + } + } + + public static List readVersionList(Plugin plugin, InputStream inputStream){ + ArrayList versionList = new ArrayList<>(); + Scanner scanner = new Scanner(inputStream); + + // Read every version + while (scanner.hasNextLine()){ + String line = scanner.nextLine(); + if(line.isEmpty()) continue; + + Version version = Version.versionOf(line); + if(version == null){ + plugin.getLogger().warning("Could not parse version \"" + line + "\""); + continue; + } + versionList.add(version); + } + + scanner.close(); + try { + inputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return versionList; + } + public static List> readUpdateList(Plugin plugin, InputStream inputStream){ + ArrayList> versionList = new ArrayList<>(); + Scanner scanner = new Scanner(inputStream); + + // Read every version + while (scanner.hasNextLine()){ + String line = scanner.nextLine(); + if(line.isEmpty()) continue; + + String[] versions = line.split("/", 2); + if(versions.length <= 1){ + plugin.getLogger().warning("Could not parse update \"" + line + "\""); + continue; + } + + Version minecraftVersion = Version.versionOf(versions[0]); + Version pluginVersion = Version.versionOf(versions[1]); + if((minecraftVersion == null) || (pluginVersion == null)){ + plugin.getLogger().warning("Could not parse update \"" + line + "\""); + continue; + } + + versionList.add(new Pair<>(minecraftVersion, pluginVersion)); + } + + scanner.close(); + try { + inputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return versionList; + } + + public static @Nullable List readVersionList(Plugin plugin, String ressouceName){ + InputStream inputStream = plugin.getResource(ressouceName); + if(inputStream == null){ + plugin.getLogger().severe("Could not find version list from resource "+ressouceName); + return null; + } + + return readVersionList(plugin, inputStream); + } + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/UpdateResource.java b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateResource.java new file mode 100644 index 0000000..11d182d --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/UpdateResource.java @@ -0,0 +1,7 @@ +package xyz.alexcrea.cuanvil.update; + +public class UpdateResource { + + + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/Version.java b/src/main/java/xyz/alexcrea/cuanvil/update/Version.java new file mode 100644 index 0000000..e0c38a9 --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/update/Version.java @@ -0,0 +1,71 @@ +package xyz.alexcrea.cuanvil.update; + +import com.google.common.primitives.Ints; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public record Version(int major, int minor, int build) implements Comparable{ + + public static @Nullable Version versionOf(@Nullable String version){ + if(version == null) return null; + String[] numbers = version.split("\\.", 3); + + Integer major; + Integer minor; + Integer patch; + + major = Ints.tryParse(numbers[0]); + // Minor number + if(numbers.length >= 2){ + minor = Ints.tryParse(numbers[1]); + }else{ + minor = 0; + } + // Patch number + if(numbers.length >= 3){ + patch = Ints.tryParse(numbers[2]); + }else{ + patch = 0; + } + + if((major == null) || (minor == null) || (patch == null)){ + return null; + } + + return new Version(major, minor, patch); + } + + + @Override + public int compareTo(@NotNull Version other) { + if(this.major > other.major) return 1; + else if (this.major < other.major) return -1; + + if(this.minor > other.minor) return 1; + else if (this.minor < other.minor) return -1; + + if(this.build > other.build) return 1; + else if (this.build < other.build) return -1; + + return 0; + } + + @Override + public boolean equals(Object obj) { + if(obj instanceof Version other){ + return (other.major == this.major) && (other.minor == this.minor) && (other.build == this.build); + } + return false; + } + + @Override + public String toString() { + if(build > 0){ + return major + "." + minor + "." + build; + } + if(minor > 0){ + return major + "." + minor; + } + return String.valueOf(major); + } +} diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt index 114dbe3..1295e8f 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/recipe/AnvilCustomRecipe.kt @@ -9,8 +9,8 @@ import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant class AnvilCustomRecipe( val name: String, var exactCount: Boolean, - //var exactLeft: Boolean, - //var exactRight: Boolean, + + // Meta and var xpCostPerCraft: Int, diff --git a/src/main/resources/version/1.18/configs/config.yml b/src/main/resources/version/1.18/configs/config.yml new file mode 100644 index 0000000..aa09cf4 --- /dev/null +++ b/src/main/resources/version/1.18/configs/config.yml @@ -0,0 +1,246 @@ +# All anvil cost will be capped to limit_repair_value if enabled. +# +# In other words: +# For any anvil cost greater than limit_repair_value, Cost will be set to limit_repair_value. +limit_repair_cost: false + +# Max cost value the Anvil can get to. +# +# Valid values include 0 to 1000. +# Cost will be displayed as "Too Expensive": +# - If Cost is above 39 +# - And replace_too_expensive is disabled (false) +limit_repair_value: 39 + +# Whether the anvil's cost limit should be removed entirely. +# +# The anvil will still visually display "Too Expensive" if "replace_too_expensive" is disabled +# However, the action will be completable if xp requirement is meet. +remove_repair_limit: false + +# Whenever anvil cost is above 39 should display the true price and not "Too Expensive". +# +# However, when bypassing "Too Expensive", anvil price will be displayed as Green. +# If the action is not completable, the cost will still be displayed as "Too expensive". +# That mean you also need to change other settings like remove_repair_limit or limit_repair_cost. +# +# Require ProtocoLib. +replace_too_expensive: false + +# XP Level amount added to the anvil when the item is repaired by another item of the same type +# +# Valid values include 0 to 1000 +item_repair_cost: 2 + +# XP Level amount added to the anvil when the item is renamed +# +# Valid values include 0 to 1000 +item_rename_cost: 1 + +# XP Level amount added to the anvil when the item is repaired by an "unit" +# For example: a Diamond on a Diamond Sword +# What's considered unit for what can be edited on the unit repair configuration. +# +# Valid values include 0 to 1000 +unit_repair_cost: 1 + +# XP Level amount added to the anvil when a sacrifice enchantment +# conflict with one of the left item enchantment +# +# Valid values include 0 to 1000 +sacrifice_illegal_enchant_cost: 1 + +# Default limit to apply to any enchants missing from override_limits +# +# Valid values include 1 to 1000 +default_limit: 5 + +# Override limits for specific enchants +# +# Enchantments not listed here will use the value of default_limit +# +# Overrides provided default from aqua_affinity to depth_strider won't change effect with extra levels +# +# Valid range of 1 - 255 for each enchantment +enchant_limits: + aqua_affinity: 1 + binding_curse: 1 + channeling: 1 + flame: 1 + infinity: 1 + mending: 1 + multishot: 1 + silk_touch: 1 + vanishing_curse: 1 + depth_strider: 3 # anything more than 3 is treated as 3 by the game + protection: 4 + fire_protection: 4 + blast_protection: 4 + projectile_protection: 4 + feather_falling: 4 + thorns: 3 + respiration: 3 + sharpness: 5 + smite: 5 + bane_of_arthropods: 5 + knockback: 2 + fire_aspect: 2 + looting: 3 + sweeping: 3 + sweeping_edge: 3 + efficiency: 5 + unbreaking: 3 + fortune: 3 + power: 5 + punch: 2 + luck_of_the_sea: 3 + lure: 3 + frost_walker: 2 + impaling: 5 + riptide: 3 + loyalty: 3 + piercing: 4 + quick_charge: 3 + soul_speed: 3 + swift_sneak: 3 + +# Multipliers used to calculate the enchantment's value in repair/combining +# +# Values here are pulled from the fandom wiki: +# https://minecraft.fandom.com/wiki/Anvil_mechanics#Costs_for_combining_enchantments +# +# If an enchantment is missing values here, or is less than 0, it will default to 0 +# +# Calculated as: [Enchantment lvl] * [multiplier] +# +# With default values protection 4 would have a value of 4 when +# coming from either a book (4 * 1) or an item (4 * 1) +enchant_values: + aqua_affinity: + item: 4 + book: 2 + bane_of_arthropods: + item: 2 + book: 1 + binding_curse: + item: 8 + book: 4 + blast_protection: + item: 4 + book: 2 + channeling: + item: 8 + book: 4 + depth_strider: + item: 4 + book: 2 + efficiency: + item: 1 + book: 1 + flame: + item: 4 + book: 2 + feather_falling: + item: 2 + book: 1 + fire_aspect: + item: 4 + book: 2 + fire_protection: + item: 2 + book: 1 + fortune: + item: 4 + book: 2 + frost_walker: + item: 4 + book: 2 + impaling: + item: 4 + book: 2 + infinity: + item: 8 + book: 4 + knockback: + item: 2 + book: 1 + looting: + item: 4 + book: 2 + loyalty: + item: 1 + book: 1 + luck_of_the_sea: + item: 4 + book: 2 + lure: + item: 4 + book: 2 + mending: + item: 4 + book: 2 + multishot: + item: 4 + book: 2 + piercing: + item: 1 + book: 1 + power: + item: 1 + book: 1 + projectile_protection: + item: 2 + book: 1 + protection: + item: 1 + book: 1 + punch: + item: 4 + book: 2 + quick_charge: + item: 2 + book: 1 + respiration: + item: 4 + book: 2 + riptide: + item: 4 + book: 2 + silk_touch: + item: 8 + book: 4 + sharpness: + item: 1 + book: 1 + smite: + item: 2 + book: 1 + soul_speed: + item: 8 + book: 4 + swift_sneak: + item: 8 + book: 4 + sweeping: + item: 4 + book: 2 + sweeping_edge: + item: 4 + book: 2 + thorns: + item: 8 + book: 4 + unbreaking: + item: 2 + book: 1 + vanishing_curse: + item: 8 + book: 4 + +# Whether to show debug logging +debug_log: false + +# Whether to show verbose debug logging +debug_log_verbose: false + +configVersion: 1.4.5 diff --git a/src/main/resources/version/1.18/configs/custom_recipes.yml b/src/main/resources/version/1.18/configs/custom_recipes.yml new file mode 100644 index 0000000..57c2220 --- /dev/null +++ b/src/main/resources/version/1.18/configs/custom_recipes.yml @@ -0,0 +1,5 @@ +# ---------------------------------------------------- +# This config file is to store custom craft +# It is recommended to use the in game config editor for this configuration. +# /customanvilconfig With ca.config.edit permission +# ---------------------------------------------------- diff --git a/src/main/resources/version/1.18/configs/enchant_conflict.yml b/src/main/resources/version/1.18/configs/enchant_conflict.yml new file mode 100644 index 0000000..387fc90 --- /dev/null +++ b/src/main/resources/version/1.18/configs/enchant_conflict.yml @@ -0,0 +1,238 @@ +# material conflicts +# +# If you want to edit this file: +# - A conflict will apply to every item except if in one of the notAffectedGroups group +# - the conflict will count only if the user try to combine at least as +# many conflicting enchantment as "maxEnchantmentBeforeConflict" +# +# +# ---------------------------------------------------- +# These restriction are about not allowing enchantment +# on illegal items +# ---------------------------------------------------- + +restriction_aqua_affinity: + enchantments: [ aqua_affinity ] + notAffectedGroups: [ enchanted_book, helmets ] + +restriction_bane_of_arthropods: + enchantments: [ bane_of_arthropods ] + notAffectedGroups: [ enchanted_book, melee_weapons ] + +restriction_blast_protection: + enchantments: [ blast_protection ] + notAffectedGroups: [ enchanted_book, armors ] + +restriction_channeling: + enchantments: [ channeling ] + notAffectedGroups: [ enchanted_book, trident ] + +restriction_binding_curse: + enchantments: [ binding_curse ] + notAffectedGroups: [ enchanted_book, wearable ] + +restriction_vanishing_curse: + enchantments: [ vanishing_curse ] + notAffectedGroups: [ enchanted_book, can_vanish ] + +restriction_depth_strider: + enchantments: [ depth_strider ] + notAffectedGroups: [ enchanted_book, boots ] + +restriction_efficiency: + enchantments: [ efficiency ] + notAffectedGroups: [ enchanted_book, tools, shears ] + +restriction_feather_falling: + enchantments: [ feather_falling ] + notAffectedGroups: [ enchanted_book, boots ] + +restriction_fire_aspect: + enchantments: [ fire_aspect ] + notAffectedGroups: [ enchanted_book, swords ] + +restriction_fire_protection: + enchantments: [ fire_protection ] + notAffectedGroups: [ enchanted_book, armors ] + +restriction_flame: + enchantments: [ flame ] + notAffectedGroups: [ enchanted_book, bow ] + +restriction_fortune: + enchantments: [ fortune ] + notAffectedGroups: [ enchanted_book, tools ] + +restriction_frost_walker: + enchantments: [ frost_walker ] + notAffectedGroups: [ enchanted_book, boots ] + +restriction_impaling: + enchantments: [ impaling ] + notAffectedGroups: [ enchanted_book, trident ] + +restriction_infinity: + enchantments: [ infinity ] + notAffectedGroups: [ enchanted_book, bow ] + +restriction_knockback: + enchantments: [ knockback ] + notAffectedGroups: [ enchanted_book, swords ] + +restriction_looting: + enchantments: [ looting ] + notAffectedGroups: [ enchanted_book, swords ] + +restriction_loyalty: + enchantments: [ loyalty ] + notAffectedGroups: [ enchanted_book, trident ] + +restriction_lure: + enchantments: [ lure ] + notAffectedGroups: [ enchanted_book, fishing_rod ] + +restriction_mending: + enchantments: [ mending ] + notAffectedGroups: [ enchanted_book, can_unbreak ] + +restriction_multishot: + enchantments: [ multishot ] + notAffectedGroups: [ enchanted_book, crossbow ] + +restriction_piercing: + enchantments: [ piercing ] + notAffectedGroups: [ enchanted_book, crossbow ] + +restriction_power: + enchantments: [ power ] + notAffectedGroups: [ enchanted_book, bow ] + +restriction_projectile_protection: + enchantments: [ projectile_protection ] + notAffectedGroups: [ enchanted_book, armors ] + +restriction_protection: + enchantments: [ protection ] + notAffectedGroups: [ enchanted_book, armors ] + +restriction_punch: + enchantments: [ punch ] + notAffectedGroups: [ enchanted_book, bow ] + +restriction_quick_charge: + enchantments: [ quick_charge ] + notAffectedGroups: [ enchanted_book, crossbow ] + +restriction_respiration: + enchantments: [ respiration ] + notAffectedGroups: [ enchanted_book, helmets ] + +restriction_riptide: + enchantments: [ riptide ] + notAffectedGroups: [ enchanted_book, trident ] + +restriction_sharpness: + enchantments: [ sharpness ] + notAffectedGroups: [ enchanted_book, melee_weapons ] + +restriction_silk_touch: + enchantments: [ silk_touch ] + notAffectedGroups: [ enchanted_book, tools ] + +restriction_smite: + enchantments: [ smite ] + notAffectedGroups: [ enchanted_book, melee_weapons ] + +restriction_soul_speed: + enchantments: [ soul_speed ] + notAffectedGroups: [ enchanted_book, boots ] + +restriction_sweeping_edge: + enchantments: [ sweeping, 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: [ swift_sneak ] + notAffectedGroups: [ enchanted_book, leggings ] + +restriction_thorns: + enchantments: [ thorns ] + notAffectedGroups: [ enchanted_book, armors ] + +restriction_unbreaking: + enchantments: [ unbreaking ] + notAffectedGroups: [ enchanted_book, can_unbreak ] + +# ---------------------------------------------------- +# Now we have conflicts about enchantment Incompatibility +# We just filtered what item enchantments can be applied +# notAffectedGroups is empty as we don't want anything to not respect theses rules +# maxEnchantmentBeforeConflict is set to 1 to only have 1 on those enchantment available +# ---------------------------------------------------- + +sword_enchant_conflict: + enchantments: + - bane_of_arthropods + - smite + - sharpness + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +protection_enchant_conflict: + enchantments: + - blast_protection + - fire_protection + - projectile_protection + - protection + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +trident_conflict1: + enchantments: + - channeling + - riptide + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +trident_conflict2: + enchantments: + - loyalty + - riptide + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +boot_conflict: + enchantments: + - depth_strider + - frost_walker + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +tool_conflict: + enchantments: + - fortune + - silk_touch + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +bow_conflict: + enchantments: + - mending + - infinity + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +crossbow_conflict: + enchantments: + - multishot + - piercing + notAffectedGroups: [ ] + maxEnchantmentBeforeConflict: 1 + +# ---------------------------------------------------- +# Bellow is for custom conflicts. +# This is also where conflict create from the gui will be placed. +# ---------------------------------------------------- diff --git a/src/main/resources/version/1.18/configs/item_groups.yml b/src/main/resources/version/1.18/configs/item_groups.yml new file mode 100644 index 0000000..ddb547e --- /dev/null +++ b/src/main/resources/version/1.18/configs/item_groups.yml @@ -0,0 +1,201 @@ +# Please note this config use spigot material names. +# It should match minecraft name in most case, maybe every case, but I can't be sure +# In case there an issue with material name, you can found them here: +# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html + +# An empty Exclude group exclude nothing, so it contain everything +everything: + type: exclude + +# An empty include group will include nothing +nothing: + type: include + +# This group is an example of a group including only stone and polished granite +example_include: + type: include + items: + - stone + - polished_granite + +# This group contain everything except polished granite and elements of example_include +example_exclude: + type: exclude + items: + - polished_granite + groups: + - example_include + +# Default configuration should be vanilla enchantment conflict group +# there may have error, if you find one you can fix it ! +# https://minecraft.fandom.com/wiki/Enchanting + +swords: + type: include + items: + - wooden_sword + - stone_sword + - iron_sword + - diamond_sword + - golden_sword + - netherite_sword + +axes: + type: include + items: + - wooden_axe + - stone_axe + - iron_axe + - diamond_axe + - golden_axe + - netherite_axe + +melee_weapons: + type: include + groups: + - swords + - axes + +helmets: + type: include + items: + - leather_helmet + - chainmail_helmet + - iron_helmet + - diamond_helmet + - golden_helmet + - netherite_helmet + - turtle_helmet + +chestplate: + type: include + items: + - leather_chestplate + - chainmail_chestplate + - iron_chestplate + - diamond_chestplate + - golden_chestplate + - netherite_chestplate + +leggings: + type: include + items: + - leather_leggings + - chainmail_leggings + - iron_leggings + - diamond_leggings + - golden_leggings + - netherite_leggings + +boots: + type: include + items: + - leather_boots + - chainmail_boots + - iron_boots + - diamond_boots + - golden_boots + - netherite_boots + +armors: + type: include + groups: + - helmets + - chestplate + - leggings + - boots + +wearable: + type: include + items: + - elytra + - carved_pumpkin + - skeleton_skull + - wither_skeleton_skull + - zombie_head + - player_head + - creeper_head + - dragon_head + groups: + - armors + +tools: + type: include + items: + - wooden_pickaxe + - stone_pickaxe + - iron_pickaxe + - diamond_pickaxe + - golden_pickaxe + - netherite_pickaxe + - wooden_shovel + - stone_shovel + - iron_shovel + - diamond_shovel + - golden_shovel + - netherite_shovel + - wooden_hoe + - stone_hoe + - iron_hoe + - diamond_hoe + - golden_hoe + - netherite_hoe + groups: + - axes + +enchanted_book: + type: include + items: + - enchanted_book + +trident: + type: include + items: + - trident + +bow: + type: include + items: + - bow + +crossbow: + type: include + items: + - crossbow + +fishing_rod: + type: include + items: + - fishing_rod + +shears: + type: include + items: + - shears + +can_unbreak: + type: include + items: + - elytra + - flint_and_steel + - shield + - carrot_on_a_stick + - warped_fungus_on_a_stick + groups: + - melee_weapons + - tools + - armors + - trident + - bow + - crossbow + - fishing_rod + - shears + +can_vanish: + type: include + items: + - compass + groups: + - wearable + - can_unbreak + diff --git a/src/main/resources/version/1.18/configs/unit_repair_item.yml b/src/main/resources/version/1.18/configs/unit_repair_item.yml new file mode 100644 index 0000000..0e96878 --- /dev/null +++ b/src/main/resources/version/1.18/configs/unit_repair_item.yml @@ -0,0 +1,185 @@ +# Unit repair configuration +# +# This configuration is to make custom unit repair +# A unit repair is, for example, a diamond to repair a diamond sword +# In vanilla, a unit repair 25% of object durability +# you can make a custom value here +# +# Item name should NOT combine caps and no caps (example: Stone) + +# Default value if the config is an invalid value (value <= 0 ) +# If value > 1 it will be treated as being = 1 +default_repair_amount: 0.25 + +# You can add custom unit repair +# The example bellow make a shield repaired by 10% by sticks + +#stick: +# shield: 0.10 + + +# Vanilla unit repair group is bellow +diamond: + diamond_helmet: 0.25 + diamond_chestplate: 0.25 + diamond_leggings: 0.25 + diamond_boots: 0.25 + diamond_sword: 0.25 + diamond_pickaxe: 0.25 + diamond_axe: 0.25 + diamond_shovel: 0.25 + diamond_hoe: 0.25 + +netherite_ingot: + netherite_helmet: 0.25 + netherite_chestplate: 0.25 + netherite_leggings: 0.25 + netherite_boots: 0.25 + netherite_sword: 0.25 + netherite_pickaxe: 0.25 + netherite_axe: 0.25 + netherite_shovel: 0.25 + netherite_hoe: 0.25 + +gold_ingot: + golden_helmet: 0.25 + golden_chestplate: 0.25 + golden_leggings: 0.25 + golden_boots: 0.25 + golden_sword: 0.25 + golden_pickaxe: 0.25 + golden_axe: 0.25 + golden_shovel: 0.25 + golden_hoe: 0.25 + +iron_ingot: + iron_helmet: 0.25 + iron_chestplate: 0.25 + iron_leggings: 0.25 + iron_boots: 0.25 + iron_sword: 0.25 + iron_pickaxe: 0.25 + iron_axe: 0.25 + iron_shovel: 0.25 + iron_hoe: 0.25 + +cobblestone: + stone_sword: 0.25 + stone_pickaxe: 0.25 + stone_axe: 0.25 + stone_shovel: 0.25 + stone_hoe: 0.25 + +cobbled_deepslate: + stone_sword: 0.25 + stone_pickaxe: 0.25 + stone_axe: 0.25 + stone_shovel: 0.25 + stone_hoe: 0.25 + +blackstone: + stone_sword: 0.25 + stone_pickaxe: 0.25 + stone_axe: 0.25 + stone_shovel: 0.25 + stone_hoe: 0.25 + +leather: + leather_helmet: 0.25 + leather_chestplate: 0.25 + leather_leggings: 0.25 + leather_boots: 0.25 + +phantom_membrane: + elytra: 0.25 + +scute: + turtle_helmet: 0.25 + +oak_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +spruce_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +birch_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +jungle_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +acacia_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +dark_oak_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +mangrove_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +cherry_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +bamboo_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +crimson_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 + +warped_planks: + wooden_sword: 0.25 + wooden_pickaxe: 0.25 + wooden_axe: 0.25 + wooden_shovel: 0.25 + wooden_hoe: 0.25 + shield: 0.25 diff --git a/src/main/resources/version/1.18/versionList b/src/main/resources/version/1.18/versionList new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/version/1.20/updateList b/src/main/resources/version/1.20/updateList new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/version/1.20/versionUpgrade.yml b/src/main/resources/version/1.20/versionUpgrade.yml new file mode 100644 index 0000000..ffe2f78 --- /dev/null +++ b/src/main/resources/version/1.20/versionUpgrade.yml @@ -0,0 +1,12 @@ +addNewItems: + message: "Add 1.20 items" + addPiglinHead: + type: add_list + config_type: item_group + path: wearable.items + value: piglin_head + addBrush: + type: list_add + config_type: item_group + path: can_unbreak.items + value: brush diff --git a/src/main/resources/version/versionList.txt b/src/main/resources/version/versionList.txt new file mode 100644 index 0000000..81eb52b --- /dev/null +++ b/src/main/resources/version/versionList.txt @@ -0,0 +1,3 @@ +1.18 +1.20 +1.20.5 \ No newline at end of file