- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.action.Action;
-import net.momirealms.customfishing.api.mechanic.action.ActionFactory;
-import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
-import org.bukkit.configuration.ConfigurationSection;
-
-import java.util.HashMap;
-
-public interface ActionManager {
-
- /**
- * Registers an ActionFactory for a specific action type.
- * This method allows you to associate an ActionFactory with a custom action type.
- *
- * @param type The custom action type to register.
- * @param actionFactory The ActionFactory responsible for creating actions of the specified type.
- * @return True if the registration was successful (the action type was not already registered), false otherwise.
- */
- boolean registerAction(String type, ActionFactory actionFactory);
-
- /**
- * Unregisters an ActionFactory for a specific action type.
- * This method allows you to remove the association between an action type and its ActionFactory.
- *
- * @param type The custom action type to unregister.
- * @return True if the action type was successfully unregistered, false if it was not found.
- */
- boolean unregisterAction(String type);
-
- /**
- * Retrieves an Action object based on the configuration provided in a ConfigurationSection.
- * This method reads the type of action from the section, obtains the corresponding ActionFactory,
- * and builds an Action object using the specified values and chance.
- *
- * events:
- * success:
- * action_1: <- section
- * ...
- *
- * @param section The ConfigurationSection containing the action configuration.
- * @return An Action object created based on the configuration, or an EmptyAction instance if the action type is invalid.
- */
- Action getAction(ConfigurationSection section);
-
- /**
- * Retrieves a mapping of ActionTriggers to arrays of Actions from a ConfigurationSection.
- * This method iterates through the provided ConfigurationSection to extract action triggers
- * and their associated arrays of Actions.
- *
- * events: <- section
- * success:
- * action_1:
- * ...
- *
- * @param section The ConfigurationSection containing action mappings.
- * @return A HashMap where keys are ActionTriggers and values are arrays of Action objects.
- */
- HashMap getActionMap(ConfigurationSection section);
-
- /**
- * Retrieves an array of Action objects from a ConfigurationSection.
- * This method iterates through the provided ConfigurationSection to extract Action configurations
- * and build an array of Action objects.
- *
- * events:
- * success: <- section
- * action_1:
- * ...
- *
- * @param section The ConfigurationSection containing action configurations.
- * @return An array of Action objects created based on the configurations in the section.
- */
- Action[] getActions(ConfigurationSection section);
-
- /**
- * Retrieves an ActionFactory associated with a specific action type.
- *
- * @param type The action type for which to retrieve the ActionFactory.
- * @return The ActionFactory associated with the specified action type, or null if not found.
- */
- ActionFactory getActionFactory(String type);
-
- /**
- * Retrieves a mapping of success times to corresponding arrays of actions from a ConfigurationSection.
- *
- * events:
- * success-times: <- section
- * 1:
- * action_1:
- * ...
- *
- * @param section The ConfigurationSection containing success times actions.
- * @return A HashMap where success times associated with actions.
- */
- HashMap getTimesActionMap(ConfigurationSection section);
-
- /**
- * Triggers a list of actions with the given condition.
- * If the list of actions is not null, each action in the list is triggered.
- *
- * @param actions The list of actions to trigger.
- * @param condition The condition associated with the actions.
- */
- static void triggerActions(Condition condition, Action... actions) {
- if (actions != null)
- for (Action action : actions)
- action.trigger(condition);
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/AdventureManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/AdventureManager.java
deleted file mode 100644
index 1f7c9c0b..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/AdventureManager.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.kyori.adventure.key.Key;
-import net.kyori.adventure.sound.Sound;
-import net.kyori.adventure.text.Component;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-public interface AdventureManager {
-
- /**
- * Get component from text
- * @param text text
- * @return component
- */
- Component getComponentFromMiniMessage(String text);
-
- /**
- * Send a message to a command sender
- * @param sender sender
- * @param msg message
- */
- void sendMessage(CommandSender sender, String msg);
-
- /**
- * Send a message with prefix
- *
- * @param sender command sender
- * @param s message
- */
- void sendMessageWithPrefix(CommandSender sender, String s);
-
- /**
- * Send a message to console
- * @param msg message
- */
- void sendConsoleMessage(String msg);
-
- /**
- * Send a message to a player
- * @param player player
- * @param msg message
- */
- void sendPlayerMessage(Player player, String msg);
-
- /**
- * Send a title to a player
- * @param player player
- * @param title title
- * @param subtitle subtitle
- * @param in in (ms)
- * @param duration duration (ms)
- * @param out out (ms)
- */
- void sendTitle(Player player, String title, String subtitle, int in, int duration, int out);
-
- /**
- * Send a title to a player
- * @param player player
- * @param title title
- * @param subtitle subtitle
- * @param in in (ms)
- * @param duration duration (ms)
- * @param out out (ms)
- */
- void sendTitle(Player player, Component title, Component subtitle, int in, int duration, int out);
-
- /**
- * Send actionbar
- * @param player player
- * @param msg msg
- */
- void sendActionbar(Player player, String msg);
-
- /**
- * Play a sound to a player
- * @param player player
- * @param source sound source
- * @param key sound key
- * @param volume volume
- * @param pitch pitch
- */
- void sendSound(Player player, Sound.Source source, Key key, float volume, float pitch);
-
- void sendSound(Player player, Sound sound);
-
- /**
- * Replace legacy color codes to MiniMessage format
- * @param legacy legacy text
- * @return MiniMessage format text
- */
- String legacyToMiniMessage(String legacy);
-
- /**
- * if a char is legacy color code
- * @param c char
- * @return is legacy color
- */
- @SuppressWarnings("BooleanMethodIsAlwaysInverted")
- boolean isColorCode(char c);
-
- /**
- * Get legacy format text
- * @param component component
- * @return legacy format text
- */
- String componentToLegacy(Component component);
-
- /**
- * Get json
- * @param component component
- * @return json
- */
- String componentToJson(Component component);
-
- /**
- * Get paper component
- * @param component shaded component
- * @return paper component
- */
- Object shadedComponentToOriginalComponent(Component component);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/BagManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/BagManager.java
deleted file mode 100644
index f83c36d2..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/BagManager.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.data.user.OfflineUser;
-import net.momirealms.customfishing.api.mechanic.action.Action;
-import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import java.util.List;
-import java.util.UUID;
-
-public interface BagManager {
-
- /**
- * Is bag enabled
- *
- * @return enabled or not
- */
- boolean isEnabled();
-
- /**
- * Retrieves the online bag inventory associated with a player's UUID.
- *
- * @param uuid The UUID of the player for whom the bag inventory is retrieved.
- * @return The online bag inventory if the player is online, or null if not found.
- */
- Inventory getOnlineBagInventory(UUID uuid);
-
- /**
- * Get the rows of a player's fishing bag
- *
- * @param player player who owns the bag
- * @return rows
- */
- int getBagInventoryRows(Player player);
-
- /**
- * Initiates the process of editing the bag inventory of an offline player by an admin.
- *
- * @param admin The admin player performing the edit.
- * @param userData The OfflineUser data of the player whose bag is being edited.
- */
- void editOfflinePlayerBag(Player admin, OfflineUser userData);
-
- /**
- * Get the actions to perform when loot is automatically collected
- *
- * @return actions
- */
- Action[] getCollectLootActions();
-
- /**
- * Get the actions to perform when bag is full
- *
- * @return actions
- */
- Action[] getBagFullActions();
-
- /**
- * If bag can store fishing loots
- *
- * @return can store or not
- */
- boolean doesBagStoreLoots();
-
- /**
- * Get the fishing bag's title
- *
- * @return title
- */
- String getBagTitle();
-
- /**
- * Get a list of allowed items in bag
- *
- * @return whitelisted items
- */
- List getBagWhiteListItems();
-
- /**
- * Get the requirements for automatically collecting loots
- *
- * @return requirements
- */
- Requirement[] getCollectRequirements();
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/BlockManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/BlockManager.java
deleted file mode 100644
index baa69366..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/BlockManager.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.block.BlockDataModifierBuilder;
-import net.momirealms.customfishing.api.mechanic.block.BlockLibrary;
-import net.momirealms.customfishing.api.mechanic.block.BlockStateModifierBuilder;
-import net.momirealms.customfishing.api.mechanic.loot.Loot;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-public interface BlockManager {
-
- /**
- * Registers a BlockLibrary instance.
- * This method associates a BlockLibrary with its unique identification and adds it to the registry.
- *
- * @param blockLibrary The BlockLibrary instance to register.
- * @return True if the registration was successful (the identification is not already registered), false otherwise.
- */
- boolean registerBlockLibrary(BlockLibrary blockLibrary);
-
- /**
- * Unregisters a BlockLibrary instance by its identification.
- * This method removes a BlockLibrary from the registry based on its unique identification.
- *
- * @param identification The unique identification of the BlockLibrary to unregister.
- * @return True if the BlockLibrary was successfully unregistered, false if it was not found.
- */
- boolean unregisterBlockLibrary(String identification);
-
- /**
- * Registers a BlockDataModifierBuilder for a specific type.
- * This method associates a BlockDataModifierBuilder with its type and adds it to the registry.
- *
- * @param type The type of the BlockDataModifierBuilder to register.
- * @param builder The BlockDataModifierBuilder instance to register.
- * @return True if the registration was successful (the type is not already registered), false otherwise.
- */
- boolean registerBlockDataModifierBuilder(String type, BlockDataModifierBuilder builder);
-
- /**
- * Registers a BlockStateModifierBuilder for a specific type.
- * This method associates a BlockStateModifierBuilder with its type and adds it to the registry.
- *
- * @param type The type of the BlockStateModifierBuilder to register.
- * @param builder The BlockStateModifierBuilder instance to register.
- * @return True if the registration was successful (the type is not already registered), false otherwise.
- */
- boolean registerBlockStateModifierBuilder(String type, BlockStateModifierBuilder builder);
-
- /**
- * Unregisters a BlockDataModifierBuilder with the specified type.
- *
- * @param type The type of the BlockDataModifierBuilder to unregister.
- * @return True if the BlockDataModifierBuilder was successfully unregistered, false otherwise.
- */
- boolean unregisterBlockDataModifierBuilder(String type);
-
- /**
- * Unregisters a BlockStateModifierBuilder with the specified type.
- *
- * @param type The type of the BlockStateModifierBuilder to unregister.
- * @return True if the BlockStateModifierBuilder was successfully unregistered, false otherwise.
- */
- boolean unregisterBlockStateModifierBuilder(String type);
-
- /**
- * Summons a falling block at a specified location based on the provided loot.
- * This method spawns a falling block at the given hookLocation with specific properties determined by the loot.
- *
- * @param player The player who triggered the action.
- * @param hookLocation The location where the hook is positioned.
- * @param playerLocation The location of the player.
- * @param loot The loot to be associated with the summoned block.
- */
- void summonBlock(Player player, Location hookLocation, Location playerLocation, Loot loot);
-
- /**
- * Retrieves the block ID associated with a given Block instance using block detection order.
- * This method iterates through the configured block detection order to find the block's ID
- * by checking different BlockLibrary instances in the specified order.
- *
- * @param block The Block instance for which to retrieve the block ID.
- * @return The block ID
- */
- @NotNull String getAnyPluginBlockID(Block block);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/CompetitionManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/CompetitionManager.java
deleted file mode 100644
index d78ade4a..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/CompetitionManager.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.competition.CompetitionConfig;
-import net.momirealms.customfishing.api.mechanic.competition.CompetitionGoal;
-import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Set;
-
-public interface CompetitionManager {
-
- /**
- * Retrieves a set of all competition names.
- *
- * @return A set of competition names.
- */
- @NotNull Set getAllCompetitionKeys();
-
- /**
- * Retrieves the localization key for a given competition goal.
- *
- * @param goal The competition goal to retrieve the localization key for.
- * @return The localization key for the specified competition goal.
- */
- @NotNull String getCompetitionGoalLocale(CompetitionGoal goal);
-
- /**
- * Starts a competition with the specified name, allowing for the option to force start it or apply it to the entire server.
- *
- * @param competition The name of the competition to start.
- * @param force Whether to force start the competition even if amount of the online players is lower than the requirement
- * @param serverGroup Whether to apply the competition to the servers that connected to Redis.
- * @return {@code true} if the competition was started successfully, {@code false} otherwise.
- */
- boolean startCompetition(String competition, boolean force, @Nullable String serverGroup);
-
- /**
- * Gets the ongoing fishing competition, if one is currently in progress.
- *
- * @return The ongoing fishing competition, or null if there is none.
- */
- @Nullable FishingCompetition getOnGoingCompetition();
-
- /**
- * Starts a competition using the specified configuration.
- *
- * @param config The configuration of the competition to start.
- * @param force Whether to force start the competition even if amount of the online players is lower than the requirement
- * @param serverGroup Whether the competition should start across all servers that connected to Redis
- * @return True if the competition was started successfully, false otherwise.
- */
- boolean startCompetition(CompetitionConfig config, boolean force, @Nullable String serverGroup);
-
- /**
- * Gets the number of seconds until the next competition.
- *
- * @return The number of seconds until the next competition.
- */
- int getNextCompetitionSeconds();
-
- /**
- * Retrieves the configuration for a competition based on its key.
- *
- * @param key The key of the competition configuration to retrieve.
- * @return The {@link CompetitionConfig} for the specified key, or {@code null} if no configuration exists with that key.
- */
- @Nullable CompetitionConfig getConfig(String key);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/EffectManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/EffectManager.java
deleted file mode 100644
index caccbfd4..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/EffectManager.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.common.Key;
-import net.momirealms.customfishing.api.mechanic.effect.BaseEffect;
-import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
-import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
-import net.momirealms.customfishing.api.mechanic.effect.FishingEffect;
-import org.bukkit.configuration.ConfigurationSection;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public interface EffectManager {
-
- /**
- * Registers an EffectCarrier with a unique Key.
- *
- * @param key The unique Key associated with the EffectCarrier.
- * @param effect The EffectCarrier to be registered.
- * @return True if the registration was successful, false if the Key already exists.
- */
- boolean registerEffectCarrier(Key key, EffectCarrier effect);
-
- /**
- * Unregisters an EffectCarrier associated with the specified Key.
- *
- * @param key The unique Key of the EffectCarrier to unregister.
- * @return True if the EffectCarrier was successfully unregistered, false if the Key does not exist.
- */
- boolean unregisterEffectCarrier(Key key);
-
- /**
- * Checks if an EffectCarrier with the specified namespace and id exists.
- *
- * @param namespace The namespace of the EffectCarrier.
- * @param id The unique identifier of the EffectCarrier.
- * @return True if an EffectCarrier with the given namespace and id exists, false otherwise.
- */
- boolean hasEffectCarrier(String namespace, String id);
-
- /**
- * Retrieves an EffectCarrier with the specified namespace and id.
- *
- * @param namespace The namespace of the EffectCarrier.
- * @param id The unique identifier of the EffectCarrier.
- * @return The EffectCarrier with the given namespace and id, or null if it doesn't exist.
- */
- @Nullable EffectCarrier getEffectCarrier(String namespace, String id);
-
- /**
- * Parses a ConfigurationSection to create an EffectCarrier based on the specified key and configuration.
- *
- * xxx_item: <- section
- * effects:
- * ...
- * events:
- * ...
- *
- * @param key The key that uniquely identifies the EffectCarrier.
- * @param section The ConfigurationSection containing the EffectCarrier configuration.
- * @return An EffectCarrier instance based on the key and configuration, or null if the section is null.
- */
- EffectCarrier getEffectCarrierFromSection(Key key, ConfigurationSection section);
-
- /**
- * Retrieves the initial FishingEffect that represents no special effects.
- *
- * @return The initial FishingEffect.
- */
- @NotNull FishingEffect getInitialEffect();
-
- /**
- * Parses a ConfigurationSection to retrieve an array of EffectModifiers.
- *
- * effects: <- section
- * effect_1:
- * type: xxx
- * value: xxx
- *
- * @param section The ConfigurationSection to parse.
- * @return An array of EffectModifiers based on the values found in the section.
- */
- @NotNull EffectModifier[] getEffectModifiers(ConfigurationSection section);
-
- BaseEffect getBaseEffect(ConfigurationSection section);
-
- /**
- * Parses a ConfigurationSection to create an EffectModifier based on the specified type and configuration.
- *
- * effects:
- * effect_1: <- section
- * type: xxx
- * value: xxx
- *
- * @param section The ConfigurationSection containing the effect modifier configuration.
- * @return An EffectModifier instance based on the type and configuration.
- */
- @Nullable EffectModifier getEffectModifier(ConfigurationSection section);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/EntityManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/EntityManager.java
deleted file mode 100644
index 25de6e97..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/EntityManager.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.entity.EntityLibrary;
-import net.momirealms.customfishing.api.mechanic.loot.Loot;
-import org.bukkit.Location;
-
-public interface EntityManager {
-
- /**
- * Registers an entity library for use in the plugin.
- *
- * @param entityLibrary The entity library to register.
- * @return {@code true} if the entity library was successfully registered, {@code false} if it already exists.
- */
- boolean registerEntityLibrary(EntityLibrary entityLibrary);
-
- /**
- * Unregisters an entity library by its identification key.
- *
- * @param identification The identification key of the entity library to unregister.
- * @return {@code true} if the entity library was successfully unregistered, {@code false} if it does not exist.
- */
- boolean unregisterEntityLibrary(String identification);
-
- /**
- * Summons an entity based on the given loot configuration to a specified location.
- *
- * @param hookLocation The location where the entity will be summoned, typically where the fishing hook is.
- * @param playerLocation The location of the player who triggered the entity summoning.
- * @param loot The loot configuration that defines the entity to be summoned.
- */
- void summonEntity(Location hookLocation, Location playerLocation, Loot loot);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/FishingManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/FishingManager.java
deleted file mode 100644
index bb9eabbe..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/FishingManager.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.TempFishingState;
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
-import net.momirealms.customfishing.api.mechanic.effect.Effect;
-import net.momirealms.customfishing.api.mechanic.game.GameInstance;
-import net.momirealms.customfishing.api.mechanic.game.GameSettings;
-import net.momirealms.customfishing.api.mechanic.game.GamingPlayer;
-import org.bukkit.entity.FishHook;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.UUID;
-
-public interface FishingManager {
-
- /**
- * Removes a fishing hook entity associated with a given player's UUID.
- *
- * @param uuid The UUID of the player
- * @return {@code true} if the fishing hook was successfully removed, {@code false} otherwise.
- */
- boolean removeHook(UUID uuid);
-
- /**
- * Retrieves a FishHook object associated with the provided player's UUID
- *
- * @param uuid The UUID of the player
- * @return fishhook entity, null if not exists
- */
- @Nullable FishHook getHook(UUID uuid);
-
- /**
- * Sets the temporary fishing state for a player.
- *
- * @param player The player for whom to set the temporary fishing state.
- * @param tempFishingState The temporary fishing state to set for the player.
- */
- void setTempFishingState(Player player, TempFishingState tempFishingState);
-
- /**
- * Gets the {@link TempFishingState} object associated with the given UUID.
- *
- * @param uuid The UUID of the player.
- * @return The {@link TempFishingState} object if found, or {@code null} if not found.
- */
- @Nullable TempFishingState getTempFishingState(UUID uuid);
-
- /**
- * Removes the temporary fishing state associated with a player.
- *
- * @param player The player whose temporary fishing state should be removed.
- */
- @Nullable TempFishingState removeTempFishingState(Player player);
-
- /**
- * Processes the game result for a gaming player
- *
- * @param gamingPlayer The gaming player whose game result should be processed.
- */
- void processGameResult(GamingPlayer gamingPlayer);
-
- /**
- * Starts a fishing game for the specified player with the given condition and effect.
- *
- * @param player The player starting the fishing game.
- * @param condition The condition used to determine the game.
- * @param effect The effect applied to the game.
- */
- boolean startFishingGame(Player player, Condition condition, Effect effect);
-
- /**
- * Starts a fishing game for the specified player with the given settings and game instance.
- *
- * @param player The player starting the fishing game.
- * @param settings The game settings for the fishing game.
- * @param gameInstance The instance of the fishing game to start.
- */
- boolean startFishingGame(Player player, GameSettings settings, GameInstance gameInstance);
-
- /**
- * Checks if a player with the given UUID has cast their fishing hook.
- *
- * @param uuid The UUID of the player to check.
- * @return {@code true} if the player has cast their fishing hook, {@code false} otherwise.
- */
- boolean hasPlayerCastHook(UUID uuid);
-
- /**
- * Gets the {@link GamingPlayer} object associated with the given UUID.
- *
- * @param uuid The UUID of the player.
- * @return The {@link GamingPlayer} object if found, or {@code null} if not found.
- */
- @Nullable GamingPlayer getGamingPlayer(UUID uuid);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/HookManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/HookManager.java
deleted file mode 100644
index d0649926..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/HookManager.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.hook.HookSetting;
-import org.bukkit.inventory.ItemStack;
-import org.jetbrains.annotations.Nullable;
-
-public interface HookManager {
-
- /**
- * Get the hook setting by its ID.
- *
- * @param id The ID of the hook setting to retrieve.
- * @return The hook setting with the given ID, or null if not found.
- */
- @Nullable HookSetting getHookSetting(String id);
-
- /**
- * Decreases the durability of a fishing hook by a specified amount and optionally updates its lore.
- * The hook would be removed if its durability is lower than 0
- *
- * @param rod The fishing rod ItemStack to modify.
- * @param amount The amount by which to decrease the durability.
- * @param updateLore Whether to update the lore of the fishing rod.
- */
- void decreaseHookDurability(ItemStack rod, int amount, boolean updateLore);
-
- /**
- * Increases the durability of a hook by a specified amount and optionally updates its lore.
- *
- * @param rod The fishing rod ItemStack to modify.
- * @param amount The amount by which to increase the durability.
- * @param updateLore Whether to update the lore of the fishing rod.
- */
- void increaseHookDurability(ItemStack rod, int amount, boolean updateLore);
-
- /**
- * Sets the durability of a fishing hook to a specific amount and optionally updates its lore.
- *
- * @param rod The fishing rod ItemStack to modify.
- * @param amount The new durability value to set.
- * @param updateLore Whether to update the lore of the fishing rod.
- */
- void setHookDurability(ItemStack rod, int amount, boolean updateLore);
-
- /**
- * Equips a fishing hook on a fishing rod.
- *
- * @param rod The fishing rod ItemStack.
- * @param hook The fishing hook ItemStack.
- * @return True if the hook was successfully equipped, false otherwise.
- */
- boolean equipHookOnRod(ItemStack rod, ItemStack hook);
-
- /**
- * Removes the fishing hook from a fishing rod.
- *
- * @param rod The fishing rod ItemStack.
- * @return The removed fishing hook ItemStack, or null if no hook was found.
- */
- @Nullable ItemStack removeHookFromRod(ItemStack rod);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/IntegrationManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/IntegrationManager.java
deleted file mode 100644
index c78a91e9..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/IntegrationManager.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.integration.EnchantmentInterface;
-import net.momirealms.customfishing.api.integration.LevelInterface;
-import net.momirealms.customfishing.api.integration.SeasonInterface;
-import org.bukkit.inventory.ItemStack;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-
-public interface IntegrationManager {
-
- /**
- * Registers a level plugin with the specified name.
- *
- * @param plugin The name of the level plugin.
- * @param level The implementation of the LevelInterface.
- * @return true if the registration was successful, false if the plugin name is already registered.
- */
- boolean registerLevelPlugin(String plugin, LevelInterface level);
-
- /**
- * Unregisters a level plugin with the specified name.
- *
- * @param plugin The name of the level plugin to unregister.
- * @return true if the unregistration was successful, false if the plugin name is not found.
- */
- boolean unregisterLevelPlugin(String plugin);
-
- /**
- * Registers an enchantment provided by a plugin.
- *
- * @param plugin The name of the plugin providing the enchantment.
- * @param enchantment The enchantment to register.
- * @return true if the registration was successful, false if the enchantment name is already in use.
- */
- boolean registerEnchantment(String plugin, EnchantmentInterface enchantment);
-
- /**
- * Unregisters an enchantment provided by a plugin.
- *
- * @param plugin The name of the plugin providing the enchantment.
- * @return true if the enchantment was successfully unregistered, false if the enchantment was not found.
- */
- boolean unregisterEnchantment(String plugin);
-
- /**
- * Get the LevelInterface provided by a plugin.
- *
- * @param plugin The name of the plugin providing the LevelInterface.
- * @return The LevelInterface provided by the specified plugin, or null if the plugin is not registered.
- */
- @Nullable LevelInterface getLevelPlugin(String plugin);
-
- /**
- * Get an enchantment plugin by its plugin name.
- *
- * @param plugin The name of the enchantment plugin.
- * @return The enchantment plugin interface, or null if not found.
- */
- @Nullable EnchantmentInterface getEnchantmentPlugin(String plugin);
-
- /**
- * Get a list of enchantment keys with level applied to the given ItemStack.
- *
- * @param itemStack The ItemStack to check for enchantments.
- * @return A list of enchantment names applied to the ItemStack.
- */
- List getEnchantments(ItemStack itemStack);
-
- /**
- * Get the current season interface, if available.
- *
- * @return The current season interface, or null if not available.
- */
- @Nullable SeasonInterface getSeasonInterface();
-
- /**
- * Set the current season interface.
- *
- * @param season The season interface to set.
- */
- void setSeasonInterface(SeasonInterface season);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/ItemManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/ItemManager.java
deleted file mode 100644
index 25759e9c..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/ItemManager.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.common.Key;
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
-import net.momirealms.customfishing.api.mechanic.item.BuildableItem;
-import net.momirealms.customfishing.api.mechanic.item.ItemBuilder;
-import net.momirealms.customfishing.api.mechanic.item.ItemLibrary;
-import org.bukkit.Location;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Map;
-import java.util.Set;
-
-public interface ItemManager {
-
- /**
- * Build an ItemStack with a specified namespace and value for a player.
- *
- * @param player The player for whom the ItemStack is being built.
- * @param namespace The namespace of the item.
- * @param value The value of the item.
- * @return The constructed ItemStack.
- */
- @Nullable
- ItemStack build(Player player, String namespace, String value);
-
- /**
- * Build an ItemStack with a specified namespace and value, replacing placeholders,
- * for a player.
- *
- * @param player The player for whom the ItemStack is being built.
- * @param namespace The namespace of the item.
- * @param value The value of the item.
- * @param placeholders The placeholders to replace in the item's attributes.
- * @return The constructed ItemStack, or null if the item doesn't exist.
- */
- @Nullable
- ItemStack build(Player player, String namespace, String value, Map placeholders);
-
- /**
- * Build an ItemStack using an ItemBuilder for a player.
- *
- * @param player The player for whom the ItemStack is being built.
- * @param builder The ItemBuilder used to construct the ItemStack.
- * @return The constructed ItemStack.
- */
- @NotNull ItemStack build(Player player, ItemBuilder builder);
-
- /**
- * Build an ItemStack using the provided ItemBuilder, player, and placeholders.
- *
- * @param player The player for whom the item is being built.
- * @param builder The ItemBuilder that defines the item's properties.
- * @param placeholders A map of placeholders and their corresponding values to be applied to the item.
- * @return The constructed ItemStack.
- */
- @NotNull ItemStack build(Player player, ItemBuilder builder, Map placeholders);
-
- /**
- * Build an ItemStack for a player based on the provided item ID.
- *
- * @param player The player for whom the ItemStack is being built.
- * @param id The item ID, which include an identification (e.g., "Oraxen:id").
- * @return The constructed ItemStack or null if the ID is not valid.
- */
- @Nullable ItemStack buildAnyPluginItemByID(Player player, String id);
-
- /**
- * Get the item ID associated with the given ItemStack, if available.
- *
- * @param itemStack The ItemStack to retrieve the item ID from.
- * @return The item ID without type or null if not found or if the ItemStack is null or empty.
- */
- @Nullable String getCustomFishingItemID(ItemStack itemStack);
-
- /**
- * Get the item ID associated with the given ItemStack by checking all available item libraries.
- * The detection order is determined by the configuration.
- *
- * @param itemStack The ItemStack to retrieve the item ID from.
- * @return The item ID or "AIR" if not found or if the ItemStack is null or empty.
- */
- @NotNull String getAnyPluginItemID(ItemStack itemStack);
-
- /**
- * Create a ItemBuilder instance for an item configuration section
- *
- * xxx_item: <- section
- * material: xxx
- * custom-model-data: xxx
- *
- * @param section The configuration section containing item settings.
- * @param type The type of the item (e.g., "rod", "bait").
- * @param id The unique identifier for the item.
- * @return A CFBuilder instance representing the configured item, or null if the section is null.
- */
- @Nullable ItemBuilder getItemBuilder(ConfigurationSection section, String type, String id);
-
- /**
- * Get a set of all item keys in the CustomFishing plugin.
- *
- * @return A set of item keys.
- */
- Set getAllItemsKey();
-
- /**
- * Retrieve a BuildableItem by its namespace and value.
- *
- * @param namespace The namespace of the BuildableItem.
- * @param value The value of the BuildableItem.
- * @return The BuildableItem with the specified namespace and value, or null if not found.
- */
- @Nullable
- BuildableItem getBuildableItem(String namespace, String value);
-
- /**
- * Get an itemStack's appearance (material + custom model data)
- *
- * @param player player
- * @param material id
- * @return appearance
- */
- ItemStack getItemStackAppearance(Player player, String material);
-
- /**
- * Register an item library.
- *
- * @param itemLibrary The item library to register.
- * @return True if the item library was successfully registered, false if it already exists.
- */
- boolean registerItemLibrary(ItemLibrary itemLibrary);
-
- /**
- * Unregister an item library.
- *
- * @param identification The item library to unregister.
- * @return True if the item library was successfully unregistered, false if it doesn't exist.
- */
- boolean unRegisterItemLibrary(String identification);
-
- /**
- * Drops an item based on the provided loot, applying velocity from a hook location to a player location.
- *
- * @param player The player for whom the item is intended.
- * @param hookLocation The location where the item will initially drop.
- * @param playerLocation The target location towards which the item's velocity is applied.
- * @param itemStack The loot to drop
- * @param condition A map of placeholders for item customization.
- */
- void dropItem(Player player, Location hookLocation, Location playerLocation, ItemStack itemStack, Condition condition);
-
- /**
- * Checks if the provided ItemStack is a custom fishing item
- *
- * @param itemStack The ItemStack to check.
- * @return True if the ItemStack is a custom fishing item; otherwise, false.
- */
- boolean isCustomFishingItem(ItemStack itemStack);
-
- /**
- * Decreases the durability of an ItemStack by a specified amount and optionally updates its lore.
- *
- * @param itemStack The ItemStack to modify.
- * @param amount The amount by which to decrease the durability.
- * @param updateLore Whether to update the lore of the ItemStack.
- */
- void decreaseDurability(Player player, ItemStack itemStack, int amount, boolean updateLore);
-
- /**
- * Increases the durability of an ItemStack by a specified amount and optionally updates its lore.
- *
- * @param itemStack The ItemStack to modify.
- * @param amount The amount by which to increase the durability.
- * @param updateLore Whether to update the lore of the ItemStack.
- */
- void increaseDurability(ItemStack itemStack, int amount, boolean updateLore);
-
- /**
- * Sets the durability of an ItemStack to a specific amount and optionally updates its lore.
- *
- * @param itemStack The ItemStack to modify.
- * @param amount The new durability value.
- * @param updateLore Whether to update the lore of the ItemStack.
- */
- void setDurability(ItemStack itemStack, int amount, boolean updateLore);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java
deleted file mode 100644
index 75acc6f8..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
-import net.momirealms.customfishing.api.mechanic.effect.Effect;
-import net.momirealms.customfishing.api.mechanic.loot.Loot;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public interface LootManager {
-
- /**
- * Retrieves a list of loot IDs associated with a loot group key.
- *
- * @param key The key of the loot group.
- * @return A list of loot IDs belonging to the specified loot group, or null if not found.
- */
- @Nullable List getLootGroup(String key);
-
- /**
- * Retrieves a loot configuration based on a provided loot key.
- *
- * @param key The key of the loot configuration.
- * @return The Loot object associated with the specified loot key, or null if not found.
- */
- @Nullable Loot getLoot(String key);
-
- /**
- * Retrieves a collection of all loot configuration keys.
- *
- * @return A collection of all loot configuration keys.
- */
- Collection getAllLootKeys();
-
- /**
- * Retrieves a collection of all loot configurations.
- *
- * @return A collection of all loot configurations.
- */
- Collection getAllLoots();
-
- /**
- * Retrieves loot configurations with weights based on a given condition.
- *
- * @param condition The condition used to filter loot configurations.
- * @return A mapping of loot configuration keys to their associated weights.
- */
- HashMap getLootWithWeight(Condition condition);
-
- /**
- * Get a collection of possible loot keys based on a given condition.
- *
- * @param condition The condition to determine possible loot.
- * @return A collection of loot keys.
- */
- Collection getPossibleLootKeys(Condition condition);
-
- /**
- * Get a map of possible loot keys with their corresponding weights, considering fishing effect and condition.
- *
- * @param initialEffect The effect to apply weight modifiers.
- * @param condition The condition to determine possible loot.
- * @return A map of loot keys and their weights.
- */
- @NotNull Map getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition);
-
- /**
- * Get the next loot item based on fishing effect and condition.
- *
- * @param effect The effect to apply weight modifiers.
- * @param condition The condition to determine possible loot.
- * @return The next loot item, or null if it doesn't exist.
- */
- @Nullable Loot getNextLoot(Effect effect, Condition condition);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/MarketManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/MarketManager.java
deleted file mode 100644
index 1388e503..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/MarketManager.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.Map;
-
-public interface MarketManager {
-
- /**
- * Open the market GUI for a player
- *
- * @param player player
- */
- void openMarketGUI(Player player);
-
- /**
- * Retrieves the current date as an integer in the format MMDD (e.g., September 21 as 0921).
- *
- * @return An integer representing the current date.
- */
- int getCachedDate();
-
- /**
- * Retrieves the current date as an integer in the format MMDD (e.g., September 21 as 0921).
- *
- * @return An integer representing the current date.
- */
- int getDate();
-
- /**
- * Calculates the price of an ItemStack based on custom data or a predefined price map.
- *
- * @param itemStack The ItemStack for which the price is calculated.
- * @return The calculated price of the ItemStack.
- */
- double getItemPrice(ItemStack itemStack);
-
- /**
- * Retrieves the formula used for calculating prices.
- *
- * @return The pricing formula as a string.
- */
- String getFormula();
-
- /**
- * Calculates the price based on a formula with provided variables.
- *
- * @return The calculated price based on the formula and provided variables.
- */
- double getFishPrice(Player player, Map vars);
-
- /**
- * Gets the character representing the item slot in the MarketGUI.
- *
- * @return The item slot character.
- */
- char getItemSlot();
-
- /**
- * Gets the character representing the sell slot in the MarketGUI.
- *
- * @return The sell slot character.
- */
- char getSellSlot();
-
- /**
- * Gets the character representing the sell-all slot in the MarketGUI.
- *
- * @return The sell-all slot character.
- */
- char getSellAllSlot();
-
- /**
- * Gets the layout of the MarketGUI as an array of strings.
- *
- * @return The layout of the MarketGUI.
- */
- String[] getLayout();
-
- /**
- * Gets the title of the MarketGUI.
- *
- * @return The title of the MarketGUI.
- */
- String getTitle();
-
- /**
- * Gets the earning limit
- *
- * @return The earning limit
- */
- double getEarningLimit(Player player);
-
- /**
- * Is market enabled
- *
- * @return enable or not
- */
- boolean isEnable();
-
- /**
- * Should fish in bag also be sold
- *
- * @return sell or not
- */
- boolean sellFishingBag();
-
- /**
- * Get the total worth of the items in inventory
- *
- * @param inventory inventory
- * @return total worth
- */
- double getInventoryTotalWorth(Inventory inventory);
-
- int getInventorySellAmount(Inventory inventory);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/PlaceholderManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/PlaceholderManager.java
deleted file mode 100644
index 922db18c..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/PlaceholderManager.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-import java.util.Map;
-
-public interface PlaceholderManager {
-
- /**
- * Register a custom placeholder
- *
- * @param placeholder for instance {level}
- * @param original for instance %player_level%
- * @return success or not, it would fail if the placeholder has been registered
- */
- boolean registerCustomPlaceholder(String placeholder, String original);
-
- /**
- * Set placeholders in a text string for a player.
- *
- * @param player The player for whom the placeholders should be set.
- * @param text The text string containing placeholders.
- * @return The text string with placeholders replaced if PlaceholderAPI is available; otherwise, the original text.
- */
- String setPlaceholders(Player player, String text);
-
- /**
- * Set placeholders in a text string for an offline player.
- *
- * @param player The offline player for whom the placeholders should be set.
- * @param text The text string containing placeholders.
- * @return The text string with placeholders replaced if PlaceholderAPI is available; otherwise, the original text.
- */
- String setPlaceholders(OfflinePlayer player, String text);
-
- /**
- * Detect and extract placeholders from a text string.
- *
- * @param text The text string to search for placeholders.
- * @return A list of detected placeholders in the text.
- */
- List detectPlaceholders(String text);
-
- /**
- * Get the value associated with a single placeholder.
- *
- * @param player The player for whom the placeholders are being resolved (nullable).
- * @param placeholder The placeholder to look up.
- * @param placeholders A map of placeholders to their corresponding values.
- * @return The value associated with the placeholder, or the original placeholder if not found.
- */
- String getSingleValue(@Nullable Player player, String placeholder, Map placeholders);
-
- /**
- * Parse a text string by replacing placeholders with their corresponding values.
- *
- * @param player The offline player for whom the placeholders are being resolved (nullable).
- * @param text The text string containing placeholders.
- * @param placeholders A map of placeholders to their corresponding values.
- * @return The text string with placeholders replaced by their values.
- */
- String parse(@Nullable OfflinePlayer player, String text, Map placeholders);
-
- /**
- * Parse a list of text strings by replacing placeholders with their corresponding values.
- *
- * @param player The player for whom the placeholders are being resolved (can be null for offline players).
- * @param list The list of text strings containing placeholders.
- * @param replacements A map of custom replacements for placeholders.
- * @return The list of text strings with placeholders replaced by their values.
- */
- List parse(@Nullable OfflinePlayer player, List list, Map replacements);
-
- /**
- * Get an expression's value
- * @param player player
- * @param formula formula
- * @param vars vars
- * @return result
- */
- double getExpressionValue(Player player, String formula, Map vars);
-
- /**
- * Get an expression's value
- * @param formula formula
- * @return result
- */
- double getExpressionValue(String formula);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/RequirementManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/RequirementManager.java
deleted file mode 100644
index d18a6cd2..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/RequirementManager.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
-import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
-import net.momirealms.customfishing.api.mechanic.requirement.RequirementFactory;
-import org.bukkit.configuration.ConfigurationSection;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public interface RequirementManager {
-
- /**
- * Legacy format support
- * @param key key
- * @param requirements requirements
- * @param weight weight
- * @return success or not
- */
- @Deprecated
- boolean putLegacyLootToMap(String key, Requirement[] requirements, double weight);
-
- /**
- * Registers a custom requirement type with its corresponding factory.
- *
- * @param type The type identifier of the requirement.
- * @param requirementFactory The factory responsible for creating instances of the requirement.
- * @return True if registration was successful, false if the type is already registered.
- */
- boolean registerRequirement(String type, RequirementFactory requirementFactory);
-
- /**
- * Unregisters a custom requirement type.
- *
- * @param type The type identifier of the requirement to unregister.
- * @return True if unregistration was successful, false if the type is not registered.
- */
- boolean unregisterRequirement(String type);
-
- /**
- * Retrieves an array of requirements based on a configuration section.
- *
- * @param section The configuration section containing requirement definitions.
- * @param advanced A flag indicating whether to use advanced requirements.
- * @return An array of Requirement objects based on the configuration section
- */
- @Nullable Requirement[] getRequirements(ConfigurationSection section, boolean advanced);
-
- /**
- * If a requirement type exists
- *
- * @param type type
- * @return exists or not
- */
- boolean hasRequirement(String type);
-
- /**
- * Retrieves a Requirement object based on a configuration section and advanced flag.
- *
- * requirement_1: <- section
- * type: xxx
- * value: xxx
- *
- * @param section The configuration section containing requirement definitions.
- * @param advanced A flag indicating whether to use advanced requirements.
- * @return A Requirement object based on the configuration section, or an EmptyRequirement if the section is null or invalid.
- */
- @NotNull Requirement getRequirement(ConfigurationSection section, boolean advanced);
-
- /**
- * Gets a requirement based on the provided type and value.
- * If a valid RequirementFactory is found for the type, it is used to create the requirement.
- * If no factory is found, a warning is logged, and an empty requirement instance is returned.
- *
- * world: <- type
- * - world <- value
- *
- * @param type The type representing the requirement type.
- * @param value The value associated with the requirement.
- * @return A Requirement instance based on the type and value, or an EmptyRequirement if the type is invalid.
- */
- @NotNull Requirement getRequirement(String type, Object value);
-
- /**
- * Retrieves a RequirementFactory based on the specified requirement type.
- *
- * @param type The requirement type for which to retrieve a factory.
- * @return A RequirementFactory for the specified type, or null if no factory is found.
- */
- @Nullable RequirementFactory getRequirementFactory(String type);
-
- /**
- * Checks if an array of requirements is met for a given condition.
- *
- * @param condition The Condition object to check against the requirements.
- * @param requirements An array of Requirement instances to be evaluated.
- * @return True if all requirements are met, false otherwise. Returns true if the requirements array is null.
- */
- static boolean isRequirementMet(Condition condition, Requirement... requirements) {
- if (requirements == null) return true;
- for (Requirement requirement : requirements) {
- if (!requirement.isConditionMet(condition)) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/StatisticsManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/StatisticsManager.java
deleted file mode 100644
index 64ad6544..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/StatisticsManager.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-import java.util.UUID;
-
-public interface StatisticsManager {
-
- /**
- * Get the statistics for a player with the given UUID.
- *
- * @param uuid The UUID of the player for whom statistics are retrieved.
- * @return The player's statistics or null if the player is not found.
- */
- @Nullable Statistics getStatistics(UUID uuid);
-
- /**
- * Get a list of strings associated with a specific key in a category map.
- *
- * @param key The key to look up in the category map.
- * @return A list of strings associated with the key or null if the key is not found.
- */
- @Nullable List getCategory(String key);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/StorageManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/StorageManager.java
deleted file mode 100644
index b84b5c1a..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/StorageManager.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.data.DataStorageInterface;
-import net.momirealms.customfishing.api.data.PlayerData;
-import net.momirealms.customfishing.api.data.user.OfflineUser;
-import net.momirealms.customfishing.api.data.user.OnlineUser;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-
-public interface StorageManager {
-
- /**
- * Gets the unique server identifier.
- *
- * @return The unique server identifier.
- */
- @NotNull String getUniqueID();
-
- /**
- * Gets an OnlineUser instance for the specified UUID.
- *
- * @param uuid The UUID of the player.
- * @return An OnlineUser instance if the player is online, or null if not.
- */
- @Nullable OnlineUser getOnlineUser(UUID uuid);
-
- /**
- * Get all the online users
- *
- * @return online users
- */
- Collection getOnlineUsers();
-
- /**
- * Asynchronously retrieves an OfflineUser instance for the specified UUID.
- * The offline user might be a locked one with no data, use isLockedData() method
- * to check if it's an empty locked data
- *
- * @param uuid The UUID of the player.
- * @param lock Whether to lock the data during retrieval.
- * @return A CompletableFuture that resolves to an Optional containing the OfflineUser instance if found, or empty if not found or locked.
- */
- CompletableFuture> getOfflineUser(UUID uuid, boolean lock);
-
- /**
- * If the offlineUser is locked with no data in it
- * An user's data would be locked if he is playing on another server that connected
- * to database. Modifying this data would actually do nothing.
- *
- * @param offlineUser offlineUser
- * @return is locked or not
- */
- boolean isLockedData(OfflineUser offlineUser);
-
- /**
- * Asynchronously saves user data for an OfflineUser.
- *
- * @param offlineUser The OfflineUser whose data needs to be saved.
- * @param unlock Whether to unlock the data after saving.
- * @return A CompletableFuture that resolves to a boolean indicating the success of the data saving operation.
- */
- CompletableFuture saveUserData(OfflineUser offlineUser, boolean unlock);
-
- /**
- * Gets the data source used for data storage.
- *
- * @return The data source.
- */
- DataStorageInterface getDataSource();
-
- /**
- * Checks if Redis is enabled.
- *
- * @return True if Redis is enabled; otherwise, false.
- */
- boolean isRedisEnabled();
-
- /**
- * Converts PlayerData to bytes.
- *
- * @param data The PlayerData to be converted.
- * @return The byte array representation of PlayerData.
- */
- byte @NotNull [] toBytes(@NotNull PlayerData data);
-
- /**
- * Converts PlayerData to JSON format.
- *
- * @param data The PlayerData to be converted.
- * @return The JSON string representation of PlayerData.
- */
- @NotNull String toJson(@NotNull PlayerData data);
-
- /**
- * Converts JSON string to PlayerData.
- *
- * @param json The JSON string to be converted.
- * @return The PlayerData object.
- */
- @NotNull PlayerData fromJson(String json);
-
- /**
- * Converts bytes to PlayerData.
- *
- * @param data The byte array to be converted.
- * @return The PlayerData object.
- */
- @NotNull PlayerData fromBytes(byte[] data);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/TotemManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/TotemManager.java
deleted file mode 100644
index 02c3dd9b..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/TotemManager.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.manager;
-
-import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
-import org.bukkit.Location;
-
-public interface TotemManager {
-
- /**
- * Get the EffectCarrier associated with an activated totem located near the specified location.
- *
- * @param location The location to search for activated totems.
- * @return The EffectCarrier associated with the nearest activated totem or null if none are found.
- */
- EffectCarrier getTotemEffect(Location location);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/GlobalSettings.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/GlobalSettings.java
deleted file mode 100644
index 0192b1d9..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/GlobalSettings.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.mechanic;
-
-import net.momirealms.customfishing.api.CustomFishingPlugin;
-import net.momirealms.customfishing.api.mechanic.action.Action;
-import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
-import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
-import org.bukkit.configuration.ConfigurationSection;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents global settings for actions related to fishing, loot, rods, and bait.
- */
-public class GlobalSettings {
-
- private static HashMap lootActions = new HashMap<>();
- private static HashMap rodActions = new HashMap<>();
- private static HashMap baitActions = new HashMap<>();
- private static HashMap hookActions = new HashMap<>();
- private static EffectModifier[] effectModifiers;
-
- /**
- * Loads global settings from a configuration section.
- *
- * @param section The configuration section to load settings from.
- */
- public static void loadEvents(ConfigurationSection section) {
- if (section == null) return;
- for (Map.Entry entry : section.getValues(false).entrySet()) {
- if (entry.getValue() instanceof ConfigurationSection inner) {
- HashMap map = CustomFishingPlugin.get().getActionManager().getActionMap(inner);
- switch (entry.getKey()) {
- case "loot" -> lootActions = map;
- case "rod" -> rodActions = map;
- case "bait" -> baitActions = map;
- case "hook" -> hookActions = map;
- }
- }
- }
- }
-
- public static EffectModifier[] getEffectModifiers() {
- return effectModifiers;
- }
-
- public static void setEffects(EffectModifier[] modifiers) {
- effectModifiers = modifiers;
- }
-
- /**
- * Unloads global settings, clearing all action maps.
- */
- public static void unload() {
- lootActions.clear();
- rodActions.clear();
- baitActions.clear();
- }
-
- /**
- * Triggers loot-related actions for a specific trigger and condition.
- *
- * @param trigger The trigger to activate actions for.
- * @param condition The condition that triggered the actions.
- */
- public static void triggerLootActions(ActionTrigger trigger, Condition condition) {
- Action[] actions = lootActions.get(trigger);
- if (actions != null) {
- for (Action action : actions) {
- action.trigger(condition);
- }
- }
- }
-
- /**
- * Triggers rod-related actions for a specific trigger and condition.
- *
- * @param trigger The trigger to activate actions for.
- * @param condition The condition that triggered the actions.
- */
- public static void triggerRodActions(ActionTrigger trigger, Condition condition) {
- Action[] actions = rodActions.get(trigger);
- if (actions != null) {
- for (Action action : actions) {
- action.trigger(condition);
- }
- }
- }
-
- /**
- * Triggers bait-related actions for a specific trigger and condition.
- *
- * @param trigger The trigger to activate actions for.
- * @param condition The condition that triggered the actions.
- */
- public static void triggerBaitActions(ActionTrigger trigger, Condition condition) {
- Action[] actions = baitActions.get(trigger);
- if (actions != null) {
- for (Action action : actions) {
- action.trigger(condition);
- }
- }
- }
-
- /**
- * Triggers hook-related actions for a specific trigger and condition.
- *
- * @param trigger The trigger to activate actions for.
- * @param condition The condition that triggered the actions.
- */
- public static void triggerHookActions(ActionTrigger trigger, Condition condition) {
- Action[] actions = hookActions.get(trigger);
- if (actions != null) {
- for (Action action : actions) {
- action.trigger(condition);
- }
- }
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/MechanicType.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/MechanicType.java
new file mode 100644
index 00000000..ca0ac3c9
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/MechanicType.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic;
+
+import net.kyori.adventure.util.Index;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Objects;
+
+public class MechanicType {
+
+ private static final HashMap> types = new HashMap<>();
+
+ public static final MechanicType LOOT = of("loot");
+ public static final MechanicType ROD = of("rod");
+ public static final MechanicType UTIL = of("util");
+ public static final MechanicType BAIT = of("bait");
+ public static final MechanicType HOOK = of("hook");
+ public static final MechanicType TOTEM = of("totem");
+ public static final MechanicType ENTITY = of("entity");
+ public static final MechanicType BLOCK = of("block");
+ public static final MechanicType ENCHANT = of("enchant");
+
+ private final String type;
+
+ public MechanicType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ private static MechanicType of(String type) {
+ return new MechanicType(type);
+ }
+
+ public static MechanicType[] values() {
+ return new MechanicType[]{LOOT, ROD, UTIL, BAIT, HOOK, TOTEM, ENCHANT, ENTITY, BLOCK};
+ }
+
+ private static final Index INDEX = Index.create(MechanicType::getType, values());
+
+ public static Index index() {
+ return INDEX;
+ }
+
+ @ApiStatus.Internal
+ public static void register(String id, MechanicType type) {
+ List previous = types.computeIfAbsent(id, k -> new ArrayList<>());
+ previous.add(type);
+ }
+
+ @Nullable
+ @ApiStatus.Internal
+ public static List getTypeByID(String id) {
+ return types.get(id);
+ }
+
+ @ApiStatus.Internal
+ public static void reset() {
+ types.clear();
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) return true;
+ if (object == null || getClass() != object.getClass()) return false;
+ MechanicType mechanicType = (MechanicType) object;
+ return Objects.equals(type, mechanicType.type);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(type);
+ }
+
+ @Override
+ public String toString() {
+ return type;
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/TempFishingState.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/TempFishingState.java
deleted file mode 100644
index 503ef51e..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/TempFishingState.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.mechanic;
-
-import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
-import net.momirealms.customfishing.api.mechanic.effect.Effect;
-import net.momirealms.customfishing.api.mechanic.loot.Loot;
-
-/**
- * Represents a temporary state during fishing that includes an effect, preparation, and loot.
- */
-public class TempFishingState {
-
- private final Effect effect;
- private final FishingPreparation preparation;
- private Loot loot;
-
- /**
- * Creates a new instance of TempFishingState.
- *
- * @param effect The effect associated with this state.
- * @param preparation The fishing preparation associated with this state.
- * @param loot The loot associated with this state.
- */
- public TempFishingState(Effect effect, FishingPreparation preparation, Loot loot) {
- this.effect = effect;
- this.preparation = preparation;
- this.loot = loot;
- }
-
- /**
- * Gets the effect associated with this fishing state.
- *
- * @return The effect.
- */
- public Effect getEffect() {
- return effect;
- }
-
- /**
- * Gets the fishing preparation associated with this fishing state.
- *
- * @return The fishing preparation.
- */
- public FishingPreparation getPreparation() {
- return preparation;
- }
-
- /**
- * Gets the loot associated with this fishing state.
- *
- * @return The loot.
- */
- public Loot getLoot() {
- return loot;
- }
-
- /**
- * Set the loot associated with this fishing state.
- *
- */
- public void setLoot(Loot loot) {
- this.loot = loot;
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/Action.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/Action.java
index af44d142..6276916d 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/Action.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/Action.java
@@ -17,10 +17,14 @@
package net.momirealms.customfishing.api.mechanic.action;
-import net.momirealms.customfishing.api.mechanic.condition.Condition;
+import net.momirealms.customfishing.api.mechanic.context.Context;
-public interface Action {
-
- void trigger(Condition condition);
+public interface Action {
+ /**
+ * Triggers the action based on the provided condition.
+ *
+ * @param context the context
+ */
+ void trigger(Context context);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionExpansion.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionExpansion.java
index bd48cfd1..6fc0ff8c 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionExpansion.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionExpansion.java
@@ -17,13 +17,39 @@
package net.momirealms.customfishing.api.mechanic.action;
-public abstract class ActionExpansion {
+/**
+ * Abstract class representing an expansion of an action in the custom fishing API.
+ * This class should be extended to provide specific implementations of actions.
+ *
+ * @param the type parameter for the action factory
+ */
+public abstract class ActionExpansion {
+ /**
+ * Retrieves the version of this action expansion.
+ *
+ * @return a String representing the version of the action expansion
+ */
public abstract String getVersion();
+ /**
+ * Retrieves the author of this action expansion.
+ *
+ * @return a String representing the author of the action expansion
+ */
public abstract String getAuthor();
+ /**
+ * Retrieves the type of this action.
+ *
+ * @return a String representing the type of action
+ */
public abstract String getActionType();
- public abstract ActionFactory getActionFactory();
+ /**
+ * Retrieves the action factory associated with this action expansion.
+ *
+ * @return an ActionFactory of type T that creates instances of the action
+ */
+ public abstract ActionFactory getActionFactory();
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionFactory.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionFactory.java
index fdaae29d..a3d526e0 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionFactory.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionFactory.java
@@ -17,7 +17,18 @@
package net.momirealms.customfishing.api.mechanic.action;
-public interface ActionFactory {
+/**
+ * Interface representing a factory for creating actions.
+ *
+ * @param the type of object that the action will operate on
+ */
+public interface ActionFactory {
- Action build(Object args, double chance);
+ /**
+ * Constructs an action based on the provided arguments.
+ *
+ * @param args the args containing the arguments needed to build the action
+ * @return the constructed action
+ */
+ Action process(Object args, double chance);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionManager.java
new file mode 100644
index 00000000..9e724f29
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionManager.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.action;
+
+import dev.dejvokep.boostedyaml.block.implementation.Section;
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import net.momirealms.customfishing.common.plugin.feature.Reloadable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.*;
+
+/**
+ * The ActionManager interface manages custom action types and provides methods for handling actions.
+ *
+ * @param the type of the context in which the actions are triggered.
+ */
+public interface ActionManager extends Reloadable {
+
+ /**
+ * Registers a custom action type with its corresponding factory.
+ *
+ * @param type The type identifier of the action.
+ * @param actionFactory The factory responsible for creating instances of the action.
+ * @return True if registration was successful, false if the type is already registered.
+ */
+ boolean registerAction(String type, ActionFactory actionFactory);
+
+ /**
+ * Unregisters a custom action type.
+ *
+ * @param type The type identifier of the action to unregister.
+ * @return True if unregistration was successful, false if the type is not registered.
+ */
+ boolean unregisterAction(String type);
+
+ /**
+ * Checks if an action type is registered.
+ *
+ * @param type The type identifier of the action.
+ * @return True if the action type is registered, otherwise false.
+ */
+ boolean hasAction(@NotNull String type);
+
+ /**
+ * Retrieves the action factory for the specified action type.
+ *
+ * @param type The type identifier of the action.
+ * @return The action factory for the specified type, or null if no factory is found.
+ */
+ @Nullable
+ ActionFactory getActionFactory(@NotNull String type);
+
+ /**
+ * Parses an action from a configuration section.
+ *
+ * @param section The configuration section containing the action definition.
+ * @return The parsed action.
+ */
+ Action parseAction(Section section);
+
+ /**
+ * Parses an array of actions from a configuration section.
+ *
+ * @param section The configuration section containing the action definitions.
+ * @return An array of parsed actions.
+ */
+ @NotNull
+ Action[] parseActions(Section section);
+
+ /**
+ * Parses an action from the given type and arguments.
+ *
+ * @param type The type identifier of the action.
+ * @param args The arguments for the action.
+ * @return The parsed action.
+ */
+ Action parseAction(@NotNull String type, @NotNull Object args);
+
+ /**
+ * Generates a map of actions triggered by specific events from a configuration section.
+ *
+ * @param section The configuration section containing event-action mappings.
+ * @return A map where the keys are action triggers and the values are arrays of actions associated with those triggers.
+ */
+ default Map[]> parseEventActions(Section section) {
+ HashMap[]> actionMap = new HashMap<>();
+ for (Map.Entry entry : section.getStringRouteMappedValues(false).entrySet()) {
+ if (entry.getValue() instanceof Section innerSection) {
+ try {
+ actionMap.put(
+ ActionTrigger.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH)),
+ parseActions(innerSection)
+ );
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return actionMap;
+ }
+
+ /**
+ * Parses a configuration section to generate a map of timed actions.
+ *
+ * @param section The configuration section containing time-action mappings.
+ * @return A TreeMap where the keys are time values (in integer form) and the values are arrays of actions associated with those times.
+ */
+ default TreeMap[]> parseTimesActions(Section section) {
+ TreeMap[]> actionMap = new TreeMap<>();
+ for (Map.Entry entry : section.getStringRouteMappedValues(false).entrySet()) {
+ if (entry.getValue() instanceof Section innerSection) {
+ actionMap.put(Integer.parseInt(entry.getKey()), parseActions(innerSection));
+ }
+ }
+ return actionMap;
+ }
+
+ /**
+ * Triggers a list of actions with the given context.
+ * If the list of actions is not null, each action in the list is triggered.
+ *
+ * @param context The context associated with the actions.
+ * @param actions The list of actions to trigger.
+ */
+ static void trigger(@NotNull Context context, @Nullable List> actions) {
+ if (actions != null)
+ for (Action action : actions)
+ action.trigger(context);
+ }
+
+ /**
+ * Triggers an array of actions with the given context.
+ * If the array of actions is not null, each action in the array is triggered.
+ *
+ * @param context The context associated with the actions.
+ * @param actions The array of actions to trigger.
+ */
+ static void trigger(@NotNull Context context, @Nullable Action[] actions) {
+ if (actions != null)
+ for (Action action : actions)
+ action.trigger(context);
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionTrigger.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionTrigger.java
index 2f41923a..3b981bb1 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionTrigger.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionTrigger.java
@@ -18,7 +18,6 @@
package net.momirealms.customfishing.api.mechanic.action;
public enum ActionTrigger {
-
SUCCESS,
FAILURE,
HOOK,
@@ -26,8 +25,11 @@ public enum ActionTrigger {
CAST,
BITE,
LAND,
+ LURE,
+ ESCAPE,
ACTIVATE,
TIMER,
INTERACT,
+ REEL,
NEW_SIZE_RECORD
}
diff --git a/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/ParseUtils.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/EmptyAction.java
similarity index 61%
rename from plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/ParseUtils.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/action/EmptyAction.java
index 3791dab0..cb819b05 100644
--- a/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/ParseUtils.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/EmptyAction.java
@@ -15,19 +15,20 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.compatibility.papi;
+package net.momirealms.customfishing.api.mechanic.action;
-import me.clip.placeholderapi.PlaceholderAPI;
-import org.bukkit.OfflinePlayer;
+import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.entity.Player;
-public class ParseUtils {
+/**
+ * An implementation of the Action interface that represents an empty action with no behavior.
+ * This class serves as a default action to prevent NPE.
+ */
+public class EmptyAction implements Action {
- public static String setPlaceholders(Player player, String text) {
- return PlaceholderAPI.setPlaceholders(player, text);
- }
+ public static final EmptyAction INSTANCE = new EmptyAction();
- public static String setPlaceholders(OfflinePlayer player, String text) {
- return PlaceholderAPI.setPlaceholders(player, text);
+ @Override
+ public void trigger(Context context) {
}
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/VersionManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/BagManager.java
similarity index 56%
rename from api/src/main/java/net/momirealms/customfishing/api/manager/VersionManager.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/BagManager.java
index d75bdfd1..5f01cf69 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/VersionManager.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/BagManager.java
@@ -15,27 +15,26 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.manager;
+package net.momirealms.customfishing.api.mechanic.bag;
+import net.momirealms.customfishing.common.plugin.feature.Reloadable;
+import org.bukkit.entity.Player;
+
+import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-public interface VersionManager {
+public interface BagManager extends Reloadable {
- boolean isVersionNewerThan1_19();
+ static int getBagInventoryRows(Player player) {
+ int size = 1;
+ for (int i = 6; i > 1; i--) {
+ if (player.hasPermission("fishingbag.rows." + i)) {
+ size = i;
+ break;
+ }
+ }
+ return size;
+ }
- boolean isVersionNewerThan1_19_R3();
-
- boolean isVersionNewerThan1_19_R2();
-
- CompletableFuture checkUpdate();
-
- boolean isVersionNewerThan1_20();
-
- boolean isSpigot();
-
- public boolean hasRegionScheduler();
-
- String getPluginVersion();
-
- boolean isMojmap();
+ CompletableFuture openBag(Player viewer, UUID owner);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/FishingBagHolder.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/FishingBagHolder.java
index 17d0644a..010fb62d 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/FishingBagHolder.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/FishingBagHolder.java
@@ -17,6 +17,8 @@
package net.momirealms.customfishing.api.mechanic.bag;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@@ -35,6 +37,20 @@ public class FishingBagHolder implements InventoryHolder {
@Override
public @NotNull Inventory getInventory() {
+ Player player = Bukkit.getPlayer(owner);
+ if (player != null) {
+ int rows = BagManager.getBagInventoryRows(player);
+ if (rows * 9 != inventory.getSize()) {
+ Inventory newBag = Bukkit.createInventory(this, rows * 9);
+ ItemStack[] newContents = new ItemStack[rows * 9];
+ ItemStack[] oldContents = inventory.getContents();
+ for (int i = 0; i < rows * 9 && i < oldContents.length; i++) {
+ newContents[i] = oldContents[i];
+ }
+ newBag.setContents(newContents);
+ this.setInventory(newBag);
+ }
+ }
return inventory;
}
@@ -49,4 +65,12 @@ public class FishingBagHolder implements InventoryHolder {
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
+
+ public static FishingBagHolder create(UUID owner, ItemStack[] itemStacks, int size) {
+ FishingBagHolder holder = new FishingBagHolder(owner);
+ Inventory inventory = Bukkit.createInventory(holder, size);
+ holder.setInventory(inventory);
+ holder.setItems(itemStacks);
+ return holder;
+ }
}
\ No newline at end of file
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfig.java
index d7da2a56..8f601de7 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfig.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfig.java
@@ -19,85 +19,80 @@ package net.momirealms.customfishing.api.mechanic.block;
import java.util.List;
-public class BlockConfig implements BlockSettings {
+/**
+ * Interface representing the configuration for a custom block in the CustomFishing plugin.
+ * Provides methods to access various block properties and modifiers.
+ */
+public interface BlockConfig {
- private String blockID;
- private List dataModifierList;
- private List stateModifierList;
- private boolean persist;
- private double horizontalVector;
- private double verticalVector;
+ String id();
- @Override
- public String getBlockID() {
- return blockID;
+ /**
+ * Gets the unique identifier for the block.
+ *
+ * @return The block's unique identifier.
+ */
+ String blockID();
+
+ /**
+ * Gets the list of data modifiers applied to the block.
+ *
+ * @return A list of {@link BlockDataModifier} objects.
+ */
+ List dataModifier();
+
+ /**
+ * Gets the list of state modifiers applied to the block.
+ *
+ * @return A list of {@link BlockStateModifier} objects.
+ */
+ List stateModifiers();
+
+ /**
+ * Creates a new builder instance for constructing a {@link BlockConfig}.
+ *
+ * @return A new {@link Builder} instance.
+ */
+ static Builder builder() {
+ return new BlockConfigImpl.BuilderImpl();
}
- @Override
- public List getDataModifier() {
- return dataModifierList;
+ /**
+ * Builder interface for constructing a {@link BlockConfig} instance.
+ */
+ interface Builder {
+
+ Builder id(String id);
+
+ /**
+ * Sets the block ID for the configuration.
+ *
+ * @param blockID The block's unique identifier.
+ * @return The current {@link Builder} instance.
+ */
+ Builder blockID(String blockID);
+
+ /**
+ * Sets the list of data modifiers for the configuration.
+ *
+ * @param dataModifierList A list of {@link BlockDataModifier} objects.
+ * @return The current {@link Builder} instance.
+ */
+ Builder dataModifierList(List dataModifierList);
+
+ /**
+ * Sets the list of state modifiers for the configuration.
+ *
+ * @param stateModifierList A list of {@link BlockStateModifier} objects.
+ * @return The current {@link Builder} instance.
+ */
+ Builder stateModifierList(List stateModifierList);
+
+ /**
+ * Builds and returns the configured {@link BlockConfig} instance.
+ *
+ * @return The constructed {@link BlockConfig} instance.
+ */
+ BlockConfig build();
}
-
- @Override
- public List getStateModifierList() {
- return stateModifierList;
- }
-
- @Override
- public boolean isPersist() {
- return persist;
- }
-
- @Override
- public double getHorizontalVector() {
- return horizontalVector;
- }
-
- @Override
- public double getVerticalVector() {
- return verticalVector;
- }
-
- public static class Builder {
-
- private final BlockConfig config;
-
- public Builder() {
- this.config = new BlockConfig();
- }
-
- public Builder persist(boolean value) {
- config.persist = value;
- return this;
- }
-
- public Builder horizontalVector(double value) {
- config.horizontalVector = value;
- return this;
- }
-
- public Builder verticalVector(double value) {
- config.verticalVector = value;
- return this;
- }
-
- public Builder blockID(String value) {
- config.blockID = value;
- return this;
- }
-
- public Builder dataModifiers(List value) {
- config.dataModifierList = value;
- return this;
- }
-
- public Builder stateModifiers(List value) {
- config.stateModifierList = value;
- return this;
- }
-
- public BlockConfig build() {
- return config;
- }
- }
-}
+}
\ No newline at end of file
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfigImpl.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfigImpl.java
new file mode 100644
index 00000000..ffcd0879
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockConfigImpl.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.block;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BlockConfigImpl implements BlockConfig {
+
+ private final String blockID;
+ private final List dataModifierList;
+ private final List stateModifierList;
+ private final String id;
+
+ public BlockConfigImpl(String id, String blockID, List dataModifierList, List stateModifierList) {
+ this.blockID = blockID;
+ this.dataModifierList = dataModifierList;
+ this.stateModifierList = stateModifierList;
+ this.id = id;
+ }
+
+ @Override
+ public String id() {
+ return id;
+ }
+
+ @Override
+ public String blockID() {
+ return blockID;
+ }
+
+ @Override
+ public List dataModifier() {
+ return dataModifierList;
+ }
+
+ @Override
+ public List stateModifiers() {
+ return stateModifierList;
+ }
+
+ public static class BuilderImpl implements Builder {
+ private String blockID;
+ private final List dataModifierList = new ArrayList<>();
+ private final List stateModifierList = new ArrayList<>();
+ private String id;
+ @Override
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+ @Override
+ public Builder blockID(String blockID) {
+ this.blockID = blockID;
+ return this;
+ }
+ @Override
+ public Builder dataModifierList(List dataModifierList) {
+ this.dataModifierList.addAll(dataModifierList);
+ return this;
+ }
+ @Override
+ public Builder stateModifierList(List stateModifierList) {
+ this.stateModifierList.addAll(stateModifierList);
+ return this;
+ }
+ @Override
+ public BlockConfig build() {
+ return new BlockConfigImpl(id, blockID, dataModifierList, stateModifierList);
+ }
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifier.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifier.java
index 6ba31318..6830a4e5 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifier.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifier.java
@@ -17,9 +17,12 @@
package net.momirealms.customfishing.api.mechanic.block;
+import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
+@FunctionalInterface
public interface BlockDataModifier {
- void apply(Player player, BlockData blockData);
+
+ void apply(Context context, BlockData blockData);
}
\ No newline at end of file
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifierBuilder.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifierFactory.java
similarity index 87%
rename from api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifierBuilder.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifierFactory.java
index 3503cd3f..a92bdbfc 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifierBuilder.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifierFactory.java
@@ -17,7 +17,8 @@
package net.momirealms.customfishing.api.mechanic.block;
-public interface BlockStateModifierBuilder {
+@FunctionalInterface
+public interface BlockDataModifierFactory {
- BlockStateModifier build(Object args);
+ BlockDataModifier process(Object args);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockLibrary.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockManager.java
similarity index 63%
rename from api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockLibrary.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockManager.java
index e530a6b9..d6faca80 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockLibrary.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockManager.java
@@ -17,19 +17,20 @@
package net.momirealms.customfishing.api.mechanic.block;
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import net.momirealms.customfishing.common.plugin.feature.Reloadable;
import org.bukkit.block.Block;
-import org.bukkit.block.data.BlockData;
+import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
-import java.util.List;
+public interface BlockManager extends Reloadable {
-public interface BlockLibrary {
+ boolean registerBlock(@NotNull BlockConfig block);
- String identification();
+ @NotNull
+ FallingBlock summonBlockLoot(@NotNull Context context);
- BlockData getBlockData(Player player, String id, List modifiers);
-
- @Nullable
- String getBlockID(Block block);
+ @NotNull
+ String getBlockID(@NotNull Block block);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifier.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifier.java
index 60af5f23..d4007c31 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifier.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifier.java
@@ -17,9 +17,12 @@
package net.momirealms.customfishing.api.mechanic.block;
+import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
+@FunctionalInterface
public interface BlockStateModifier {
- void apply(Player player, BlockState blockState);
+
+ void apply(Context context, BlockState blockState);
}
\ No newline at end of file
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifierBuilder.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifierFactory.java
similarity index 87%
rename from api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifierBuilder.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifierFactory.java
index da0e2e0b..9e95d858 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockDataModifierBuilder.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockStateModifierFactory.java
@@ -17,7 +17,8 @@
package net.momirealms.customfishing.api.mechanic.block;
-public interface BlockDataModifierBuilder {
+@FunctionalInterface
+public interface BlockStateModifierFactory {
- BlockDataModifier build(Object args);
+ BlockStateModifier process(Object args);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/EmptyBlockDataModifier.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/EmptyBlockDataModifier.java
new file mode 100644
index 00000000..b67bd45e
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/EmptyBlockDataModifier.java
@@ -0,0 +1,14 @@
+package net.momirealms.customfishing.api.mechanic.block;
+
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.entity.Player;
+
+public class EmptyBlockDataModifier implements BlockDataModifier {
+
+ public static final BlockDataModifier INSTANCE = new EmptyBlockDataModifier();
+
+ @Override
+ public void apply(Context context, BlockData blockData) {
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/EmptyBlockStateModifier.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/EmptyBlockStateModifier.java
new file mode 100644
index 00000000..68558c7b
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/EmptyBlockStateModifier.java
@@ -0,0 +1,14 @@
+package net.momirealms.customfishing.api.mechanic.block;
+
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import org.bukkit.block.BlockState;
+import org.bukkit.entity.Player;
+
+public class EmptyBlockStateModifier implements BlockStateModifier {
+
+ public static final EmptyBlockStateModifier INSTANCE = new EmptyBlockStateModifier();
+
+ @Override
+ public void apply(Context context, BlockState blockState) {
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/ActionBarConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/ActionBarConfig.java
deleted file mode 100644
index 06a39372..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/ActionBarConfig.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.mechanic.competition;
-
-public class ActionBarConfig extends AbstractCompetitionInfo {
-
- public static class Builder {
-
- private final ActionBarConfig config;
-
- public Builder() {
- this.config = new ActionBarConfig();
- }
-
- public Builder showToAll(boolean showToAll) {
- this.config.showToAll = showToAll;
- return this;
- }
-
- public Builder refreshRate(int rate) {
- this.config.refreshRate = rate;
- return this;
- }
-
- public Builder switchInterval(int interval) {
- this.config.switchInterval = interval;
- return this;
- }
-
- public Builder text(String[] texts) {
- this.config.texts = texts;
- return this;
- }
-
- public ActionBarConfig build() {
- return this.config;
- }
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/BossBarConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/BossBarConfig.java
deleted file mode 100644
index 32458903..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/BossBarConfig.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.mechanic.competition;
-
-import org.bukkit.boss.BarColor;
-
-public class BossBarConfig extends AbstractCompetitionInfo {
-
- private BarColor color;
- private Overlay overlay;
-
- public BarColor getColor() {
- return color;
- }
-
- public Overlay getOverlay() {
- return overlay;
- }
-
- public static class Builder {
-
- private final BossBarConfig config;
-
- public Builder() {
- this.config = new BossBarConfig();
- }
-
- public Builder showToAll(boolean showToAll) {
- this.config.showToAll = showToAll;
- return this;
- }
-
- public Builder refreshRate(int rate) {
- this.config.refreshRate = rate;
- return this;
- }
-
- public Builder switchInterval(int interval) {
- this.config.switchInterval = interval;
- return this;
- }
-
- public Builder text(String[] texts) {
- this.config.texts = texts;
- return this;
- }
-
- public Builder color(BarColor color) {
- this.config.color = color;
- return this;
- }
-
- public Builder overlay(Overlay overlay) {
- this.config.overlay = overlay;
- return this;
- }
-
- public BossBarConfig build() {
- return this.config;
- }
- }
-
- public enum Overlay {
- NOTCHED_6,
- NOTCHED_10,
- NOTCHED_12,
- NOTCHED_20,
- PROGRESS
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfig.java
index adc698a0..4b714582 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfig.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfig.java
@@ -18,178 +18,227 @@
package net.momirealms.customfishing.api.mechanic.competition;
import net.momirealms.customfishing.api.mechanic.action.Action;
+import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfig;
+import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfig;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.bukkit.entity.Player;
import java.util.HashMap;
-public class CompetitionConfig {
+/**
+ * Interface representing the configuration for a fishing competition.
+ */
+public interface CompetitionConfig {
- private final String key;
- private int duration;
- private int minPlayers;
- private BossBarConfig bossBarConfig;
- private ActionBarConfig actionBarConfig;
- private Action[] skipActions;
- private Action[] startActions;
- private Action[] endActions;
- private Action[] joinActions;
- private Requirement[] requirements;
- private CompetitionGoal goal;
- private HashMap rewards;
+ CompetitionGoal DEFAULT_GOAL = CompetitionGoal.CATCH_AMOUNT;
+ int DEFAULT_DURATION = 300;
+ int DEFAULT_MIN_PLAYERS = 0;
+ Requirement[] DEFAULT_REQUIREMENTS = null;
+ Action[] DEFAULT_SKIP_ACTIONS = null;
+ Action[] DEFAULT_START_ACTIONS = null;
+ Action[] DEFAULT_END_ACTIONS = null;
+ Action[] DEFAULT_JOIN_ACTIONS = null;
+ HashMap[]> DEFAULT_REWARDS = new HashMap<>();
- public CompetitionConfig(String key) {
- this.key = key;
- }
+ /**
+ * Gets the unique key for the competition.
+ *
+ * @return the key for the competition.
+ */
+ String key();
- public String getKey() {
- return key;
- }
+ /**
+ * Gets the duration of the competition in seconds.
+ *
+ * @return the duration in seconds.
+ */
+ int durationInSeconds();
- public int getDurationInSeconds() {
- return duration;
- }
+ /**
+ * Gets the minimum number of players required to start the competition.
+ *
+ * @return the minimum number of players.
+ */
+ int minPlayersToStart();
- public int getMinPlayersToStart() {
- return minPlayers;
- }
+ /**
+ * Gets the actions to be performed when the competition starts.
+ *
+ * @return an array of start actions.
+ */
+ Action[] startActions();
- @Nullable
- public Action[] getStartActions() {
- return startActions;
- }
+ /**
+ * Gets the actions to be performed when the competition ends.
+ *
+ * @return an array of end actions.
+ */
+ Action[] endActions();
- @Nullable
- public Action[] getEndActions() {
- return endActions;
+ /**
+ * Gets the actions to be performed when a player joins the competition.
+ *
+ * @return an array of join actions.
+ */
+ Action[] joinActions();
+
+ /**
+ * Gets the actions to be performed when a player skips the competition.
+ *
+ * @return an array of skip actions.
+ */
+ Action[] skipActions();
+
+ /**
+ * Gets the requirements that players must meet to join the competition.
+ *
+ * @return an array of join requirements.
+ */
+ Requirement[] joinRequirements();
+
+ /**
+ * Gets the goal of the competition.
+ *
+ * @return the competition goal.
+ */
+ CompetitionGoal goal();
+
+ /**
+ * Gets the rewards for the competition.
+ *
+ * @return a hashmap where the key is a string identifier and the value is an array of actions.
+ */
+ HashMap[]> rewards();
+
+ /**
+ * Gets the configuration for the boss bar during the competition.
+ *
+ * @return the boss bar configuration.
+ */
+ BossBarConfig bossBarConfig();
+
+ /**
+ * Gets the configuration for the action bar during the competition.
+ *
+ * @return the action bar configuration.
+ */
+ ActionBarConfig actionBarConfig();
+
+ /**
+ * Creates a new builder for the competition configuration.
+ *
+ * @return a new builder instance.
+ */
+ static Builder builder() {
+ return new CompetitionConfigImpl.BuilderImpl();
}
/**
- * Get the actions to perform if player joined the competition
- *
- * @return actions
+ * Builder interface for constructing a CompetitionConfig instance.
*/
- @Nullable
- public Action[] getJoinActions() {
- return joinActions;
- }
+ interface Builder {
- /**
- * Get the actions to perform if the amount of players doesn't meet the requirement
- *
- * @return actions
- */
- @Nullable
- public Action[] getSkipActions() {
- return skipActions;
- }
+ /**
+ * Sets the unique key for the competition.
+ *
+ * @param key the key for the competition.
+ * @return the builder instance.
+ */
+ Builder key(String key);
- /**
- * Get the requirements for participating the competition
- *
- * @return requirements
- */
- @Nullable
- public Requirement[] getRequirements() {
- return requirements;
- }
+ /**
+ * Sets the goal of the competition.
+ *
+ * @param goal the competition goal.
+ * @return the builder instance.
+ */
+ Builder goal(CompetitionGoal goal);
- @NotNull
- public CompetitionGoal getGoal() {
- return goal;
- }
+ /**
+ * Sets the duration of the competition.
+ *
+ * @param duration the duration in seconds.
+ * @return the builder instance.
+ */
+ Builder duration(int duration);
- /**
- * Get the reward map
- *
- * @return reward map
- */
- public HashMap getRewards() {
- return rewards;
- }
+ /**
+ * Sets the minimum number of players required to start the competition.
+ *
+ * @param minPlayers the minimum number of players.
+ * @return the builder instance.
+ */
+ Builder minPlayers(int minPlayers);
- @Nullable
- public BossBarConfig getBossBarConfig() {
- return bossBarConfig;
- }
+ /**
+ * Sets the requirements that players must meet to join the competition.
+ *
+ * @param joinRequirements an array of join requirements.
+ * @return the builder instance.
+ */
+ Builder joinRequirements(Requirement[] joinRequirements);
- @Nullable
- public ActionBarConfig getActionBarConfig() {
- return actionBarConfig;
- }
+ /**
+ * Sets the actions to be performed when a player skips the competition.
+ *
+ * @param skipActions an array of skip actions.
+ * @return the builder instance.
+ */
+ Builder skipActions(Action[] skipActions);
- public static Builder builder(String key) {
- return new Builder(key);
- }
+ /**
+ * Sets the actions to be performed when the competition starts.
+ *
+ * @param startActions an array of start actions.
+ * @return the builder instance.
+ */
+ Builder startActions(Action[] startActions);
- public static class Builder {
+ /**
+ * Sets the actions to be performed when the competition ends.
+ *
+ * @param endActions an array of end actions.
+ * @return the builder instance.
+ */
+ Builder endActions(Action[] endActions);
- private final CompetitionConfig config;
+ /**
+ * Sets the actions to be performed when a player joins the competition.
+ *
+ * @param joinActions an array of join actions.
+ * @return the builder instance.
+ */
+ Builder joinActions(Action[] joinActions);
- public Builder(String key) {
- this.config = new CompetitionConfig(key);
- }
+ /**
+ * Sets the rewards for the competition.
+ *
+ * @param rewards a hashmap where the key is a string identifier and the value is an array of actions.
+ * @return the builder instance.
+ */
+ Builder rewards(HashMap[]> rewards);
- public Builder duration(int duration) {
- config.duration = duration;
- return this;
- }
+ /**
+ * Sets the configuration for the boss bar during the competition.
+ *
+ * @param bossBarConfig the boss bar configuration.
+ * @return the builder instance.
+ */
+ Builder bossBarConfig(BossBarConfig bossBarConfig);
- public Builder minPlayers(int min) {
- config.minPlayers = min;
- return this;
- }
+ /**
+ * Sets the configuration for the action bar during the competition.
+ *
+ * @param actionBarConfig the action bar configuration.
+ * @return the builder instance.
+ */
+ Builder actionBarConfig(ActionBarConfig actionBarConfig);
- public Builder startActions(Action[] startActions) {
- config.startActions = startActions;
- return this;
- }
-
- public Builder endActions(Action[] endActions) {
- config.endActions = endActions;
- return this;
- }
-
- public Builder skipActions(Action[] skipActions) {
- config.skipActions = skipActions;
- return this;
- }
-
- public Builder joinActions(Action[] joinActions) {
- config.joinActions = joinActions;
- return this;
- }
-
- @SuppressWarnings("UnusedReturnValue")
- public Builder actionbar(ActionBarConfig actionBarConfig) {
- config.actionBarConfig = actionBarConfig;
- return this;
- }
-
- @SuppressWarnings("UnusedReturnValue")
- public Builder bossbar(BossBarConfig bossBarConfig) {
- config.bossBarConfig = bossBarConfig;
- return this;
- }
-
- public Builder requirements(Requirement[] requirements) {
- config.requirements = requirements;
- return this;
- }
-
- public Builder goal(CompetitionGoal goal) {
- config.goal = goal;
- return this;
- }
-
- public Builder rewards(HashMap rewards) {
- config.rewards = rewards;
- return this;
- }
-
- public CompetitionConfig build() {
- return config;
- }
+ /**
+ * Builds and returns the CompetitionConfig instance.
+ *
+ * @return the constructed CompetitionConfig instance.
+ */
+ CompetitionConfig build();
}
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfigImpl.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfigImpl.java
new file mode 100644
index 00000000..14bad1e3
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionConfigImpl.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.competition;
+
+import net.momirealms.customfishing.api.mechanic.action.Action;
+import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfig;
+import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfig;
+import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
+import org.bukkit.entity.Player;
+
+import java.util.HashMap;
+
+public class CompetitionConfigImpl implements CompetitionConfig {
+
+ private final String key;
+ private final CompetitionGoal goal;
+ private final int duration;
+ private final int minPlayers;
+ private final Requirement[] joinRequirements;
+ private final Action[] skipActions;
+ private final Action[] startActions;
+ private final Action[] endActions;
+ private final Action[] joinActions;
+ private final HashMap[]> rewards;
+ private final BossBarConfig bossBarConfig;
+ private final ActionBarConfig actionBarConfig;
+
+ public CompetitionConfigImpl(String key, CompetitionGoal goal, int duration, int minPlayers, Requirement[] joinRequirements, Action[] skipActions, Action[] startActions, Action[] endActions, Action[] joinActions, HashMap[]> rewards, BossBarConfig bossBarConfig, ActionBarConfig actionBarConfig) {
+ this.key = key;
+ this.goal = goal;
+ this.duration = duration;
+ this.minPlayers = minPlayers;
+ this.joinRequirements = joinRequirements;
+ this.skipActions = skipActions;
+ this.startActions = startActions;
+ this.endActions = endActions;
+ this.joinActions = joinActions;
+ this.rewards = rewards;
+ this.bossBarConfig = bossBarConfig;
+ this.actionBarConfig = actionBarConfig;
+ }
+
+ @Override
+ public String key() {
+ return key;
+ }
+
+ @Override
+ public int durationInSeconds() {
+ return duration;
+ }
+
+ @Override
+ public int minPlayersToStart() {
+ return minPlayers;
+ }
+
+ @Override
+ public Action[] startActions() {
+ return startActions;
+ }
+
+ @Override
+ public Action[] endActions() {
+ return endActions;
+ }
+
+ @Override
+ public Action[] joinActions() {
+ return joinActions;
+ }
+
+ @Override
+ public Action[] skipActions() {
+ return skipActions;
+ }
+
+ @Override
+ public Requirement[] joinRequirements() {
+ return joinRequirements;
+ }
+
+ @Override
+ public CompetitionGoal goal() {
+ return goal;
+ }
+
+ @Override
+ public HashMap[]> rewards() {
+ return rewards;
+ }
+
+ @Override
+ public BossBarConfig bossBarConfig() {
+ return bossBarConfig;
+ }
+
+ @Override
+ public ActionBarConfig actionBarConfig() {
+ return actionBarConfig;
+ }
+
+ public static class BuilderImpl implements Builder {
+ private String key;
+ private CompetitionGoal goal = DEFAULT_GOAL;
+ private int duration = DEFAULT_DURATION;
+ private int minPlayers = DEFAULT_MIN_PLAYERS;
+ private Requirement[] joinRequirements = DEFAULT_REQUIREMENTS;
+ private Action[] skipActions = DEFAULT_SKIP_ACTIONS;
+ private Action[] startActions = DEFAULT_START_ACTIONS;
+ private Action[] endActions = DEFAULT_END_ACTIONS;
+ private Action[] joinActions = DEFAULT_JOIN_ACTIONS;
+ private HashMap[]> rewards = DEFAULT_REWARDS;
+ private BossBarConfig bossBarConfig;
+ private ActionBarConfig actionBarConfig;
+ @Override
+ public Builder key(String key) {
+ this.key = key;
+ return this;
+ }
+ @Override
+ public Builder goal(CompetitionGoal goal) {
+ this.goal = goal;
+ return this;
+ }
+ @Override
+ public Builder duration(int duration) {
+ this.duration = duration;
+ return this;
+ }
+ @Override
+ public Builder minPlayers(int minPlayers) {
+ this.minPlayers = minPlayers;
+ return this;
+ }
+ @Override
+ public Builder joinRequirements(Requirement[] joinRequirements) {
+ this.joinRequirements = joinRequirements;
+ return this;
+ }
+ @Override
+ public Builder skipActions(Action[] skipActions) {
+ this.skipActions = skipActions;
+ return this;
+ }
+ @Override
+ public Builder startActions(Action[] startActions) {
+ this.startActions = startActions;
+ return this;
+ }
+ @Override
+ public Builder endActions(Action[] endActions) {
+ this.endActions = endActions;
+ return this;
+ }
+ @Override
+ public Builder joinActions(Action[] joinActions) {
+ this.joinActions = joinActions;
+ return this;
+ }
+ @Override
+ public Builder rewards(HashMap[]> rewards) {
+ this.rewards = rewards;
+ return this;
+ }
+ @Override
+ public Builder bossBarConfig(BossBarConfig bossBarConfig) {
+ this.bossBarConfig = bossBarConfig;
+ return this;
+ }
+ @Override
+ public Builder actionBarConfig(ActionBarConfig actionBarConfig) {
+ this.actionBarConfig = actionBarConfig;
+ return this;
+ }
+ @Override
+ public CompetitionConfig build() {
+ return new CompetitionConfigImpl(key, goal, duration, minPlayers, joinRequirements, skipActions, startActions, endActions, joinActions, rewards, bossBarConfig, actionBarConfig);
+ }
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionGoal.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionGoal.java
index 306471a9..7560c7c4 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionGoal.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionGoal.java
@@ -17,17 +17,115 @@
package net.momirealms.customfishing.api.mechanic.competition;
-import java.util.concurrent.ThreadLocalRandom;
+import net.kyori.adventure.util.Index;
+import net.momirealms.customfishing.common.locale.MessageConstants;
+import net.momirealms.customfishing.common.locale.TranslationManager;
+import net.momirealms.customfishing.common.util.RandomUtils;
+import org.apache.logging.log4j.util.Supplier;
+import org.apache.logging.log4j.util.TriConsumer;
+import org.bukkit.entity.Player;
-public enum CompetitionGoal {
+import java.util.Optional;
- CATCH_AMOUNT,
- TOTAL_SCORE,
- MAX_SIZE,
- TOTAL_SIZE,
- RANDOM;
+public final class CompetitionGoal {
+ public static final CompetitionGoal CATCH_AMOUNT = new CompetitionGoal(
+ "catch_amount",
+ ((rankingProvider, player, score) -> rankingProvider.refreshData(player, 1)),
+ () -> Optional.ofNullable(TranslationManager.miniMessageTranslation(MessageConstants.GOAL_CATCH_AMOUNT.build().key())).orElse("catch_amount")
+ );
+ public static final CompetitionGoal TOTAL_SCORE = new CompetitionGoal(
+ "total_score",
+ (RankingProvider::refreshData),
+ () -> Optional.ofNullable(TranslationManager.miniMessageTranslation(MessageConstants.GOAL_TOTAL_SCORE.build().key())).orElse("total_score")
+ );
+ public static final CompetitionGoal MAX_SIZE = new CompetitionGoal(
+ "max_size",
+ ((rankingProvider, player, score) -> {
+ if (rankingProvider.getPlayerScore(player) < score) {
+ rankingProvider.setData(player, score);
+ }
+ }),
+ () -> Optional.ofNullable(TranslationManager.miniMessageTranslation(MessageConstants.GOAL_MAX_SIZE.build().key())).orElse("max_size")
+ );
+ public static final CompetitionGoal MIN_SIZE = new CompetitionGoal(
+ "min_size",
+ ((rankingProvider, player, score) -> {
+ if (rankingProvider.getPlayerScore(player) > score) {
+ rankingProvider.setData(player, score);
+ }
+ }),
+ () -> Optional.ofNullable(TranslationManager.miniMessageTranslation(MessageConstants.GOAL_MIN_SIZE.build().key())).orElse("min_size")
+ );
+ public static final CompetitionGoal TOTAL_SIZE = new CompetitionGoal(
+ "total_size",
+ (RankingProvider::refreshData),
+ () -> Optional.ofNullable(TranslationManager.miniMessageTranslation(MessageConstants.GOAL_TOTAL_SIZE.build().key())).orElse("total_size")
+ );
+ public static final CompetitionGoal RANDOM = new CompetitionGoal(
+ "random",
+ (rankingProvider, player, score) -> {},
+ () -> "random"
+ );
+
+ private static final CompetitionGoal[] values = new CompetitionGoal[] {
+ CATCH_AMOUNT, TOTAL_SCORE, MAX_SIZE, TOTAL_SIZE, RANDOM
+ };
+
+ private static final Index index = Index.create(CompetitionGoal::key, values());
+
+ /**
+ * Gets an array containing all defined competition goals.
+ *
+ * @return An array of all competition goals.
+ */
+ public static CompetitionGoal[] values() {
+ return values;
+ }
+
+ /**
+ * Gets the index of competition goals by their keys.
+ *
+ * @return An index mapping keys to competition goals.
+ */
+ public static Index index() {
+ return index;
+ }
+
+ /**
+ * Gets a randomly selected competition goal.
+ *
+ * @return A randomly selected competition goal.
+ */
public static CompetitionGoal getRandom() {
- return CompetitionGoal.values()[ThreadLocalRandom.current().nextInt(CompetitionGoal.values().length - 1)];
+ return CompetitionGoal.values()[RandomUtils.generateRandomInt(0, values.length - 1)];
+ }
+
+ private final String key;
+ private final TriConsumer scoreConsumer;
+ private final Supplier nameSupplier;
+
+ private CompetitionGoal(String key, TriConsumer scoreConsumer, Supplier nameSupplier) {
+ this.key = key;
+ this.scoreConsumer = scoreConsumer;
+ this.nameSupplier = nameSupplier;
+ }
+
+ /**
+ * Gets the key representing this competition goal.
+ *
+ * @return The key of the competition goal.
+ */
+ public String key() {
+ return key;
+ }
+
+ public void refreshScore(RankingProvider ranking, Player player, Double score) {
+ scoreConsumer.accept(ranking, player.getName(), score);
+ }
+
+ @Override
+ public String toString() {
+ return nameSupplier.get();
}
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionManager.java
new file mode 100644
index 00000000..91efc706
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionManager.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.competition;
+
+import net.momirealms.customfishing.common.plugin.feature.Reloadable;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+public interface CompetitionManager extends Reloadable {
+
+ boolean startCompetition(String competition, boolean force, @Nullable String serverGroup);
+
+ boolean startCompetition(CompetitionConfig config, boolean force, @Nullable String serverGroup);
+
+ @Nullable
+ FishingCompetition getOnGoingCompetition();
+
+ int getNextCompetitionInSeconds();
+
+ @Nullable
+ CompetitionConfig getCompetition(String key);
+
+ Collection getCompetitionIDs();
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionPlayer.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionPlayer.java
index 5a18ef9e..7ae2597c 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionPlayer.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionPlayer.java
@@ -19,52 +19,98 @@ package net.momirealms.customfishing.api.mechanic.competition;
import org.jetbrains.annotations.NotNull;
-public class CompetitionPlayer implements Comparable{
+/**
+ * Represents a player participating in a fishing competition.
+ */
+public class CompetitionPlayer implements Comparable {
- public static CompetitionPlayer empty = new CompetitionPlayer("", 0);
- private long time;
private final String player;
+ private long time;
private double score;
+ /**
+ * Constructs a new CompetitionPlayer with the specified player name and initial score.
+ *
+ * @param player the name of the player.
+ * @param score the initial score of the player.
+ */
public CompetitionPlayer(String player, double score) {
this.player = player;
this.score = score;
this.time = System.currentTimeMillis();
}
- public void addScore(double score){
+ /**
+ * Adds the specified score to the player's current score.
+ * If the added score is positive, updates the player's time to the current time.
+ *
+ * @param score the score to add.
+ */
+ public void addScore(double score) {
this.score += score;
+ if (score <= 0) return;
this.time = System.currentTimeMillis();
}
- public void setScore(double score){
+ /**
+ * Sets the player's score to the specified value and updates the player's time to the current time.
+ *
+ * @param score the new score for the player.
+ */
+ public void setScore(double score) {
this.score = score;
this.time = System.currentTimeMillis();
}
+ /**
+ * Gets the time when the player's score was last updated.
+ *
+ * @return the last update time in milliseconds.
+ */
public long getTime() {
- return time;
+ return this.time;
}
+ /**
+ * Gets the player's current score.
+ *
+ * @return the current score.
+ */
public double getScore() {
return this.score;
}
- public String getPlayer(){
+ /**
+ * Gets the name of the player.
+ *
+ * @return the player's name.
+ */
+ public String getPlayer() {
return this.player;
}
+ /**
+ * Compares this player to another CompetitionPlayer for ordering.
+ * Players are compared first by score, then by time if scores are equal.
+ *
+ * @param another the other player to compare to.
+ */
@Override
- public int compareTo(@NotNull CompetitionPlayer competitionPlayer) {
- if (competitionPlayer.getScore() != this.score) {
- return (competitionPlayer.getScore() > this.score) ? 1 : -1;
- } else if (competitionPlayer.getTime() != this.time) {
- return (competitionPlayer.getTime() > this.time) ? 1 : -1;
+ public int compareTo(@NotNull CompetitionPlayer another) {
+ if (another.getScore() != this.score) {
+ return (another.getScore() > this.score) ? 1 : -1;
+ } else if (another.getTime() != this.time) {
+ return (another.getTime() > this.time) ? 1 : -1;
} else {
return 0;
}
}
+ /**
+ * Returns a string representation of the CompetitionPlayer.
+ *
+ * @return a string containing the player's name, score, and last update time.
+ */
@Override
public String toString() {
return "CompetitionPlayer[" +
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/FishingCompetition.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/FishingCompetition.java
index 1e5d7b1d..f19b46bd 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/FishingCompetition.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/FishingCompetition.java
@@ -17,19 +17,17 @@
package net.momirealms.customfishing.api.mechanic.competition;
+import net.momirealms.customfishing.api.mechanic.context.Context;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Map;
public interface FishingCompetition {
/**
* Start the fishing competition
*/
- void start();
+ void start(boolean triggerEvent);
/**
* Stop the fishing competition
@@ -91,34 +89,29 @@ public interface FishingCompetition {
*
* @return The configuration of the fishing competition.
*/
- @NotNull CompetitionConfig getConfig();
+ @NotNull
+ CompetitionConfig getConfig();
/**
* Gets the goal of the fishing competition.
*
* @return The goal of the fishing competition.
*/
- @NotNull CompetitionGoal getGoal();
+ @NotNull
+ CompetitionGoal getGoal();
/**
* Gets the ranking data for the fishing competition.
*
* @return The ranking data for the fishing competition.
*/
- @NotNull Ranking getRanking();
+ @NotNull
+ RankingProvider getRanking();
/**
- * Gets the cached placeholders for the fishing competition.
+ * Get the public context
*
- * @return A ConcurrentHashMap containing cached placeholders.
+ * @return public context
*/
- @NotNull Map getCachedPlaceholders();
-
- /**
- * Gets a specific cached placeholder value by its key.
- *
- * @param papi The key of the cached placeholder.
- * @return The cached placeholder value as a string, or null if not found.
- */
- @Nullable String getCachedPlaceholder(String papi);
+ Context getPublicContext();
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/Ranking.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/RankingProvider.java
similarity index 94%
rename from api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/Ranking.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/RankingProvider.java
index 728ac725..7a65432e 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/Ranking.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/RankingProvider.java
@@ -17,12 +17,12 @@
package net.momirealms.customfishing.api.mechanic.competition;
-import net.momirealms.customfishing.api.common.Pair;
+import net.momirealms.customfishing.common.util.Pair;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
-public interface Ranking {
+public interface RankingProvider {
/**
* Clears the list of competition players.
@@ -62,9 +62,9 @@ public interface Ranking {
void removePlayer(String player);
/**
- * Returns an iterator for iterating over pairs of player names and scores.
+ * Returns an iterator for iterating over items of player names and scores.
*
- * @return An iterator for pairs of player names and scores.
+ * @return An iterator for items of player names and scores.
*/
Iterator> getIterator();
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/AbstractCompetitionInfo.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/AbstractCompetitionInfo.java
similarity index 71%
rename from api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/AbstractCompetitionInfo.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/AbstractCompetitionInfo.java
index 434395d7..d241e1ac 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/AbstractCompetitionInfo.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/AbstractCompetitionInfo.java
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.mechanic.competition;
+package net.momirealms.customfishing.api.mechanic.competition.info;
/**
* Abstract base class for competition information.
@@ -27,13 +27,22 @@ public abstract class AbstractCompetitionInfo {
protected int switchInterval;
protected boolean showToAll;
protected String[] texts;
+ protected boolean enabled;
+
+ protected AbstractCompetitionInfo(boolean enabled, int refreshRate, int switchInterval, boolean showToAll, String[] texts) {
+ this.refreshRate = refreshRate;
+ this.switchInterval = switchInterval;
+ this.showToAll = showToAll;
+ this.texts = texts;
+ this.enabled = enabled;
+ }
/**
* Get the refresh rate for updating competition information.
*
* @return The refresh rate in ticks.
*/
- public int getRefreshRate() {
+ public int refreshRate() {
return refreshRate;
}
@@ -42,7 +51,7 @@ public abstract class AbstractCompetitionInfo {
*
* @return The switch interval in ticks.
*/
- public int getSwitchInterval() {
+ public int switchInterval() {
return switchInterval;
}
@@ -51,7 +60,7 @@ public abstract class AbstractCompetitionInfo {
*
* @return True if information is shown to all players, otherwise only to participants.
*/
- public boolean isShowToAll() {
+ public boolean showToAll() {
return showToAll;
}
@@ -60,7 +69,16 @@ public abstract class AbstractCompetitionInfo {
*
* @return An array of competition information texts.
*/
- public String[] getTexts() {
+ public String[] texts() {
return texts;
}
+
+ /**
+ * If the feature is enabled.
+ *
+ * @return enabled or not.
+ */
+ public boolean enabled() {
+ return enabled;
+ }
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfig.java
new file mode 100644
index 00000000..08cf314a
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfig.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.competition.info;
+
+public interface ActionBarConfig {
+
+ int DEFAULT_REFRESH_RATE = 20;
+ int DEFAULT_SWITCH_INTERVAL = 200;
+ boolean DEFAULT_VISIBILITY = true;
+ String[] DEFAULT_TEXTS = new String[]{""};
+
+ /**
+ * Get the refresh rate for updating the competition information on the action bar.
+ *
+ * @return The refresh rate in ticks.
+ */
+ int refreshRate();
+
+ /**
+ * Get the switch interval for displaying different competition texts.
+ *
+ * @return The switch interval in ticks.
+ */
+ int switchInterval();
+
+ /**
+ * Check if competition information should be shown to all players.
+ *
+ * @return True if information is shown to all players, otherwise only to participants.
+ */
+ boolean showToAll();
+
+ /**
+ * Get an array of competition information texts.
+ *
+ * @return An array of competition information texts.
+ */
+ String[] texts();
+
+ /**
+ * Is action bar enabled
+ *
+ * @return enabled or not
+ */
+ boolean enabled();
+
+ /**
+ * Creates a new builder instance for constructing {@code ActionBarConfig} objects.
+ *
+ * @return A new {@code Builder} instance.
+ */
+ static Builder builder() {
+ return new ActionBarConfigImpl.BuilderImpl();
+ }
+
+ /**
+ * Builder interface for constructing {@code ActionBarConfig} objects.
+ */
+ interface Builder {
+
+ /**
+ * Sets whether the competition information should be shown to all players.
+ *
+ * @param showToAll True to show information to all players, false to show only to participants.
+ * @return The current {@code Builder} instance.
+ */
+ Builder showToAll(boolean showToAll);
+
+ /**
+ * Sets the refresh rate for updating the competition information.
+ *
+ * @param rate The refresh rate in ticks.
+ * @return The current {@code Builder} instance.
+ */
+ Builder refreshRate(int rate);
+
+ /**
+ * Sets the interval for switching between different competition texts.
+ *
+ * @param interval The switch interval in ticks.
+ * @return The current {@code Builder} instance.
+ */
+ Builder switchInterval(int interval);
+
+ /**
+ * Sets the texts to be displayed on the action bar during the competition.
+ *
+ * @param texts An array of competition information texts.
+ * @return The current {@code Builder} instance.
+ */
+ Builder text(String[] texts);
+
+ Builder enable(boolean enable);
+
+ /**
+ * Builds the {@code ActionBarConfig} object with the configured settings.
+ *
+ * @return The constructed {@code ActionBarConfig} object.
+ */
+ ActionBarConfig build();
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfigImpl.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfigImpl.java
new file mode 100644
index 00000000..b0a359b4
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfigImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.competition.info;
+
+public class ActionBarConfigImpl extends AbstractCompetitionInfo implements ActionBarConfig {
+
+ public ActionBarConfigImpl(boolean enable, int refreshRate, int switchInterval, boolean showToAll, String[] texts) {
+ super(enable, refreshRate, switchInterval, showToAll, texts);
+ }
+
+ public static class BuilderImpl implements Builder {
+ private int refreshRate = DEFAULT_REFRESH_RATE;
+ private int switchInterval = DEFAULT_SWITCH_INTERVAL;
+ private boolean showToAll = DEFAULT_VISIBILITY;
+ private String[] texts = DEFAULT_TEXTS;
+ private boolean enable = true;
+ @Override
+ public Builder showToAll(boolean showToAll) {
+ this.showToAll = showToAll;
+ return this;
+ }
+ @Override
+ public Builder refreshRate(int rate) {
+ this.refreshRate = rate;
+ return this;
+ }
+ @Override
+ public Builder switchInterval(int interval) {
+ this.switchInterval = interval;
+ return this;
+ }
+ @Override
+ public Builder text(String[] texts) {
+ this.texts = texts;
+ return this;
+ }
+ @Override
+ public Builder enable(boolean enable) {
+ this.enable = enable;
+ return this;
+ }
+ @Override
+ public ActionBarConfig build() {
+ return new ActionBarConfigImpl(enable, refreshRate, switchInterval, showToAll, texts);
+ }
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfig.java
new file mode 100644
index 00000000..f1144d27
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfig.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.competition.info;
+
+import net.kyori.adventure.bossbar.BossBar;
+
+public interface BossBarConfig {
+
+ int DEFAULT_REFRESH_RATE = 20;
+ int DEFAULT_SWITCH_INTERVAL = 200;
+ boolean DEFAULT_VISIBILITY = true;
+ String[] DEFAULT_TEXTS = new String[]{""};
+ BossBar.Color DEFAULT_COLOR = BossBar.Color.BLUE;
+ BossBar.Overlay DEFAULT_OVERLAY = BossBar.Overlay.PROGRESS;
+
+ /**
+ * Get the refresh rate for updating competition information.
+ *
+ * @return The refresh rate in ticks.
+ */
+ int refreshRate();
+
+ /**
+ * Get the switch interval for displaying different competition texts.
+ *
+ * @return The switch interval in ticks.
+ */
+ int switchInterval();
+
+ /**
+ * Check if competition information should be shown to all players.
+ *
+ * @return True if information is shown to all players, otherwise only to participants.
+ */
+ boolean showToAll();
+
+ /**
+ * Get an array of competition information texts.
+ *
+ * @return An array of competition information texts.
+ */
+ String[] texts();
+
+ /**
+ * Gets the color of the boss bar.
+ *
+ * @return The color of the boss bar.
+ */
+ BossBar.Color color();
+
+ /**
+ * Gets the overlay style of the boss bar.
+ *
+ * @return The overlay style of the boss bar.
+ */
+ BossBar.Overlay overlay();
+
+ /**
+ * Is boss bar enabled
+ *
+ * @return enabled or not
+ */
+ boolean enabled();
+
+ /**
+ * Creates a new builder instance for constructing {@code BossBarConfig} objects.
+ *
+ * @return A new {@code Builder} instance.
+ */
+ static Builder builder() {
+ return new BossBarConfigImpl.BuilderImpl();
+ }
+
+ /**
+ * Builder interface for constructing {@code BossBarConfig} objects.
+ */
+ interface Builder {
+
+ /**
+ * Sets whether the competition information should be shown to all players.
+ *
+ * @param showToAll True to show information to all players, false to show only to participants.
+ * @return The current {@code Builder} instance.
+ */
+ Builder showToAll(boolean showToAll);
+
+ /**
+ * Sets the refresh rate for updating the competition information.
+ *
+ * @param rate The refresh rate in ticks.
+ * @return The current {@code Builder} instance.
+ */
+ Builder refreshRate(int rate);
+
+ /**
+ * Sets the interval for switching between different competition texts.
+ *
+ * @param interval The switch interval in ticks.
+ * @return The current {@code Builder} instance.
+ */
+ Builder switchInterval(int interval);
+
+ /**
+ * Sets the texts to be displayed on the boss bar during the competition.
+ *
+ * @param texts An array of competition information texts.
+ * @return The current {@code Builder} instance.
+ */
+ Builder text(String[] texts);
+
+ /**
+ * Sets the color of the boss bar.
+ *
+ * @param color The color of the boss bar.
+ * @return The current {@code Builder} instance.
+ */
+ Builder color(BossBar.Color color);
+
+ /**
+ * Sets the overlay style of the boss bar.
+ *
+ * @param overlay The overlay style of the boss bar.
+ * @return The current {@code Builder} instance.
+ */
+ Builder overlay(BossBar.Overlay overlay);
+
+ Builder enable(boolean enable);
+
+ /**
+ * Builds the {@code BossBarConfig} object with the configured settings.
+ *
+ * @return The constructed {@code BossBarConfig} object.
+ */
+ BossBarConfig build();
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfigImpl.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfigImpl.java
new file mode 100644
index 00000000..f2a50971
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfigImpl.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.competition.info;
+
+import net.kyori.adventure.bossbar.BossBar;
+
+public class BossBarConfigImpl extends AbstractCompetitionInfo implements BossBarConfig {
+
+ private final BossBar.Color color;
+ private final BossBar.Overlay overlay;
+
+ public BossBarConfigImpl(boolean enable, int refreshRate, int switchInterval, boolean showToAll, String[] texts, BossBar.Color color, BossBar.Overlay overlay) {
+ super(enable, refreshRate, switchInterval, showToAll, texts);
+ this.color = color;
+ this.overlay = overlay;
+ }
+
+ @Override
+ public BossBar.Color color() {
+ return color;
+ }
+
+ @Override
+ public BossBar.Overlay overlay() {
+ return overlay;
+ }
+
+ public static class BuilderImpl implements Builder {
+ private int refreshRate = DEFAULT_REFRESH_RATE;
+ private int switchInterval = DEFAULT_SWITCH_INTERVAL;
+ private boolean showToAll = DEFAULT_VISIBILITY;
+ private String[] texts = DEFAULT_TEXTS;
+ private BossBar.Overlay overlay = DEFAULT_OVERLAY;
+ private BossBar.Color color = DEFAULT_COLOR;
+ private boolean enable = true;
+ @Override
+ public Builder showToAll(boolean showToAll) {
+ this.showToAll = showToAll;
+ return this;
+ }
+ @Override
+ public Builder refreshRate(int rate) {
+ this.refreshRate = rate;
+ return this;
+ }
+ @Override
+ public Builder switchInterval(int interval) {
+ this.switchInterval = interval;
+ return this;
+ }
+ @Override
+ public Builder text(String[] texts) {
+ this.texts = texts;
+ return this;
+ }
+ @Override
+ public Builder color(BossBar.Color color) {
+ this.color = color;
+ return this;
+ }
+ @Override
+ public Builder overlay(BossBar.Overlay overlay) {
+ this.overlay = overlay;
+ return this;
+ }
+ @Override
+ public Builder enable(boolean enable) {
+ this.enable = enable;
+ return this;
+ }
+ @Override
+ public BossBarConfig build() {
+ return new BossBarConfigImpl(enable, refreshRate, switchInterval, showToAll, texts, color, overlay);
+ }
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/condition/Condition.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/condition/Condition.java
deleted file mode 100644
index 8d41e070..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/condition/Condition.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.mechanic.condition;
-
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents a condition with associated data
- */
-public class Condition {
-
- protected Location location;
- protected final Player player;
- protected final @NotNull Map args;
-
- /**
- * Creates a new Condition object based on a player's location.
- *
- * @param player The player associated with this condition.
- */
- public Condition(@NotNull Player player) {
- this(player.getLocation(), player, new HashMap<>());
- }
-
- /**
- * Creates a new Condition object with specified arguments.
- *
- * @param player The player associated with this condition.
- * @param args A map of arguments associated with this condition.
- */
- public Condition(@NotNull Player player, @NotNull Map args) {
- this(player.getLocation(), player, args);
- }
-
- /**
- * Creates a new Condition object with a specific location, player, and arguments.
- *
- * @param location The location associated with this condition.
- * @param player The player associated with this condition.
- * @param args A map of arguments associated with this condition.
- */
- public Condition(Location location, Player player, @NotNull Map args) {
- this.location = location;
- this.player = player;
- this.args = args;
- if (player != null)
- this.args.put("{player}", player.getName());
- if (location != null) {
- this.args.put("{x}", String.valueOf(location.getX()));
- this.args.put("{y}", String.valueOf(location.getY()));
- this.args.put("{z}", String.valueOf(location.getZ()));
- this.args.put("{world}", location.getWorld().getName());
- }
- }
-
- /**
- * Sets the location associated with this condition.
- *
- * @param location The new location to set.
- */
- public void setLocation(@NotNull Location location) {
- this.location = location;
- this.args.put("{x}", String.valueOf(location.getX()));
- this.args.put("{y}", String.valueOf(location.getY()));
- this.args.put("{z}", String.valueOf(location.getZ()));
- this.args.put("{world}", location.getWorld().getName());
- }
-
- /**
- * Gets the location associated with this condition.
- *
- * @return The location associated with this condition.
- */
- public Location getLocation() {
- return location;
- }
-
- /**
- * Gets the player associated with this condition.
- *
- * @return The player associated with this condition.
- */
- public Player getPlayer() {
- return player;
- }
-
- /**
- * Gets the map of arguments associated with this condition.
- *
- * @return A map of arguments associated with this condition.
- */
- @NotNull
- public Map getArgs() {
- return args;
- }
-
- /**
- * Gets the value of a specific argument by its key.
- *
- * @param key The key of the argument to retrieve.
- * @return The value of the argument or null if not found.
- */
- @Nullable
- public String getArg(String key) {
- return args.get(key);
- }
-
- /**
- * Inserts or updates an argument with the specified key and value.
- *
- * @param key The key of the argument to insert or update.
- * @param value The value to set for the argument.
- */
- public void insertArg(String key, String value) {
- args.put(key, value);
- }
-
- /**
- * Deletes an argument with the specified key.
- *
- * @param key The key of the argument to delete.
- * @return The value of the deleted argument or null if not found.
- */
- public String delArg(String key) {
- return args.remove(key);
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/condition/FishingPreparation.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/condition/FishingPreparation.java
deleted file mode 100644
index 2ce5b509..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/condition/FishingPreparation.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) <2022>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package net.momirealms.customfishing.api.mechanic.condition;
-
-import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
-import net.momirealms.customfishing.api.mechanic.effect.FishingEffect;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public abstract class FishingPreparation extends Condition {
-
- public FishingPreparation(Player player) {
- super(player);
- }
-
- /**
- * Retrieves the ItemStack representing the fishing rod.
- *
- * @return The ItemStack representing the fishing rod.
- */
- @NotNull
- public abstract ItemStack getRodItemStack();
-
- /**
- * Retrieves the ItemStack representing the bait (if available).
- *
- * @return The ItemStack representing the bait, or null if no bait is set.
- */
- @Nullable
- public abstract ItemStack getBaitItemStack();
-
- /**
- * Checks if player meet the requirements for fishing gears
- *
- * @return True if can fish, false otherwise.
- */
- public abstract boolean canFish();
-
- /**
- * Merges a FishingEffect into this fishing rod, applying effect modifiers.
- *
- * @param effect The FishingEffect to merge into this rod.
- */
- public abstract void mergeEffect(FishingEffect effect);
-
- /**
- * Triggers actions associated with a specific action trigger.
- *
- * @param actionTrigger The action trigger that initiates the actions.
- */
- public abstract void triggerActions(ActionTrigger actionTrigger);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/BaitConfigParser.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/BaitConfigParser.java
new file mode 100644
index 00000000..2014af75
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/BaitConfigParser.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) <2022>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.momirealms.customfishing.api.mechanic.config;
+
+import dev.dejvokep.boostedyaml.block.implementation.Section;
+import net.momirealms.customfishing.api.mechanic.MechanicType;
+import net.momirealms.customfishing.api.mechanic.config.function.*;
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
+import net.momirealms.customfishing.api.mechanic.effect.LootBaseEffect;
+import net.momirealms.customfishing.api.mechanic.event.EventCarrier;
+import net.momirealms.customfishing.api.mechanic.item.CustomFishingItem;
+import net.momirealms.customfishing.api.mechanic.loot.Loot;
+import net.momirealms.customfishing.api.mechanic.loot.LootType;
+import net.momirealms.customfishing.common.config.node.Node;
+import net.momirealms.customfishing.common.item.Item;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+public class BaitConfigParser {
+
+ private final String id;
+ private final String material;
+ private final List, Context>>> tagConsumers = new ArrayList<>();
+ private final List> eventBuilderConsumers = new ArrayList<>();
+ private final List> effectBuilderConsumers = new ArrayList<>();
+ private final List> baseEffectBuilderConsumers = new ArrayList<>();
+ private final List> lootBuilderConsumers = new ArrayList<>();
+
+ public BaitConfigParser(String id, Section section, Map> functionMap) {
+ this.id = id;
+ this.material = section.getString("material");
+ if (!section.contains("tag")) section.set("tag", true);
+ analyze(section, functionMap);
+ }
+
+ private void analyze(Section section, Map> functionMap) {
+ Map dataMap = section.getStringRouteMappedValues(false);
+ for (Map.Entry entry : dataMap.entrySet()) {
+ String key = entry.getKey();
+ Node