add flags for the api

This commit is contained in:
alexcrea 2025-07-09 23:04:07 +02:00
parent 7ee6ab0376
commit cea6d51470
Signed by: alexcrea
GPG key ID: E346CD16413450E3
14 changed files with 417 additions and 23 deletions

View file

@ -7,6 +7,9 @@ import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe;
/**
* A Builder for custom craft using anvil.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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 {
* <p>
* 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.
* <p>
* 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 {
* <p>
* 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.
* <p>
* 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)
* <p>
* 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.
* <p>
* 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)
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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
* <p>
* linear xp cost are applied after level cost
* <p>
* 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 {
* <p>
* linear xp cost are applied after level cost
* @param removeExactLinearXp if we should remove the exact amount of linear xp
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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}.
* <p>
* 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)}
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1}
*
* @return True if successful.
*/

View file

@ -15,6 +15,9 @@ import java.util.List;
/**
* Custom Anvil api for conflict registry.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* You may want to use {@link #addConflict(ConflictBuilder)} instead as it is more performance in most case as this function will reload every conflict.
* <p>
* 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.
* <p>
* You should use {@link #addConflict(ConflictBuilder)} or {@link #writeConflict(ConflictBuilder)} instead
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#ENCHANTMENT_CONFLICT_V1 ENCHANTMENT_CONFLICT_V1}
*
* @return An immutable collection of conflict.
*/

View file

@ -15,6 +15,9 @@ import java.util.Set;
/**
* A Builder for material conflict.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* In vanilla. material restriction have this value set to 0 and enchantment conflict set to 1.
* <p>
* 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.
* <p>
* 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.
* <p>
* In vanilla. material restriction have this value set to 0 and enchantment conflict set to 1.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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)}}
* <p>
* 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)}
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
*/

View file

@ -13,6 +13,9 @@ import java.util.List;
/**
* Custom Anvil api for custom anvil recipes.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CUSTOM_RECIPE_V1 CUSTOM_RECIPE_V1}
*
* @return An immutable collection of recipes.
*/
@NotNull

View file

@ -23,6 +23,9 @@ import java.util.Map;
/**
* Custom Anvil api for enchantment registry.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* Please note that this function assume the provided enchantment is registered into minecraft registry.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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){

View file

@ -18,6 +18,9 @@ import java.util.*;
/**
* Custom Anvil api for material group registry.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* You may want to use {@link #addMaterialGroup(AbstractMaterialGroup)} instead as it is more performance in most case as this function will reload every conflict.
* <p>
* 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.
* <p>
* You should use {@link #addMaterialGroup(AbstractMaterialGroup)} or {@link #writeMaterialGroup(AbstractMaterialGroup)} instead
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
*/

View file

@ -18,11 +18,15 @@ import java.util.List;
/**
* Custom Anvil api for unit repair.
* <p>
* 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%)
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
* <p>
* Each element of the provided triple represent a part of the recipe
@ -184,27 +210,27 @@ public class UnitRepairApi {
* </ul>
*/
@NotNull
public static List<Triple<Material, Material, Double>> getUnitRepairs(){
public static List<Triple<Material, Material, Double>> getUnitRepairs() {
List<Triple<Material, Material, Double>> 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)));

View file

@ -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<CAApiFlags> 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<CAApiFlags> getCurrentFlags() {
return Collections.unmodifiableSet(CURRENT_FLAGS);
}
public boolean hasFlags(CAApiFlags... flag) {
return CURRENT_FLAGS.containsAll(List.of(flag));
}
}

View file

@ -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
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CONFIG_EVENTS_V1 CONFIG_EVENTS_V1}
*/
public class CAConfigReadyEvent extends Event {

View file

@ -13,6 +13,9 @@ import org.bukkit.event.HandlerList;
* (after configuration loading phase. see {@link CAConfigReadyEvent})
* <p>
* use {@link xyz.alexcrea.cuanvil.api.EnchantmentApi EnchantmentApi} to register and unregister your custom enchantments
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#CONFIG_EVENTS_V1 CONFIG_EVENTS_V1}
*/
public class CAEnchantRegistryReadyEvent extends Event {

View file

@ -18,6 +18,9 @@ import org.jetbrains.annotations.NotNull;
* for this event to be useful.
* <p>
* There is also {@link CATreatAnvilResultEvent} that may be better for some use case.
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1}
*/
public class CAClickResultBypassEvent extends Event implements Cancellable {

View file

@ -17,6 +17,8 @@ import org.jetbrains.annotations.NotNull;
* <p>
* It is also recommended that you read about {@link CAPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent}
* as your use case may be more prone to use theses.
* <p>
* 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
* <p>
* 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
*/

View file

@ -20,6 +20,9 @@ import org.jetbrains.annotations.NotNull;
* <p>
* It is also recommended that you read about {@link CAEarlyPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent}
* as your use case may be more prone to use theses.
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1}
*/
public class CAPreAnvilBypassEvent extends Event implements Cancellable {

View file

@ -17,6 +17,8 @@ import xyz.alexcrea.cuanvil.util.AnvilUseType;
* and {@link CAEarlyPreAnvilBypassEvent} for your use case
* <p>
* A null result will cancel this pre anvil event
* <p>
* 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.
* <p>
* 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.
* <p>
* 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
* <p>
* note that it will not be null unless another listener previously set it to null.
* <p>
* 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
* <p>
* note that a null result will cancel this anvil use.
* <p>
* 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 {
* <li>Item merge</li>
* <li>Item rename</li>
* </ul>
* <p>
* 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 {
* <li>Item merge</li>
* <li>Item rename</li>
* </ul>
* <p>
* This is part of
* {@link xyz.alexcrea.cuanvil.api.data.CAApiFlags#LISTENER_EVENTS_V1 LISTENER_EVENTS_V1}
*
* @param levelCost The new cost.
*/