diff --git a/.gitignore b/.gitignore index 191597df..e841e9cd 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,9 @@ target target-api *.java~ *.kts~ + +### OpenCode ### + +/AGENTS.md + +opencode.json \ No newline at end of file diff --git a/API/build.gradle.kts b/API/build.gradle.kts index 9c28f817..c4ee9f05 100644 --- a/API/build.gradle.kts +++ b/API/build.gradle.kts @@ -2,6 +2,10 @@ plugins { id("re.alwyn974.groupez.publish") version "1.0.0" } +dependencies{ + implementation("net.kyori:adventure-api:4.25.0") +} + rootProject.extra.properties["sha"]?.let { sha -> version = sha } diff --git a/API/src/main/java/fr/maxlego08/menu/ComponentsManager.java b/API/src/main/java/fr/maxlego08/menu/ComponentsManager.java new file mode 100644 index 00000000..7e49abfa --- /dev/null +++ b/API/src/main/java/fr/maxlego08/menu/ComponentsManager.java @@ -0,0 +1,28 @@ +package fr.maxlego08.menu; + +import fr.maxlego08.menu.api.MenuPlugin; +import fr.maxlego08.menu.api.exceptions.ItemComponentAlreadyRegisterException; +import fr.maxlego08.menu.api.loader.ItemComponentLoader; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +public interface ComponentsManager { + + void initializeDefaultComponents(MenuPlugin plugin); + + /** + * Register a new ItemComponentLoader. + * @param loader The loader to register + * @throws ItemComponentAlreadyRegisterException if a loader with the same name is already registered + **/ + void registerComponent(@NotNull ItemComponentLoader loader) throws ItemComponentAlreadyRegisterException; + + /** + * Get an ItemComponentLoader by its name. + * @param name The name of the loader + * @return An Optional containing the loader if found, or empty if not found + **/ + @NotNull + Optional getLoader(@NotNull String name); +} diff --git a/API/src/main/java/fr/maxlego08/menu/api/ButtonManager.java b/API/src/main/java/fr/maxlego08/menu/api/ButtonManager.java index bb76dda5..cf4d5b7c 100644 --- a/API/src/main/java/fr/maxlego08/menu/api/ButtonManager.java +++ b/API/src/main/java/fr/maxlego08/menu/api/ButtonManager.java @@ -13,6 +13,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.Collection; @@ -43,20 +44,21 @@ public interface ButtonManager { * * @param button The {@link ButtonLoader} instance to unregister. */ - void unregister(ButtonLoader button); + void unregister(@NotNull ButtonLoader button); /** * Unregisters all {@link ButtonLoader} instances linked to a specific plugin. * * @param plugin The plugin whose loaders should be unregistered. */ - void unregisters(Plugin plugin); + void unregisters(@NotNull Plugin plugin); /** * Retrieves all registered {@link ButtonLoader} instances. * * @return A collection containing all registered {@link ButtonLoader} instances. */ + @NotNull Collection getLoaders(); /** @@ -65,7 +67,8 @@ public interface ButtonManager { * @param plugin The plugin whose loaders are to be retrieved. * @return A collection of {@link ButtonLoader} instances or an empty collection if none are found. */ - Collection getLoaders(Plugin plugin); + @NotNull + Collection getLoaders(@NotNull Plugin plugin); /** * Retrieves a {@link ButtonLoader} based on the name of the associated {@link Button}. @@ -73,20 +76,22 @@ public interface ButtonManager { * @param name The name of the {@link ButtonLoader}. * @return An {@link Optional} containing the {@link ButtonLoader}, if found. */ - Optional getLoader(String name); + @NotNull + Optional getLoader(@Nullable String name); /** * Registers a new {@link PermissibleLoader} responsible for permissible creation. * * @param permissibleLoader The {@link PermissibleLoader} instance to register. */ - void registerPermissible(PermissibleLoader permissibleLoader); + void registerPermissible(@NotNull PermissibleLoader permissibleLoader); /** * Retrieves a mapping of permissible keys to their associated {@link PermissibleLoader} instances. * * @return A map linking permissible keys to their corresponding {@link PermissibleLoader} instances. */ + @NotNull Map getPermissibles(); /** @@ -95,14 +100,15 @@ public interface ButtonManager { * @param key The key identifying the permissible. * @return An {@link Optional} containing the {@link PermissibleLoader}, if found. */ - Optional getPermission(String key); + @NotNull + Optional getPermission(@NotNull String key); /** * Registers a new {@link ActionLoader} responsible for action creation. * * @param actionLoader The {@link ActionLoader} instance to register. */ - void registerAction(ActionLoader actionLoader); + void registerAction(@NotNull ActionLoader actionLoader); /** * Retrieves an {@link Optional} {@link ActionLoader} based on a specific action key. @@ -110,7 +116,8 @@ public interface ButtonManager { * @param key The key identifying the action. * @return An {@link Optional} containing the {@link ActionLoader}, if found. */ - Optional getActionLoader(String key); + @NotNull + Optional getActionLoader(@NotNull String key); /** * Converts a list of map elements from a configuration file into a list of {@link Permissible} objects. @@ -120,7 +127,8 @@ public interface ButtonManager { * @param file The configuration file in use. * @return A list of {@link Permissible} objects derived from the configuration. */ - List loadPermissible(List> elements, String path, File file); + @NotNull + List<@NotNull Permissible> loadPermissible(@NotNull List<@NotNull Map> elements,@NotNull String path,@NotNull File file); /** * Converts a list of map elements from a configuration file into a list of {@link Permissible} objects. @@ -130,7 +138,8 @@ public interface ButtonManager { * @param file The file where the configuration is located. * @return A list of {@link Permissible} objects derived from the configuration. */ - List loadPermissible(YamlConfiguration configuration, String path, File file); + @NotNull + List<@NotNull Permissible> loadPermissible(@NotNull YamlConfiguration configuration,@NotNull String path,@NotNull File file); /** * Converts a list of map elements from a configuration file into a list of {@link Action} objects. @@ -142,9 +151,11 @@ public interface ButtonManager { * @param file The configuration file in use. * @return A list of {@link Action} objects derived from the configuration. */ - List loadActions(List> elements, String path, File file); + @NotNull + List<@NotNull Action> loadActions(@NotNull List<@NotNull Map> elements,@NotNull String path,@NotNull File file); - List loadActions(List> elements, String path, File file, @NotNull List defaultActions, boolean useSuccess, boolean stopOnEmpty); + @NotNull + List<@NotNull Action> loadActions(@NotNull List> elements,@NotNull String path,@NotNull File file, @NotNull List<@NotNull ActionPattern> defaultActions, boolean useSuccess, boolean stopOnEmpty); /** * Converts a list of map elements from a configuration file into a list of {@link Action} objects. @@ -156,13 +167,17 @@ public interface ButtonManager { * @param file The configuration file in use. * @return A list of {@link Action} objects derived from the configuration. */ - List loadActions(YamlConfiguration configuration, String path, File file); + @NotNull + List<@NotNull Action> loadActions(@NotNull YamlConfiguration configuration,@NotNull String path,@NotNull File file); - List loadActions(YamlConfiguration configuration, String path, File file, @NotNull List defaultActions, boolean useSuccess, boolean stopOnEmpty); + @NotNull + List<@NotNull Action> loadActions(@NotNull YamlConfiguration configuration,@NotNull String path,@NotNull File file, @NotNull List<@NotNull ActionPattern> defaultActions, boolean useSuccess, boolean stopOnEmpty); - List loadRequirements(YamlConfiguration configuration, String path, File file) throws InventoryException; + @NotNull + List loadRequirements(@Nullable YamlConfiguration configuration,@NotNull String path,@NotNull File file) throws InventoryException; - Requirement loadRequirement(YamlConfiguration configuration, String path, File file) throws InventoryException; + @NotNull + Requirement loadRequirement(@NotNull YamlConfiguration configuration,@NotNull String path,@NotNull File file) throws InventoryException; /** * Retrieves a list of all empty actions from the given configuration elements. @@ -173,7 +188,8 @@ public interface ButtonManager { * @param elements The list of configuration items detailing an action's entire configuration. * @return A list of all empty actions from the given configuration elements. */ - List getEmptyActions(List> elements); + @NotNull + List getEmptyActions(@NotNull List> elements); /** * Retrieves a list of all empty permissibles from the given configuration elements. @@ -184,7 +200,8 @@ public interface ButtonManager { * @param elements The list of configuration items detailing a permissible's entire configuration. * @return A list of all empty permissibles from the given configuration elements. */ - List getEmptyPermissible(List> elements); + @NotNull + List getEmptyPermissible(@NotNull List> elements); /** * Retrieves a {@link Loader} for a {@link Button} object based on the given parameters. @@ -192,10 +209,11 @@ public interface ButtonManager { *

This method is used to create a loader for a button object, given the plugin instance, file, size, and matrix.

* * @param menuPlugin The plugin instance associated with the button loader. - * @param file The file from which the button configuration is loaded. - * @param size The size of the button. - * @param matrix The matrix containing the button's configuration data. + * @param file The file from which the button configuration is loaded. + * @param size The size of the button. + * @param matrix The matrix containing the button's configuration data. * @return A {@link Loader} for a {@link Button} object based on the given parameters. */ - Loader