mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-03 22:26:15 +00:00
comments
This commit is contained in:
@@ -40,7 +40,7 @@ public interface DataStorageInterface {
|
||||
|
||||
void updateManyPlayersData(Collection<? extends OfflineUser> users, boolean unlock);
|
||||
|
||||
void lockPlayerData(UUID uuid, boolean lock);
|
||||
void lockOrUnlockPlayerData(UUID uuid, boolean lock);
|
||||
|
||||
Set<UUID> getUniqueUsers(boolean legacy);
|
||||
}
|
||||
|
||||
@@ -20,21 +20,106 @@ 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;
|
||||
import java.util.List;
|
||||
|
||||
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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<ActionTrigger, Action[]> 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.
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
ActionFactory getActionBuilder(String type);
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<Integer, Action[]> 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.
|
||||
*/
|
||||
void triggerActions(List<Action> actions, Condition condition);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,22 @@ import org.bukkit.inventory.Inventory;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface BagManager {
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -24,19 +24,82 @@ 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 {
|
||||
boolean registerBlockLibrary(BlockLibrary library);
|
||||
|
||||
boolean unregisterBlockLibrary(BlockLibrary library);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
boolean unregisterBlockLibrary(String library);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
String getAnyBlockID(Block block);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -20,27 +20,67 @@ 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;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface CompetitionManager {
|
||||
Set<String> getAllCompetitions();
|
||||
|
||||
String getCompetitionLocale(CompetitionGoal goal);
|
||||
/**
|
||||
* Retrieves a set of all competition names.
|
||||
*
|
||||
* @return A set of competition names.
|
||||
*/
|
||||
@NotNull Set<String> getAllCompetitionKeys();
|
||||
|
||||
void startCompetition(String competition, boolean force, boolean allServers);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@Nullable
|
||||
FishingCompetition getOnGoingCompetition();
|
||||
/**
|
||||
* 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 allServers 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, boolean allServers);
|
||||
|
||||
void startCompetition(CompetitionConfig config, boolean force, boolean allServers);
|
||||
/**
|
||||
* 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 allServers 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, boolean allServers);
|
||||
|
||||
/**
|
||||
* Gets the number of seconds until the next competition.
|
||||
*
|
||||
* @return The number of seconds until the next competition.
|
||||
*/
|
||||
int getNextCompetitionSeconds();
|
||||
|
||||
CompletableFuture<Integer> getPlayerCount();
|
||||
|
||||
@Nullable
|
||||
CompetitionConfig getConfig(String key);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -19,16 +19,94 @@ package net.momirealms.customfishing.api.manager;
|
||||
|
||||
import net.momirealms.customfishing.api.common.Key;
|
||||
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 {
|
||||
|
||||
boolean registerEffectItem(Key key, EffectCarrier effect);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
boolean unregisterEffectItem(Key key);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@Nullable EffectCarrier getEffect(String namespace, String id);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
FishingEffect getInitialEffect();
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Parses a ConfigurationSection to create an EffectModifier based on the specified type and configuration.
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,29 @@ 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);
|
||||
|
||||
boolean unregisterEntityLibrary(String lib);
|
||||
|
||||
boolean unregisterEntityLibrary(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);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -34,27 +35,84 @@ import java.util.Optional;
|
||||
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);
|
||||
|
||||
void removeHookCheckTask(Player player);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
Optional<FishHook> getHook(UUID uuid);
|
||||
|
||||
void removeTempFishingState(Player player);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
Collection<String> getPossibleLootKeys(Condition condition);
|
||||
|
||||
@NotNull Map<String, Double> getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition);
|
||||
|
||||
Loot getNextLoot(Effect initialEffect, Condition condition);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void 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.
|
||||
*/
|
||||
void 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);
|
||||
}
|
||||
|
||||
@@ -29,14 +29,45 @@ import java.util.Optional;
|
||||
|
||||
public interface GameManager {
|
||||
|
||||
|
||||
/**
|
||||
* Registers a new game type with the specified type identifier.
|
||||
*
|
||||
* @param type The type identifier for the game.
|
||||
* @param gameFactory The {@link GameFactory} that creates instances of the game.
|
||||
* @return {@code true} if the registration was successful, {@code false} if the type identifier is already registered.
|
||||
*/
|
||||
boolean registerGameType(String type, GameFactory gameFactory);
|
||||
|
||||
/**
|
||||
* Unregisters a game type with the specified type identifier.
|
||||
*
|
||||
* @param type The type identifier of the game to unregister.
|
||||
* @return {@code true} if the game type was successfully unregistered, {@code false} if the type identifier was not found.
|
||||
*/
|
||||
boolean unregisterGameType(String type);
|
||||
|
||||
/**
|
||||
* Retrieves the game factory associated with the specified game type.
|
||||
*
|
||||
* @param type The type identifier of the game.
|
||||
* @return The {@code GameFactory} for the specified game type, or {@code null} if not found.
|
||||
*/
|
||||
@Nullable GameFactory getGameFactory(String type);
|
||||
|
||||
Optional<Pair<BasicGameConfig, GameInstance>> getGame(String key);
|
||||
/**
|
||||
* Retrieves a game instance and its basic configuration associated with the specified key.
|
||||
*
|
||||
* @param key The key identifying the game instance.
|
||||
* @return An {@code Optional} containing a {@code Pair} of the basic game configuration and the game instance
|
||||
* if found, or an empty {@code Optional} if not found.
|
||||
*/
|
||||
@Nullable Pair<BasicGameConfig, GameInstance> getGameInstance(String key);
|
||||
|
||||
/**
|
||||
* Retrieves a map of game names and their associated weights based on the specified conditions.
|
||||
*
|
||||
* @param condition The condition to evaluate game weights.
|
||||
* @return A {@code HashMap} containing game names as keys and their associated weights as values.
|
||||
*/
|
||||
HashMap<String, Double> getGameWithWeight(Condition condition);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,61 @@
|
||||
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 {
|
||||
@Nullable
|
||||
HookSetting getHookSetting(String id);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -21,24 +21,81 @@ 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);
|
||||
|
||||
LevelInterface getLevelHook(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);
|
||||
|
||||
List<String> getEnchantments(ItemStack rod);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
SeasonInterface getSeasonInterface();
|
||||
/**
|
||||
* 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<String> 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);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.momirealms.customfishing.api.common.Key;
|
||||
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 net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,45 +33,174 @@ 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<String, String> placeholders);
|
||||
|
||||
@NotNull
|
||||
ItemStack build(Player player, ItemBuilder builder);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
ItemStack buildAnyItemByID(Player player, String id);
|
||||
/**
|
||||
* 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<String, String> placeholders);
|
||||
|
||||
@Nullable
|
||||
String getItemID(ItemStack itemStack);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
String getAnyItemID(ItemStack itemStack);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@Nullable
|
||||
ItemBuilder getItemBuilder(ConfigurationSection section, String type, String id);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
ItemStack build(Player player, ItemBuilder builder, Map<String, String> placeholders);
|
||||
/**
|
||||
* Create a ItemBuilder instance for an item configuration section
|
||||
* <p>
|
||||
* 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<Key> getAllItemsKey();
|
||||
|
||||
boolean registerCustomItem(String namespace, String value, BuildableItem buildableItem);
|
||||
|
||||
boolean unregisterCustomItem(String namespace, String value);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
boolean unRegisterItemLibrary(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);
|
||||
|
||||
boolean unRegisterItemLibrary(String itemLibrary);
|
||||
|
||||
void dropItem(Player player, Location hookLocation, Location playerLocation, Loot loot, Map<String, String> args);
|
||||
/**
|
||||
* 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 id The loot object representing the item to be dropped.
|
||||
* @param args A map of placeholders for item customization.
|
||||
*/
|
||||
void dropItem(Player player, Location hookLocation, Location playerLocation, String id, Map<String, String> args);
|
||||
|
||||
/**
|
||||
* Drops an item entity at the specified location and applies velocity towards another location.
|
||||
*
|
||||
* @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 item stack to be dropped as an entity.
|
||||
*/
|
||||
void dropItem(Location hookLocation, Location playerLocation, ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* 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(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);
|
||||
}
|
||||
|
||||
@@ -18,22 +18,79 @@
|
||||
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<String> 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<String> getAllLootKeys();
|
||||
|
||||
/**
|
||||
* Retrieves a collection of all loot configurations.
|
||||
*
|
||||
* @return A collection of all loot configurations.
|
||||
*/
|
||||
Collection<Loot> 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<String, Double> 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<String> 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<String, Double> getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition);
|
||||
|
||||
/**
|
||||
* Get the next loot item based on fishing effect and condition.
|
||||
*
|
||||
* @param initialEffect 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 initialEffect, Condition condition);
|
||||
}
|
||||
|
||||
@@ -21,15 +21,85 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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 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();
|
||||
|
||||
double getPrice(float base, float bonus, float size);
|
||||
/**
|
||||
* Calculates the price based on a formula with provided variables.
|
||||
*
|
||||
* @param base The base value for the formula.
|
||||
* @param bonus The bonus value for the formula.
|
||||
* @param size The size value for the formula.
|
||||
* @return The calculated price based on the formula and provided variables.
|
||||
*/
|
||||
double getFishPrice(float base, float bonus, float size);
|
||||
|
||||
/**
|
||||
* Gets the character representing the item slot in the MarketGUI.
|
||||
*
|
||||
* @return The item slot character.
|
||||
*/
|
||||
char getItemSlot();
|
||||
|
||||
/**
|
||||
* Gets the character representing the function slot in the MarketGUI.
|
||||
*
|
||||
* @return The function slot character.
|
||||
*/
|
||||
char getFunctionSlot();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Is market enabled
|
||||
*
|
||||
* @return enable or not
|
||||
*/
|
||||
boolean isEnable();
|
||||
}
|
||||
|
||||
@@ -26,17 +26,68 @@ import java.util.Map;
|
||||
|
||||
public interface PlaceholderManager {
|
||||
|
||||
/**
|
||||
* 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<String> 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<String, String> 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<String, String> placeholders);
|
||||
|
||||
String parseCacheable(Player player, String text);
|
||||
|
||||
/**
|
||||
* 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<String> parse(@Nullable OfflinePlayer player, List<String> list, Map<String, String> replacements);
|
||||
|
||||
/**
|
||||
* Parse a text string by replacing placeholders with their corresponding values, using caching for the player's placeholders.
|
||||
*
|
||||
* @param player The player for whom the placeholders are being resolved.
|
||||
* @param text The text string containing placeholders.
|
||||
* @return The text string with placeholders replaced by their values.
|
||||
*/
|
||||
String parseCacheablePlaceholders(Player player, String text);;
|
||||
}
|
||||
|
||||
@@ -21,29 +21,80 @@ 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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface RequirementManager {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
HashMap<String, Double> getLootWithWeight(Condition condition);
|
||||
|
||||
HashMap<String, Double> getGameWithWeight(Condition condition);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
Requirement getRequirement(ConfigurationSection section, boolean checkAction);
|
||||
/**
|
||||
* Retrieves a Requirement object based on a configuration section and advanced flag.
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
Requirement getRequirement(String key, Object value);
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
RequirementFactory getRequirementBuilder(String type);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
static boolean isRequirementsMet(Requirement[] requirements, Condition condition) {
|
||||
/**
|
||||
* 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)) {
|
||||
@@ -52,9 +103,4 @@ public interface RequirementManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean isRequirementMet(Requirement requirement, Condition condition) {
|
||||
if (requirement == null) return true;
|
||||
return requirement.isConditionMet(condition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,20 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface StatisticsManager {
|
||||
Statistics getStatistics(UUID uuid);
|
||||
|
||||
/**
|
||||
* 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<String> getCategory(String key);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ 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.Optional;
|
||||
import java.util.UUID;
|
||||
@@ -30,49 +31,93 @@ import java.util.concurrent.CompletableFuture;
|
||||
public interface StorageManager {
|
||||
|
||||
/**
|
||||
* Get server unique id
|
||||
* @return id
|
||||
* Gets the unique server identifier.
|
||||
*
|
||||
* @return The unique server identifier.
|
||||
*/
|
||||
String getUniqueID();
|
||||
@NotNull String getUniqueID();
|
||||
|
||||
/**
|
||||
* Get online user's data
|
||||
* @param uuid uuid
|
||||
* @return online user data
|
||||
* 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.
|
||||
*/
|
||||
OnlineUser getOnlineUser(UUID uuid);
|
||||
@Nullable OnlineUser getOnlineUser(UUID uuid);
|
||||
|
||||
/**
|
||||
* Get an offline user's data
|
||||
* Otherwise it would return Optional.empty() if data is locked
|
||||
* It an offline user never played the server, its name would equal "" (empty string)
|
||||
* @param uuid uuid
|
||||
* @param lock lock
|
||||
* @return offline user data
|
||||
* 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<Optional<OfflineUser>> 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<Boolean> saveUserData(OfflineUser offlineUser, boolean unlock);
|
||||
|
||||
/**
|
||||
* Get all the players in servers that connected to the same redis server
|
||||
* @return amount
|
||||
*/
|
||||
CompletableFuture<Integer> getRedisPlayerCount();
|
||||
|
||||
/**
|
||||
* Get plugin data source
|
||||
* @return data source
|
||||
* 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();
|
||||
|
||||
byte[] toBytes(@NotNull PlayerData data);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
PlayerData fromJson(String json);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -21,5 +21,12 @@ 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);
|
||||
}
|
||||
|
||||
@@ -17,25 +17,49 @@
|
||||
|
||||
package net.momirealms.customfishing.api.mechanic.competition;
|
||||
|
||||
/**
|
||||
* Abstract base class for competition information.
|
||||
* Contains common properties and methods for competition info.
|
||||
*/
|
||||
public abstract class AbstractCompetitionInfo {
|
||||
|
||||
|
||||
protected int refreshRate;
|
||||
protected int switchInterval;
|
||||
protected boolean showToAll;
|
||||
protected String[] texts;
|
||||
|
||||
/**
|
||||
* Get the refresh rate for updating competition information.
|
||||
*
|
||||
* @return The refresh rate in ticks.
|
||||
*/
|
||||
public int getRefreshRate() {
|
||||
return refreshRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the switch interval for displaying different competition texts.
|
||||
*
|
||||
* @return The switch interval in ticks.
|
||||
*/
|
||||
public int getSwitchInterval() {
|
||||
return switchInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if competition information should be shown to all players.
|
||||
*
|
||||
* @return True if information is shown to all players, otherwise only to participants.
|
||||
*/
|
||||
public boolean isShowToAll() {
|
||||
return showToAll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of competition information texts.
|
||||
*
|
||||
* @return An array of competition information texts.
|
||||
*/
|
||||
public String[] getTexts() {
|
||||
return texts;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customfishing.api.mechanic.competition;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -43,11 +44,11 @@ public class CompetitionConfig {
|
||||
return key;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
public int getDurationInSeconds() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public int getMinPlayers() {
|
||||
public int getMinPlayersToStart() {
|
||||
return minPlayers;
|
||||
}
|
||||
|
||||
@@ -59,10 +60,20 @@ public class CompetitionConfig {
|
||||
return endActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions to perform if player joined the competition
|
||||
*
|
||||
* @return actions
|
||||
*/
|
||||
public Action[] getJoinActions() {
|
||||
return joinActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions to perform if the amount of players doesn't meet the requirement
|
||||
*
|
||||
* @return actions
|
||||
*/
|
||||
public Action[] getSkipActions() {
|
||||
return skipActions;
|
||||
}
|
||||
@@ -71,18 +82,29 @@ public class CompetitionConfig {
|
||||
return goal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reward map
|
||||
*
|
||||
* @return reward map
|
||||
*/
|
||||
public HashMap<String, Action[]> getRewards() {
|
||||
return rewards;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BossBarConfig getBossBarConfig() {
|
||||
return bossBarConfig;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ActionBarConfig getActionBarConfig() {
|
||||
return actionBarConfig;
|
||||
}
|
||||
|
||||
public static Builder builder(String key) {
|
||||
return new Builder(key);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final CompetitionConfig config;
|
||||
@@ -121,11 +143,13 @@ public class CompetitionConfig {
|
||||
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;
|
||||
|
||||
@@ -19,35 +19,106 @@ package net.momirealms.customfishing.api.mechanic.competition;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FishingCompetition {
|
||||
|
||||
/**
|
||||
* Start the fishing competition
|
||||
*/
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Stop the fishing competition
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* End the fishing competition
|
||||
*/
|
||||
void end();
|
||||
|
||||
/**
|
||||
* Check if the fishing competition is ongoing.
|
||||
*
|
||||
* @return {@code true} if the competition is still ongoing, {@code false} if it has ended.
|
||||
*/
|
||||
boolean isOnGoing();
|
||||
|
||||
/**
|
||||
* Refreshes the data for a player in the fishing competition, including updating their score and triggering
|
||||
* actions if it's their first time joining the competition.
|
||||
*
|
||||
* @param player The player whose data needs to be refreshed.
|
||||
* @param score The player's current score in the competition.
|
||||
*/
|
||||
void refreshData(Player player, double score);
|
||||
|
||||
/**
|
||||
* Checks if a player has joined the fishing competition based on their name.
|
||||
*
|
||||
* @param player The player to check for participation.
|
||||
* @return {@code true} if the player has joined the competition; {@code false} otherwise.
|
||||
*/
|
||||
boolean hasPlayerJoined(OfflinePlayer player);
|
||||
|
||||
/**
|
||||
* Gets the progress of the fishing competition as a float value (0~1).
|
||||
*
|
||||
* @return The progress of the fishing competition as a float.
|
||||
*/
|
||||
float getProgress();
|
||||
|
||||
/**
|
||||
* Gets the remaining time in seconds for the fishing competition.
|
||||
*
|
||||
* @return The remaining time in seconds.
|
||||
*/
|
||||
long getRemainingTime();
|
||||
|
||||
/**
|
||||
* Gets the start time of the fishing competition.
|
||||
*
|
||||
* @return The start time of the fishing competition.
|
||||
*/
|
||||
long getStartTime();
|
||||
|
||||
CompetitionConfig getConfig();
|
||||
/**
|
||||
* Gets the configuration of the fishing competition.
|
||||
*
|
||||
* @return The configuration of the fishing competition.
|
||||
*/
|
||||
@NotNull CompetitionConfig getConfig();
|
||||
|
||||
CompetitionGoal getGoal();
|
||||
/**
|
||||
* Gets the goal of the fishing competition.
|
||||
*
|
||||
* @return The goal of the fishing competition.
|
||||
*/
|
||||
@NotNull CompetitionGoal getGoal();
|
||||
|
||||
Ranking getRanking();
|
||||
/**
|
||||
* Gets the ranking data for the fishing competition.
|
||||
*
|
||||
* @return The ranking data for the fishing competition.
|
||||
*/
|
||||
@NotNull Ranking getRanking();
|
||||
|
||||
ConcurrentHashMap<String, String> getCachedPlaceholders();
|
||||
/**
|
||||
* Gets the cached placeholders for the fishing competition.
|
||||
*
|
||||
* @return A ConcurrentHashMap containing cached placeholders.
|
||||
*/
|
||||
@NotNull Map<String, String> getCachedPlaceholders();
|
||||
|
||||
String getCachedPlaceholder(String papi);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ public class FishingPreparation extends Condition {
|
||||
this.effects = new ArrayList<>();
|
||||
boolean rodOnMainHand = mainHandItem.getType() == Material.FISHING_ROD;
|
||||
this.rodItemStack = rodOnMainHand ? mainHandItem : offHandItem;
|
||||
String rodItemID = plugin.getItemManager().getAnyItemID(this.rodItemStack);
|
||||
EffectCarrier rodEffect = plugin.getEffectManager().getEffect("rod", rodItemID);
|
||||
String rodItemID = plugin.getItemManager().getAnyPluginItemID(this.rodItemStack);
|
||||
EffectCarrier rodEffect = plugin.getEffectManager().getEffectCarrier("rod", rodItemID);
|
||||
if (rodEffect != null) effects.add(rodEffect);
|
||||
super.insertArg("{rod}", rodItemID);
|
||||
|
||||
@@ -66,14 +66,14 @@ public class FishingPreparation extends Condition {
|
||||
if (cfCompound != null && cfCompound.hasTag("hook_id")) {
|
||||
String hookID = cfCompound.getString("hook_id");
|
||||
super.insertArg("{hook}", rodItemID);
|
||||
EffectCarrier carrier = plugin.getEffectManager().getEffect("hook", hookID);
|
||||
EffectCarrier carrier = plugin.getEffectManager().getEffectCarrier("hook", hookID);
|
||||
if (carrier != null) {
|
||||
this.effects.add(carrier);
|
||||
}
|
||||
}
|
||||
|
||||
String baitItemID = plugin.getItemManager().getAnyItemID(rodOnMainHand ? offHandItem : mainHandItem);
|
||||
EffectCarrier baitEffect = plugin.getEffectManager().getEffect("bait", baitItemID);
|
||||
String baitItemID = plugin.getItemManager().getAnyPluginItemID(rodOnMainHand ? offHandItem : mainHandItem);
|
||||
EffectCarrier baitEffect = plugin.getEffectManager().getEffectCarrier("bait", baitItemID);
|
||||
|
||||
if (baitEffect != null) {
|
||||
this.baitItemStack = rodOnMainHand ? offHandItem : mainHandItem;
|
||||
@@ -89,10 +89,10 @@ public class FishingPreparation extends Condition {
|
||||
this.insertArg("{in-bag}", "true");
|
||||
for (int i = 0; i < fishingBag.getSize(); i++) {
|
||||
ItemStack itemInBag = fishingBag.getItem(i);
|
||||
String bagItemID = plugin.getItemManager().getItemID(itemInBag);
|
||||
String bagItemID = plugin.getItemManager().getCustomFishingItemID(itemInBag);
|
||||
if (bagItemID == null) continue;
|
||||
if (!hasBait) {
|
||||
EffectCarrier effect = plugin.getEffectManager().getEffect("bait", bagItemID);
|
||||
EffectCarrier effect = plugin.getEffectManager().getEffectCarrier("bait", bagItemID);
|
||||
if (effect != null) {
|
||||
this.baitItemStack = itemInBag;
|
||||
this.effects.add(effect);
|
||||
@@ -100,7 +100,7 @@ public class FishingPreparation extends Condition {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
EffectCarrier utilEffect = plugin.getEffectManager().getEffect("util", bagItemID);
|
||||
EffectCarrier utilEffect = plugin.getEffectManager().getEffectCarrier("util", bagItemID);
|
||||
if (utilEffect != null && !uniqueUtils.contains(bagItemID)) {
|
||||
effects.add(utilEffect);
|
||||
uniqueUtils.add(bagItemID);
|
||||
@@ -111,7 +111,7 @@ public class FishingPreparation extends Condition {
|
||||
}
|
||||
|
||||
for (String enchant : plugin.getIntegrationManager().getEnchantments(rodItemStack)) {
|
||||
EffectCarrier enchantEffect = plugin.getEffectManager().getEffect("enchant", enchant);
|
||||
EffectCarrier enchantEffect = plugin.getEffectManager().getEffectCarrier("enchant", enchant);
|
||||
if (enchantEffect != null) {
|
||||
this.effects.add(enchantEffect);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ public class BasicGameConfig {
|
||||
private int minDifficulty;
|
||||
private int maxDifficulty;
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final BasicGameConfig basicGameConfig;
|
||||
@@ -37,11 +41,13 @@ public class BasicGameConfig {
|
||||
basicGameConfig = new BasicGameConfig();
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public Builder difficulty(int value) {
|
||||
basicGameConfig.minDifficulty = (basicGameConfig.maxDifficulty = value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public Builder difficulty(int min, int max) {
|
||||
basicGameConfig.minDifficulty = min;
|
||||
basicGameConfig.maxDifficulty = max;
|
||||
@@ -64,6 +70,12 @@ public class BasicGameConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates random game settings based on specified time and difficulty ranges, adjusted by an effect's difficulty modifier.
|
||||
*
|
||||
* @param effect The effect to adjust the difficulty.
|
||||
* @return A {@link GameSettings} object representing the generated game settings.
|
||||
*/
|
||||
@Nullable
|
||||
public GameSettings getGameSetting(Effect effect) {
|
||||
return new GameSettings(
|
||||
|
||||
@@ -19,24 +19,46 @@ package net.momirealms.customfishing.api.mechanic.game;
|
||||
|
||||
import net.momirealms.customfishing.api.mechanic.effect.Effect;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface GamingPlayer {
|
||||
|
||||
/**
|
||||
* Cancel the game
|
||||
*/
|
||||
void cancel();
|
||||
|
||||
boolean isSuccessful();
|
||||
|
||||
/**
|
||||
* @return whether to cancel the event
|
||||
*/
|
||||
boolean onRightClick();
|
||||
|
||||
/**
|
||||
* @return whether to cancel the event
|
||||
*/
|
||||
boolean onLeftClick();
|
||||
|
||||
/**
|
||||
* @return whether to cancel the event
|
||||
*/
|
||||
boolean onSwapHand();
|
||||
|
||||
/**
|
||||
* @return whether to cancel the event
|
||||
*/
|
||||
boolean onChat(String message);
|
||||
|
||||
/**
|
||||
* @return whether to cancel the event
|
||||
*/
|
||||
boolean onJump();
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
Effect getEffectReward();
|
||||
|
||||
boolean onChat(String message);
|
||||
/**
|
||||
* @return effect reward based on game results
|
||||
*/
|
||||
@Nullable Effect getEffectReward();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user