From cea6d5147062a97d83a0ee4d2f8570a8ca2d82da Mon Sep 17 00:00:00 2001 From: alexcrea Date: Wed, 9 Jul 2025 23:04:07 +0200 Subject: [PATCH] add flags for the api --- .../cuanvil/api/AnvilRecipeBuilder.java | 68 ++++++++++++++ .../xyz/alexcrea/cuanvil/api/ConflictAPI.java | 30 ++++++ .../alexcrea/cuanvil/api/ConflictBuilder.java | 93 +++++++++++++++++++ .../cuanvil/api/CustomAnvilRecipeApi.java | 19 ++++ .../alexcrea/cuanvil/api/EnchantmentApi.java | 49 ++++++++++ .../cuanvil/api/MaterialGroupApi.java | 30 ++++++ .../alexcrea/cuanvil/api/UnitRepairApi.java | 72 +++++++++----- .../alexcrea/cuanvil/api/data/CAApiFlags.java | 42 +++++++++ .../cuanvil/api/event/CAConfigReadyEvent.java | 3 + .../event/CAEnchantRegistryReadyEvent.java | 3 + .../listener/CAClickResultBypassEvent.java | 3 + .../listener/CAEarlyPreAnvilBypassEvent.java | 5 + .../event/listener/CAPreAnvilBypassEvent.java | 3 + .../listener/CATreatAnvilResultEvent.java | 20 ++++ 14 files changed, 417 insertions(+), 23 deletions(-) create mode 100644 src/main/java/xyz/alexcrea/cuanvil/api/data/CAApiFlags.java diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java b/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java index 4292fa0..ee7e50c 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java @@ -7,6 +7,9 @@ import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe; /** * A Builder for custom craft using anvil. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} */ @SuppressWarnings("unused") public class AnvilRecipeBuilder { @@ -27,6 +30,9 @@ public class AnvilRecipeBuilder { * Instantiates a new Anvil recipe builder. * exact count default to true. * xp level and linear cost per craft default to 0. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param name The recipe name */ @@ -45,6 +51,9 @@ public class AnvilRecipeBuilder { /** * Gets the recipe name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return This recipe builder instance. */ @@ -55,6 +64,9 @@ public class AnvilRecipeBuilder { /** * Sets the recipe name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param name The recipe name * @return This recipe builder instance. @@ -69,6 +81,9 @@ public class AnvilRecipeBuilder { *

* Exact count mean the recipe can only be crafted 1 by 1. * If set to false, then it will craft as much as possible in 1 go and will keep unused material onto the anvil inventory. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return If the recipe is exact count. */ @@ -81,6 +96,9 @@ public class AnvilRecipeBuilder { *

* Exact count mean the recipe can only be crafted 1 by 1. * If set to false, then it will craft as much as possible in 1 go and will keep unused material onto the anvil inventory. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param exactCount If the recipe is exact count * @return This recipe builder instance. @@ -92,6 +110,9 @@ public class AnvilRecipeBuilder { /** * Get the xp level cost per craft. (default 0) + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return The xp level cost per craft * @deprecated use {@link #getLevelCostPerCraft() getLevelCostPerCraft} instead @@ -103,6 +124,9 @@ public class AnvilRecipeBuilder { /** * Sets the xp level cost per craft. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param xpCostPerCraft The xp level cost per craft * @return This recipe builder instance. @@ -115,6 +139,9 @@ public class AnvilRecipeBuilder { /** * Get the xp level cost per craft. (default 0) + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return The xp level cost per craft */ @@ -124,6 +151,9 @@ public class AnvilRecipeBuilder { /** * Sets the xp level cost per craft. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param levelCostPerCraft The xp level cost per craft * @return This recipe builder instance. @@ -135,6 +165,9 @@ public class AnvilRecipeBuilder { /** * Get the linear xp cost (not xp level cost) per craft. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return The xp level cost per craft */ @@ -144,6 +177,9 @@ public class AnvilRecipeBuilder { /** * Sets the linear xp cost (not xp level cost) per craft. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param linearXpCostPerCraft The linear xp cost per craft * @return This recipe builder instance. @@ -160,6 +196,10 @@ public class AnvilRecipeBuilder { * If true will require the level that has at least the specified level of xp then on click remove only the necessary xp *

* linear xp cost are applied after level cost + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} + * * @return if we should remove the exact amount of linear xp */ public boolean isRemoveExactLinearXp() { @@ -174,6 +214,10 @@ public class AnvilRecipeBuilder { *

* linear xp cost are applied after level cost * @param removeExactLinearXp if we should remove the exact amount of linear xp + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} + * * @return This recipe builder instance. */ public AnvilRecipeBuilder setRemoveExactLinearXp(boolean removeExactLinearXp) { @@ -184,6 +228,9 @@ public class AnvilRecipeBuilder { /** * Get the left item of the recipe. * If null (default) then the recipe will not be able to be registered. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return The left item */ @@ -195,6 +242,9 @@ public class AnvilRecipeBuilder { /** * Set the left item. * If null (default) then the recipe will not be able to be registered. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param leftItem the left item * @return This recipe builder instance. @@ -207,6 +257,9 @@ public class AnvilRecipeBuilder { /** * Get the recipe right item. * null on default new instance. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return The right item */ @@ -218,6 +271,9 @@ public class AnvilRecipeBuilder { /** * Set the recipe right item. * null on default new instance. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param rightItem the right item * @return This recipe builder instance. @@ -230,6 +286,9 @@ public class AnvilRecipeBuilder { /** * Get the recipe result item. * If null (default) then the recipe will not be able to be registered. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return The result item */ @@ -241,6 +300,9 @@ public class AnvilRecipeBuilder { /** * Set the recipe result item. * If null (default) then the recipe will not be able to be registered. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param resultItem The result item * @return This recipe builder instance. @@ -253,6 +315,9 @@ public class AnvilRecipeBuilder { /** * Build the anvil custom recipe. * Should probably use {@link #registerIfAbsent() registerIfAbsent} or {@link ConflictAPI#addConflict(ConflictBuilder) addConflict}. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return A new anvil custom recipe base on this builder. */ @@ -273,6 +338,9 @@ public class AnvilRecipeBuilder { /** * Register this recipe if absent. * Equivalent to {@link ConflictAPI#addConflict(ConflictBuilder)} + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @return True if successful. */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/ConflictAPI.java b/src/main/java/xyz/alexcrea/cuanvil/api/ConflictAPI.java index fe2715e..acf8d01 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/ConflictAPI.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/ConflictAPI.java @@ -15,6 +15,9 @@ import java.util.List; /** * Custom Anvil api for conflict registry. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} */ @SuppressWarnings("unused") public class ConflictAPI { @@ -29,6 +32,9 @@ public class ConflictAPI { * Write and add a conflict. * Will not write the conflict if it already exists. * Will not be successful if the conflict is empty. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param builder The conflict builder to be based on * @return True if successful. @@ -41,6 +47,9 @@ public class ConflictAPI { * Write and add a conflict. * Will not write the conflict if it already exists. * Will not be successful if the conflict is empty. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param builder The conflict builder to be based on * @param overrideDeleted If we should write even if the conflict was previously deleted. @@ -70,6 +79,9 @@ public class ConflictAPI { * Write a conflict to the config file and plan an update of conflicts. *

* You may want to use {@link #addConflict(ConflictBuilder)} instead as it is more performance in most case as this function will reload every conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param builder the builder * @return true if was written successfully. @@ -82,6 +94,9 @@ public class ConflictAPI { * Write a conflict to the config file. *

* You should use {@link #addConflict(ConflictBuilder)} or {@link #writeConflict(ConflictBuilder)} instead + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param builder The builder * @param updatePlanned If we should plan a global update for conflicts @@ -116,6 +131,9 @@ public class ConflictAPI { /** * Extract every enchantment names from a builder. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param builder The builder storing the enchantments * @return Builder's stored enchantment. @@ -132,6 +150,9 @@ public class ConflictAPI { /** * Remove a conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param conflict The conflict to remove * @return True if successful. @@ -153,6 +174,9 @@ public class ConflictAPI { /** * Prepare a task to save conflict configuration. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} */ private static void prepareSaveTask() { if (saveChangeTask != null) return; @@ -165,6 +189,9 @@ public class ConflictAPI { /** * Prepare a task to reload every conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} */ private static void prepareUpdateTask() { if (reloadChangeTask != null) return; @@ -184,6 +211,9 @@ public class ConflictAPI { /** * Get every registered conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return An immutable collection of conflict. */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java b/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java index f662140..c77ad39 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java @@ -15,6 +15,9 @@ import java.util.Set; /** * A Builder for material conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} */ @SuppressWarnings("unused") public class ConflictBuilder { @@ -31,6 +34,9 @@ public class ConflictBuilder { /** * Instantiates a new Conflict builder. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param name The conflict name * @param maxBeforeConflict Maximum number of conflicting enchantment before conflict is active @@ -50,6 +56,9 @@ public class ConflictBuilder { /** * Instantiates a new Conflict builder. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param name The conflict name * @param source The conflict source @@ -60,6 +69,9 @@ public class ConflictBuilder { /** * Instantiates a new Conflict builder. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param name The conflict name */ @@ -69,6 +81,9 @@ public class ConflictBuilder { /** * Gets conflict source. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The conflict source. */ @@ -79,6 +94,9 @@ public class ConflictBuilder { /** * Gets conflict source name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The conflict source name. */ @@ -91,6 +109,9 @@ public class ConflictBuilder { /** * Gets conflict name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The conflict name. */ @@ -101,6 +122,9 @@ public class ConflictBuilder { /** * Gets stored conflicting enchantment names. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The stored enchantment names. */ @@ -111,6 +135,9 @@ public class ConflictBuilder { /** * Gets stored conflicting enchantment keys. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The stored enchantment keys. */ @@ -121,6 +148,9 @@ public class ConflictBuilder { /** * Gets stored excluded group names. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The stored group names. */ @@ -136,6 +166,9 @@ public class ConflictBuilder { * That mean new enchantment will not be able to be added to the item and present enchantment will not have its level upgraded. *

* In vanilla. material restriction have this value set to 0 and enchantment conflict set to 1. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return the max number of conflicting enchantment before conflict. 0 by default. */ @@ -145,6 +178,9 @@ public class ConflictBuilder { /** * Sets conflict name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param name The name * @return This conflict builder instance. @@ -161,6 +197,9 @@ public class ConflictBuilder { * That mean new enchantment will not be able to be added to the item and present enchantment will not have its level upgraded. *

* In vanilla. material restriction have this value set to 0 and enchantment conflict set to 1. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param maxBeforeConflict The max before conflict * @return This conflict builder instance. @@ -172,6 +211,9 @@ public class ConflictBuilder { /** * Add a conflicting enchantment by name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param enchantmentName The enchantment name * @return This conflict builder instance. @@ -184,6 +226,9 @@ public class ConflictBuilder { /** * Add a conflicting enchantment by key. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param enchantmentKey The enchantment key * @return This conflict builder instance. @@ -196,6 +241,9 @@ public class ConflictBuilder { /** * Add a conflicting enchantment by instance. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param enchantment The enchantment * @return This conflict builder instance. @@ -208,6 +256,9 @@ public class ConflictBuilder { /** * Remove conflicting enchantment by name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param enchantmentName The enchantment name * @return This conflict builder instance. @@ -220,6 +271,9 @@ public class ConflictBuilder { /** * Remove conflicting enchantment by key. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param enchantmentKey The enchantment key * @return This conflict builder instance. @@ -232,6 +286,9 @@ public class ConflictBuilder { /** * Remove enchantment by instance. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param enchantment The enchantment * @return This conflict builder instance. @@ -251,6 +308,9 @@ public class ConflictBuilder { * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param groupName The group name * @return This conflict builder instance. @@ -271,6 +331,9 @@ public class ConflictBuilder { * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param group The group * @return this conflict builder instance. @@ -290,6 +353,9 @@ public class ConflictBuilder { * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param groupName The group name * @return This conflict builder instance. @@ -310,6 +376,9 @@ public class ConflictBuilder { * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param group The group * @return This conflict builder instance. @@ -321,6 +390,9 @@ public class ConflictBuilder { /** * Copy this conflict builder. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return A copy of this conflict builder. */ @@ -348,6 +420,9 @@ public class ConflictBuilder { /** * Build a new Enchant conflict group by this builder. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return An Enchant conflict group with this builder parameters. */ @@ -362,6 +437,9 @@ public class ConflictBuilder { /** * Register this conflict if not yet registered. * Equivalent to {@link ConflictAPI#addConflict(ConflictBuilder, boolean) ConflictAPI.addConflict(this, true)}} + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return True if successful. */ @@ -372,6 +450,9 @@ public class ConflictBuilder { /** * Register this conflict if not yet registered or deleted. * Equivalent to {@link ConflictAPI#addConflict(ConflictBuilder) ConflictAPI.addConflict(this)} + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return True if successful. */ @@ -381,6 +462,9 @@ public class ConflictBuilder { /** * Append builders stored enchantments into conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param conflict The conflict target */ @@ -401,6 +485,9 @@ public class ConflictBuilder { /** * Append an enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param conflict The conflict target * @param enchantment The enchantment @@ -415,6 +502,9 @@ public class ConflictBuilder { /** * Append a list of enchantments. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @param conflict The conflict target * @param enchantments List of enchantment to add @@ -433,6 +523,9 @@ public class ConflictBuilder { /** * Extract group abstract material group. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1} * * @return The abstract material group from the builder. */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/CustomAnvilRecipeApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/CustomAnvilRecipeApi.java index 8f80aa3..b923888 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/CustomAnvilRecipeApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/CustomAnvilRecipeApi.java @@ -13,6 +13,9 @@ import java.util.List; /** * Custom Anvil api for custom anvil recipes. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} */ @SuppressWarnings("unused") public class CustomAnvilRecipeApi { @@ -24,6 +27,9 @@ public class CustomAnvilRecipeApi { /** * Write and add a custom anvil recipe. * Will not write the recipe if it already exists. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param builder The recipe builder to be based on * @return True if successful. @@ -35,6 +41,9 @@ public class CustomAnvilRecipeApi { /** * Write and add a custom anvil recipe. * Will not write the recipe if it already exists. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param builder The recipe builder to be based on * @param overrideDeleted If we should write even if the recipe was previously deleted. @@ -81,6 +90,9 @@ public class CustomAnvilRecipeApi { // TODO remove by name and/or by builder (as name is keept) (and maybe create a get by name) /** * Remove a custom anvil recipe. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} * * @param recipe The recipe to remove * @return True if successful. @@ -103,6 +115,9 @@ public class CustomAnvilRecipeApi { /** * Prepare a task to save custom recipe configuration. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} */ private static void prepareSaveTask() { if(saveChangeTask != null) return; @@ -115,6 +130,10 @@ public class CustomAnvilRecipeApi { /** * Get every registered recipes. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1} + * * @return An immutable collection of recipes. */ @NotNull diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/EnchantmentApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/EnchantmentApi.java index 76f1ac2..d87bc2a 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/EnchantmentApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/EnchantmentApi.java @@ -23,6 +23,9 @@ import java.util.Map; /** * Custom Anvil api for enchantment registry. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} */ @SuppressWarnings("unused") public class EnchantmentApi { @@ -33,6 +36,9 @@ public class EnchantmentApi { /** * Register an enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param enchantment The enchantment to register * @return True if successful. @@ -56,6 +62,9 @@ public class EnchantmentApi { /** * Register an enchantment by minecraft registered enchantment instance. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param enchantment The enchantment to register * @param defaultRarity The default rarity of the provided enchantment @@ -72,6 +81,9 @@ public class EnchantmentApi { * Register an enchantment by minecraft registered enchantment instance. *

* Please note that this function assume the provided enchantment is registered into minecraft registry. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param enchantment The enchantment to register * @return True if successful. @@ -82,6 +94,9 @@ public class EnchantmentApi { /** * Unregister an enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param enchantment The enchantment to unregister * @return True if successful. @@ -100,6 +115,9 @@ public class EnchantmentApi { /** * Unregister an enchantment by its key. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param key The enchantment key to unregister * @return True if successful. @@ -111,6 +129,9 @@ public class EnchantmentApi { /** * Unregister an enchantment by his bukkit enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param enchantment The enchantment to unregister * @return True if successful. @@ -121,6 +142,9 @@ public class EnchantmentApi { /** * Get by key an enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param key The key used to fetch * @return The custom anvil enchantment of this key. null if not found. @@ -132,6 +156,9 @@ public class EnchantmentApi { /** * Get by name an enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param name The name used to fetch * @return The custom anvil enchantment of this name. null if not found. @@ -145,6 +172,9 @@ public class EnchantmentApi { /** * Get list of enchantment using the provided name. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} * * @param name The name used to fetch * @return List of custom anvil enchantments of this name. May be empty if not found. @@ -155,6 +185,10 @@ public class EnchantmentApi { /** * Get every registered custom anvil enchantments. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} + * @return An immutable map of enchantment key as map key and custom anvil enchantment as value. */ @NotNull @@ -164,6 +198,10 @@ public class EnchantmentApi { /** * Write the default level and rarity configuration of the enchantment. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} + * * @param enchantment The enchantment to write default configuration * @param override If it should override old configuration * @return Return false if override is false and a configuration exist. true otherwise. @@ -205,6 +243,9 @@ public class EnchantmentApi { /** * Prepare a task to save custom recipe configuration. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} */ private static void prepareSaveTask() { if(saveChangeTask != null) return; @@ -217,6 +258,10 @@ public class EnchantmentApi { /** * Add a bulk get operator. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} + * * @param operation An optimised get enchantments operation */ public static void addBulkGet(@NotNull BulkGetEnchantOperation operation){ @@ -225,6 +270,10 @@ public class EnchantmentApi { /** * Add a bulk clean operator. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_REGISTER_V1 ENCHANTMENT_REGISTER_V1} + * * @param operation An optimised clean enchantments operation */ public static void addBulkClean(@NotNull BulkCleanEnchantOperation operation){ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java index 48dd500..7474174 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java @@ -18,6 +18,9 @@ import java.util.*; /** * Custom Anvil api for material group registry. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} */ @SuppressWarnings("unused") public class MaterialGroupApi { @@ -32,6 +35,9 @@ public class MaterialGroupApi { * Write and add a group. * Will not write the group if it already exists. * Will not be successful if the group is empty. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @param group The group to add * @return true if successful. @@ -44,6 +50,9 @@ public class MaterialGroupApi { * Write and add a group. * Will not write the group if it already exists. * Will not be successful if the group is empty. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @param group The group to add * @param overrideDeleted If we should write even if the group was previously deleted. @@ -77,6 +86,9 @@ public class MaterialGroupApi { * Write a material group to the config file and plan an update of groups. *

* You may want to use {@link #addMaterialGroup(AbstractMaterialGroup)} instead as it is more performance in most case as this function will reload every conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @param group the group to write * @return true if was written successfully. @@ -89,6 +101,9 @@ public class MaterialGroupApi { * Write a material group to the config file. *

* You should use {@link #addMaterialGroup(AbstractMaterialGroup)} or {@link #writeMaterialGroup(AbstractMaterialGroup)} instead + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @param group the group to write * @param updatePlanned if we should plan a global update for material groups @@ -175,6 +190,9 @@ public class MaterialGroupApi { * Remove a material group. * Caution ! It will not be removed from depending conflict or other material group at runtime. * For that reason, it is not recommended to use this function. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @param group The recipe to remove * @return True if the group was present. @@ -199,6 +217,9 @@ public class MaterialGroupApi { /** * Prepare a task to reload every conflict. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} */ private static void prepareSaveTask() { if (saveChangeTask != null) return; @@ -211,6 +232,9 @@ public class MaterialGroupApi { /** * Prepare a task to save configuration. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} */ private static void prepareUpdateTask() { if (reloadChangeTask != null) return; @@ -228,6 +252,9 @@ public class MaterialGroupApi { /** * Get by name a group. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @param groupName the group name used to fetch * @return the abstract group of this name. null if not found. @@ -239,6 +266,9 @@ public class MaterialGroupApi { /** * Get every registered material groups. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#MATERIAL_GROUP_V1 MATERIAL_GROUP_V1} * * @return An immutable map of group name as its key and group as mapped value. */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java index bc50c16..14d87bf 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java @@ -18,11 +18,15 @@ import java.util.List; /** * Custom Anvil api for unit repair. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} */ @SuppressWarnings("unused") public class UnitRepairApi { - private UnitRepairApi(){} + private UnitRepairApi() { + } private static Object saveChangeTask = null; @@ -30,31 +34,40 @@ public class UnitRepairApi { * Write and add a custom anvil unit repair recipe. * Will not write the recipe if it already exists or was deleted. * Set the value to minecraft default value (0.25 = 25%) + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} * * @param unit The unit material used to repair the bellow item. * @param repairable The item to be repaired. * @return true if successful. */ - public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable){ + public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable) { return addUnitRepair(unit, repairable, 0.25, false); } /** * Write and add a custom anvil unit repair recipe. * Will not write the recipe if it already exists or was deleted. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} * * @param unit The unit material used to repair the bellow item. * @param repairable The item to be repaired. * @param value The amount to be repaired by every unit. (1% = 0.01) * @return true if successful. */ - public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value){ + public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value) { return addUnitRepair(unit, repairable, value, false); } /** * Write and add a custom anvil unit repair recipe. * Will not write the recipe if it already exists. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} * * @param unit The unit material used to repair the bellow item. * @param repairable The item to be repaired. @@ -62,12 +75,12 @@ public class UnitRepairApi { * @param overrideDeleted If we should write even if the recipe was previously deleted. * @return true if successful. */ - public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value, boolean overrideDeleted){ + public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value, boolean overrideDeleted) { FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); String path = unit.name().toLowerCase() + "." + repairable.name().toLowerCase(); - if(!overrideDeleted && ConfigHolder.UNIT_REPAIR_HOLDER.isDeleted(path)) return false; - if(config.contains(path)) return false; + if (!overrideDeleted && ConfigHolder.UNIT_REPAIR_HOLDER.isDeleted(path)) return false; + if (config.contains(path)) return false; // Set unit repair return setUnitRepair(unit, repairable, value); @@ -76,13 +89,16 @@ public class UnitRepairApi { /** * Write and add a custom anvil unit repair recipe. * Do not check if it previously existed or exist. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} * * @param unit The unit material used to repair the bellow item. * @param repairable The item to be repaired. * @param value The amount to be repaired by every unit. (1% = 0.01) * @return true if successful. */ - public static boolean setUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value){ + public static boolean setUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value) { FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); String repairableName = repairable.name().toLowerCase(); @@ -94,10 +110,10 @@ public class UnitRepairApi { // Add to gui UnitRepairConfigGui repairConfigGui = UnitRepairConfigGui.getCurrentInstance(); - if(repairConfigGui != null) { + if (repairConfigGui != null) { UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored(); - if(elementGui != null) elementGui.updateValueForGeneric(repairableName, true); + if (elementGui != null) elementGui.updateValueForGeneric(repairableName, true); repairConfigGui.updateValueForGeneric(unit, true); } @@ -106,12 +122,15 @@ public class UnitRepairApi { /** * Remove a custom anvil unit repair recipe. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} * * @param unit The unit material used to repair the bellow item. * @param repairable The item used to be repaired. * @return true if successful. */ - public static boolean removeUnitRepair(@NotNull Material unit, @NotNull Material repairable){ + public static boolean removeUnitRepair(@NotNull Material unit, @NotNull Material repairable) { // Delete every possible variation and save to file String unitName = unit.name(); String repairableName = repairable.name(); @@ -124,17 +143,17 @@ public class UnitRepairApi { // Test if it was the last value of this section boolean lastValue = false; - if(config.isConfigurationSection(unitName.toLowerCase())) { + if (config.isConfigurationSection(unitName.toLowerCase())) { ConfigurationSection section = config.getConfigurationSection(unitName.toLowerCase()); - if(section != null && section.getKeys(false).isEmpty()) { + if (section != null && section.getKeys(false).isEmpty()) { lastValue = true; config.set(unitName.toLowerCase(), null); } } else if (config.isConfigurationSection(unitName.toUpperCase())) { ConfigurationSection section = config.getConfigurationSection(unitName.toUpperCase()); - if(section != null && section.getKeys(false).isEmpty()) { + if (section != null && section.getKeys(false).isEmpty()) { lastValue = true; config.set(unitName.toUpperCase(), null); } @@ -148,11 +167,11 @@ public class UnitRepairApi { // Remove from gui UnitRepairConfigGui repairConfigGui = UnitRepairConfigGui.getCurrentInstance(); - if(repairConfigGui != null) { + if (repairConfigGui != null) { UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored(); - if(elementGui != null) elementGui.removeGeneric(repairableName); - if(lastValue){ + if (elementGui != null) elementGui.removeGeneric(repairableName); + if (lastValue) { repairConfigGui.removeGeneric(unit); } } @@ -162,11 +181,14 @@ public class UnitRepairApi { /** * Prepare a task to save custom unit repair recipe configuration. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} */ private static void prepareSaveTask() { - if(saveChangeTask != null) return; + if (saveChangeTask != null) return; - saveChangeTask = DependencyManager.scheduler.scheduleGlobally(CustomAnvil.instance, ()->{ + saveChangeTask = DependencyManager.scheduler.scheduleGlobally(CustomAnvil.instance, () -> { ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(true); saveChangeTask = null; }); @@ -174,6 +196,10 @@ public class UnitRepairApi { /** * Get every unit repair recipes. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#UNIT_REPAIR_V1 UNIT_REPAIR_V1} + * * @return An immutable collection of unit repair recipes. *

* Each element of the provided triple represent a part of the recipe @@ -184,27 +210,27 @@ public class UnitRepairApi { * */ @NotNull - public static List> getUnitRepairs(){ + public static List> getUnitRepairs() { List> mutableList = new ArrayList<>(); FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig(); for (String unitKey : config.getKeys(false)) { // Test if config section exist - if(!config.isConfigurationSection(unitKey)) continue; + if (!config.isConfigurationSection(unitKey)) continue; // Test if unit is a material Material unit = Material.getMaterial(unitKey.toUpperCase()); - if(unit == null) continue; + if (unit == null) continue; // Iterate over reparable items ConfigurationSection section = config.getConfigurationSection(unitKey); for (String repairableKey : section.getKeys(false)) { // Test if value section exist - if(!section.isDouble(repairableKey)) continue; + if (!section.isDouble(repairableKey)) continue; // Test if repairable is valid a material Material repairable = Material.getMaterial(repairableKey.toUpperCase()); - if(repairable == null) continue; + if (repairable == null) continue; // Add the values mutableList.add(new Triple<>(unit, repairable, section.getDouble(repairableKey))); diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/data/CAApiFlags.java b/src/main/java/xyz/alexcrea/cuanvil/api/data/CAApiFlags.java new file mode 100644 index 0000000..c8d6e3a --- /dev/null +++ b/src/main/java/xyz/alexcrea/cuanvil/api/data/CAApiFlags.java @@ -0,0 +1,42 @@ +package xyz.alexcrea.cuanvil.api.data; + +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +public enum CAApiFlags { + + ENCHANTMENT_REGISTER_V1, + ENCHANTMENT_CONFLICT_V1, + CUSTOM_RECIPE_V1, + UNIT_REPAIR_V1, + + MATERIAL_GROUP_V1, + + CONFIG_EVENTS_V1, + LISTENER_EVENTS_V1, + ; + + private static final Set CURRENT_FLAGS = EnumSet.of( + ENCHANTMENT_REGISTER_V1, + ENCHANTMENT_CONFLICT_V1, + CUSTOM_RECIPE_V1, + UNIT_REPAIR_V1, + + MATERIAL_GROUP_V1, + + CONFIG_EVENTS_V1, + LISTENER_EVENTS_V1 + ); + + public static Set getCurrentFlags() { + return Collections.unmodifiableSet(CURRENT_FLAGS); + } + + public boolean hasFlags(CAApiFlags... flag) { + return CURRENT_FLAGS.containsAll(List.of(flag)); + } + + +} diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java index 67d27a8..d2fd770 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java @@ -19,6 +19,9 @@ import org.bukkit.event.HandlerList; * {@link xyz.alexcrea.cuanvil.api.MaterialGroupApi MaterialGroupApi} * and {@link xyz.alexcrea.cuanvil.api.UnitRepairApi UnitRepairApi} * to add/remove/edit configurations + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CONFIG_EVENTS_V1 CONFIG_EVENTS_V1} */ public class CAConfigReadyEvent extends Event { diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/CAEnchantRegistryReadyEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/CAEnchantRegistryReadyEvent.java index 3ffe372..9f4507c 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/CAEnchantRegistryReadyEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/CAEnchantRegistryReadyEvent.java @@ -13,6 +13,9 @@ import org.bukkit.event.HandlerList; * (after configuration loading phase. see {@link CAConfigReadyEvent}) *

* use {@link xyz.alexcrea.cuanvil.api.EnchantmentApi EnchantmentApi} to register and unregister your custom enchantments + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CONFIG_EVENTS_V1 CONFIG_EVENTS_V1} */ public class CAEnchantRegistryReadyEvent extends Event { diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAClickResultBypassEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAClickResultBypassEvent.java index a27c65e..f81f08e 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAClickResultBypassEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAClickResultBypassEvent.java @@ -18,6 +18,9 @@ import org.jetbrains.annotations.NotNull; * for this event to be useful. *

* There is also {@link CATreatAnvilResultEvent} that may be better for some use case. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} */ public class CAClickResultBypassEvent extends Event implements Cancellable { diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAEarlyPreAnvilBypassEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAEarlyPreAnvilBypassEvent.java index 2fbd275..50831b1 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAEarlyPreAnvilBypassEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAEarlyPreAnvilBypassEvent.java @@ -17,6 +17,8 @@ import org.jetbrains.annotations.NotNull; *

* It is also recommended that you read about {@link CAPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent} * as your use case may be more prone to use theses. + *

+ * This is part of {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} */ public class CAEarlyPreAnvilBypassEvent extends Event implements Cancellable { @@ -48,6 +50,9 @@ public class CAEarlyPreAnvilBypassEvent extends Event implements Cancellable { /** * Get the bukkit pre anvil event causing this event + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @return The pre anvil event causing to this event */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAPreAnvilBypassEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAPreAnvilBypassEvent.java index 18334e3..521e7b8 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAPreAnvilBypassEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CAPreAnvilBypassEvent.java @@ -20,6 +20,9 @@ import org.jetbrains.annotations.NotNull; *

* It is also recommended that you read about {@link CAEarlyPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent} * as your use case may be more prone to use theses. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} */ public class CAPreAnvilBypassEvent extends Event implements Cancellable { diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CATreatAnvilResultEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CATreatAnvilResultEvent.java index 1675d1a..dce0727 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CATreatAnvilResultEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/listener/CATreatAnvilResultEvent.java @@ -17,6 +17,8 @@ import xyz.alexcrea.cuanvil.util.AnvilUseType; * and {@link CAEarlyPreAnvilBypassEvent} for your use case *

* A null result will cancel this pre anvil event + *

+ * This is part of {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} */ @SuppressWarnings("unused") public class CATreatAnvilResultEvent extends Event { @@ -51,6 +53,9 @@ public class CATreatAnvilResultEvent extends Event { /** * Get the bukkit inventory click event causing to this event. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @return The click event causing to this event. */ @@ -60,6 +65,9 @@ public class CATreatAnvilResultEvent extends Event { /** * Get the type of use source of the result. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @return The craft use type. */ @@ -71,6 +79,9 @@ public class CATreatAnvilResultEvent extends Event { * Get the current result *

* note that it will not be null unless another listener previously set it to null. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @return The current result. */ @@ -82,6 +93,9 @@ public class CATreatAnvilResultEvent extends Event { * Set the current result *

* note that a null result will cancel this anvil use. + *

+ * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @param result The new result */ @@ -102,6 +116,9 @@ public class CATreatAnvilResultEvent extends Event { *

  • Item merge
  • *
  • Item rename
  • * + *

    + * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @return The current cost. */ @@ -122,6 +139,9 @@ public class CATreatAnvilResultEvent extends Event { *

  • Item merge
  • *
  • Item rename
  • * + *

    + * This is part of + * {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1} * * @param levelCost The new cost. */