diff --git a/README.md b/README.md
index 628c8ebf..e730d763 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
-CustomFishing is a Paper plugin that provides minigames and a powerful condition & action library for fishing.
+CustomFishing is a Paper plugin that provides minigames and a powerful playerContext & action library for fishing.
With the new concept of weight system, CustomFishing brings unlimited customization possibilities and best performance.
## How to build
diff --git a/api/build.gradle.kts b/api/build.gradle.kts
index c4df5e65..6240aca3 100644
--- a/api/build.gradle.kts
+++ b/api/build.gradle.kts
@@ -1,11 +1,44 @@
-dependencies {
- compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
- compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
- compileOnly("de.tr7zw:item-nbt-api:2.12.4")
+plugins {
+ id("io.github.goooler.shadow") version "8.1.7"
}
+repositories {
+ maven("https://repo.codemc.io/repository/maven-public/")
+ maven("https://jitpack.io/")
+}
+
+dependencies {
+ implementation(project(":common"))
+ implementation("dev.dejvokep:boosted-yaml:${rootProject.properties["boosted_yaml_version"]}")
+ implementation("net.kyori:adventure-api:${rootProject.properties["adventure_bundle_version"]}") {
+ exclude(module = "adventure-bom")
+ exclude(module = "checker-qual")
+ exclude(module = "annotations")
+ }
+ implementation("com.saicone.rtag:rtag:1.5.3")
+ implementation("com.saicone.rtag:rtag-item:1.5.3")
+ compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
+ compileOnly("com.google.code.gson:gson:${rootProject.properties["gson_version"]}")
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(17)
+ }
+}
+
+tasks.withType {
+ options.encoding = "UTF-8"
+ options.release.set(17)
+ dependsOn(tasks.clean)
+}
+
+
tasks {
shadowJar {
- relocate ("de.tr7zw.changeme", "net.momirealms.customfishing.libraries")
+ relocate("net.kyori", "net.momirealms.customfishing.libraries")
+ relocate("dev.dejvokep", "net.momirealms.customfishing.libraries")
}
-}
+}
\ No newline at end of file
diff --git a/api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java b/api/src/main/java/net/momirealms/customfishing/api/BukkitCustomFishingPlugin.java
similarity index 66%
rename from api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java
rename to api/src/main/java/net/momirealms/customfishing/api/BukkitCustomFishingPlugin.java
index 649c0612..3e64b622 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/BukkitCustomFishingPlugin.java
@@ -17,17 +17,36 @@
package net.momirealms.customfishing.api;
+import net.momirealms.customfishing.api.integration.IntegrationManager;
import net.momirealms.customfishing.api.manager.*;
-import net.momirealms.customfishing.api.scheduler.Scheduler;
+import net.momirealms.customfishing.api.mechanic.action.ActionManager;
+import net.momirealms.customfishing.api.mechanic.bag.BagManager;
+import net.momirealms.customfishing.api.mechanic.block.BlockManager;
+import net.momirealms.customfishing.api.mechanic.competition.CompetitionManager;
+import net.momirealms.customfishing.api.mechanic.effect.EffectManager;
+import net.momirealms.customfishing.api.mechanic.entity.EntityManager;
+import net.momirealms.customfishing.api.mechanic.fishing.FishingManager;
+import net.momirealms.customfishing.api.mechanic.game.GameManager;
+import net.momirealms.customfishing.api.mechanic.hook.HookManager;
+import net.momirealms.customfishing.api.mechanic.item.ItemManager;
+import net.momirealms.customfishing.api.mechanic.loot.LootManager;
+import net.momirealms.customfishing.api.mechanic.market.MarketManager;
+import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
+import net.momirealms.customfishing.api.mechanic.statistic.StatisticsManager;
+import net.momirealms.customfishing.api.mechanic.totem.TotemManager;
+import net.momirealms.customfishing.common.command.CustomFishingCommandManager;
+import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
+import net.momirealms.customfishing.common.plugin.scheduler.SchedulerAdapter;
+import org.bukkit.Location;
+import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
-import org.jetbrains.annotations.NotNull;
-public abstract class CustomFishingPlugin extends JavaPlugin {
+public abstract class BukkitCustomFishingPlugin extends JavaPlugin implements CustomFishingPlugin {
protected boolean initialized;
- protected Scheduler scheduler;
- protected CommandManager commandManager;
+ protected SchedulerAdapter scheduler;
+ protected CustomFishingCommandManager commandManager;
protected VersionManager versionManager;
protected ItemManager itemManager;
protected RequirementManager requirementManager;
@@ -37,7 +56,6 @@ public abstract class CustomFishingPlugin extends JavaPlugin {
protected EffectManager effectManager;
protected EntityManager entityManager;
protected BlockManager blockManager;
- protected AdventureManager adventure;
protected BagManager bagManager;
protected GameManager gameManager;
protected MarketManager marketManager;
@@ -49,29 +67,20 @@ public abstract class CustomFishingPlugin extends JavaPlugin {
protected TotemManager totemManager;
protected HookManager hookManager;
- private static CustomFishingPlugin instance;
+ private static BukkitCustomFishingPlugin instance;
- public CustomFishingPlugin() {
+ public BukkitCustomFishingPlugin() {
instance = this;
}
- public static CustomFishingPlugin get() {
+ public static BukkitCustomFishingPlugin get() {
return getInstance();
}
- @NotNull
- public static CustomFishingPlugin getInstance() {
+ public static BukkitCustomFishingPlugin getInstance() {
return instance;
}
- public Scheduler getScheduler() {
- return scheduler;
- }
-
- public CommandManager getCommandManager() {
- return commandManager;
- }
-
public VersionManager getVersionManager() {
return versionManager;
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/common/Key.java b/api/src/main/java/net/momirealms/customfishing/api/common/Key.java
deleted file mode 100644
index a276f10c..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/common/Key.java
+++ /dev/null
@@ -1,46 +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.common;
-
-public record Key(String namespace, String value) {
-
- public static Key of(String namespace, String value) {
- return new Key(namespace, value);
- }
-
- @Override
- public int hashCode() {
- int result = this.namespace.hashCode();
- result = (31 * result) + this.value.hashCode();
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Key key)) return false;
- return this.namespace.equals(key.namespace()) && this.value.equals(key.value());
- }
-
- @Override
- public String toString() {
- return namespace + ":" + value;
- }
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/data/LegacyDataStorageInterface.java b/api/src/main/java/net/momirealms/customfishing/api/data/LegacyDataStorageInterface.java
deleted file mode 100644
index 190206bc..00000000
--- a/api/src/main/java/net/momirealms/customfishing/api/data/LegacyDataStorageInterface.java
+++ /dev/null
@@ -1,33 +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.data;
-
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-
-public interface LegacyDataStorageInterface extends DataStorageInterface {
-
- /**
- * Retrieve legacy player data from the SQL database.
- *
- * @param uuid The UUID of the player.
- * @return A CompletableFuture containing the optional legacy player data.
- */
- CompletableFuture> getLegacyPlayerData(UUID uuid);
-}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/event/CustomFishingReloadEvent.java b/api/src/main/java/net/momirealms/customfishing/api/event/CustomFishingReloadEvent.java
index 1219d485..41defa68 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/event/CustomFishingReloadEvent.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/event/CustomFishingReloadEvent.java
@@ -17,7 +17,7 @@
package net.momirealms.customfishing.api.event;
-import net.momirealms.customfishing.api.CustomFishingPlugin;
+import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
@@ -25,9 +25,9 @@ import org.jetbrains.annotations.NotNull;
public class CustomFishingReloadEvent extends Event {
private static final HandlerList handlerList = new HandlerList();
- private final CustomFishingPlugin plugin;
+ private final BukkitCustomFishingPlugin plugin;
- public CustomFishingReloadEvent(CustomFishingPlugin plugin) {
+ public CustomFishingReloadEvent(BukkitCustomFishingPlugin plugin) {
this.plugin = plugin;
}
@@ -41,7 +41,7 @@ public class CustomFishingReloadEvent extends Event {
return getHandlerList();
}
- public CustomFishingPlugin getPluginInstance() {
+ public BukkitCustomFishingPlugin getPluginInstance() {
return plugin;
}
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/event/FishHookLandEvent.java b/api/src/main/java/net/momirealms/customfishing/api/event/FishHookLandEvent.java
index 8adeace1..dc9a1daa 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/event/FishHookLandEvent.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/event/FishHookLandEvent.java
@@ -33,7 +33,7 @@ public class FishHookLandEvent extends PlayerEvent {
private final Target target;
private final FishHook fishHook;
private final Effect effect;
- private boolean isFirst;
+ private final boolean isFirst;
/**
* Constructs a new FishHookLandEvent.
diff --git a/api/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java b/api/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java
index 7d496973..c8980d0d 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java
@@ -17,7 +17,6 @@
package net.momirealms.customfishing.api.event;
-import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
diff --git a/api/src/main/java/net/momirealms/customfishing/api/integration/EnchantmentInterface.java b/api/src/main/java/net/momirealms/customfishing/api/integration/EnchantmentProvider.java
similarity index 81%
rename from api/src/main/java/net/momirealms/customfishing/api/integration/EnchantmentInterface.java
rename to api/src/main/java/net/momirealms/customfishing/api/integration/EnchantmentProvider.java
index 04a92876..5235fab1 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/integration/EnchantmentInterface.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/EnchantmentProvider.java
@@ -17,19 +17,19 @@
package net.momirealms.customfishing.api.integration;
+import net.kyori.adventure.key.Key;
+import net.momirealms.customfishing.common.util.Pair;
import org.bukkit.inventory.ItemStack;
import java.util.List;
-public interface EnchantmentInterface {
+public interface EnchantmentProvider extends ExternalProvider {
/**
* Get a list of enchantments with level for itemStack
- * format: plugin:enchantment:level
- * example: minecraft:sharpness:5
*
* @param itemStack itemStack
* @return enchantment list
*/
- List getEnchants(ItemStack itemStack);
+ List> getEnchants(ItemStack itemStack);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/integration/EntityProvider.java b/api/src/main/java/net/momirealms/customfishing/api/integration/EntityProvider.java
new file mode 100644
index 00000000..9cfea439
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/EntityProvider.java
@@ -0,0 +1,43 @@
+/*
+ * 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.integration;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Entity;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public interface EntityProvider extends ExternalProvider {
+
+ /**
+ * Spawns an entity at the specified location with the given properties.
+ *
+ * @param location The location where the entity will be spawned.
+ * @param id The identifier of the entity to be spawned.
+ * @param propertyMap A map containing additional properties for the entity.
+ * @return The spawned entity.
+ */
+ @NotNull
+ Entity spawn(@NotNull Location location, @NotNull String id, @NotNull Map propertyMap);
+
+ default Entity spawn(@NotNull Location location, @NotNull String id) {
+ return spawn(location, id, new HashMap<>());
+ }
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/integration/ExternalProvider.java b/api/src/main/java/net/momirealms/customfishing/api/integration/ExternalProvider.java
new file mode 100644
index 00000000..778049e7
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/ExternalProvider.java
@@ -0,0 +1,11 @@
+package net.momirealms.customfishing.api.integration;
+
+public interface ExternalProvider {
+
+ /**
+ * Gets the identification of the external provider.
+ *
+ * @return The identification string of the external provider.
+ */
+ String identifier();
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/integration/IntegrationManager.java b/api/src/main/java/net/momirealms/customfishing/api/integration/IntegrationManager.java
new file mode 100644
index 00000000..f5d223a9
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/IntegrationManager.java
@@ -0,0 +1,107 @@
+/*
+ * 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.integration;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Interface for managing integration providers in the custom fishing API.
+ * This allows for the registration and retrieval of various types of providers
+ * such as Leveler, Enchantment, and Season providers.
+ */
+public interface IntegrationManager {
+
+ /**
+ * Registers a LevelerProvider.
+ *
+ * @param level the LevelerProvider to register
+ * @return true if registration is successful, false otherwise
+ */
+ boolean registerLevelerProvider(LevelerProvider level);
+
+ /**
+ * Unregisters a LevelerProvider by its ID.
+ *
+ * @param id the ID of the LevelerProvider to unregister
+ * @return true if unregistration is successful, false otherwise
+ */
+ boolean unregisterLevelerProvider(String id);
+
+ /**
+ * Registers an EnchantmentProvider.
+ *
+ * @param enchantment the EnchantmentProvider to register
+ * @return true if registration is successful, false otherwise
+ */
+ boolean registerEnchantmentProvider(EnchantmentProvider enchantment);
+
+ /**
+ * Unregisters an EnchantmentProvider by its ID.
+ *
+ * @param id the ID of the EnchantmentProvider to unregister
+ * @return true if unregistration is successful, false otherwise
+ */
+ boolean unregisterEnchantmentProvider(String id);
+
+ /**
+ * Registers a SeasonProvider.
+ *
+ * @param season the SeasonProvider to register
+ * @return true if registration is successful, false otherwise
+ */
+ boolean registerSeasonProvider(SeasonProvider season);
+
+ /**
+ * Unregisters a SeasonProvider by its ID.
+ *
+ * @param id the ID of the SeasonProvider to unregister
+ * @return true if unregistration is successful, false otherwise
+ */
+ boolean unregisterSeasonProvider(String id);
+
+ boolean registerEntityProvider(EntityProvider entity);
+
+ boolean unregisterEntityProvider(String identifier);
+
+ /**
+ * Retrieves a registered LevelerProvider by its ID.
+ *
+ * @param id the ID of the LevelerProvider to retrieve
+ * @return the LevelerProvider if found, or null if not found
+ */
+ @Nullable
+ LevelerProvider getLevelerProvider(String id);
+
+ /**
+ * Retrieves a registered EnchantmentProvider by its ID.
+ *
+ * @param id the ID of the EnchantmentProvider to retrieve
+ * @return the EnchantmentProvider if found, or null if not found
+ */
+ @Nullable
+ EnchantmentProvider getEnchantmentProvider(String id);
+
+ /**
+ * Retrieves a registered SeasonProvider by its ID.
+ *
+ * @param id the ID of the SeasonProvider to retrieve
+ * @return the SeasonProvider if found, or null if not found
+ */
+ @Nullable
+ SeasonProvider getSeasonProvider(String id);
+}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/misc/Value.java b/api/src/main/java/net/momirealms/customfishing/api/integration/ItemProvider.java
similarity index 67%
rename from api/src/main/java/net/momirealms/customfishing/api/mechanic/misc/Value.java
rename to api/src/main/java/net/momirealms/customfishing/api/integration/ItemProvider.java
index 1dbea0c4..de13d9d8 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/misc/Value.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/ItemProvider.java
@@ -15,13 +15,18 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.mechanic.misc;
+package net.momirealms.customfishing.api.integration;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.Map;
+public interface ItemProvider extends ExternalProvider {
-public interface Value {
+ @NotNull
+ ItemStack buildItem(Player player, String id);
- double get(Player player, Map values);
+ @Nullable
+ String itemID(ItemStack itemStack);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/integration/LevelInterface.java b/api/src/main/java/net/momirealms/customfishing/api/integration/LevelerProvider.java
similarity index 95%
rename from api/src/main/java/net/momirealms/customfishing/api/integration/LevelInterface.java
rename to api/src/main/java/net/momirealms/customfishing/api/integration/LevelerProvider.java
index da326178..60141114 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/integration/LevelInterface.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/LevelerProvider.java
@@ -19,7 +19,7 @@ package net.momirealms.customfishing.api.integration;
import org.bukkit.entity.Player;
-public interface LevelInterface {
+public interface LevelerProvider extends ExternalProvider {
/**
* Add exp to a certain skill or job
diff --git a/api/src/main/java/net/momirealms/customfishing/api/integration/SeasonInterface.java b/api/src/main/java/net/momirealms/customfishing/api/integration/SeasonProvider.java
similarity index 84%
rename from api/src/main/java/net/momirealms/customfishing/api/integration/SeasonInterface.java
rename to api/src/main/java/net/momirealms/customfishing/api/integration/SeasonProvider.java
index bae8da60..03cb5fb9 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/integration/SeasonInterface.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/integration/SeasonProvider.java
@@ -17,10 +17,11 @@
package net.momirealms.customfishing.api.integration;
+import net.momirealms.customfishing.api.mechanic.misc.season.Season;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
-public interface SeasonInterface {
+public interface SeasonProvider extends ExternalProvider {
/**
* Get a world's season
@@ -28,5 +29,6 @@ public interface SeasonInterface {
* @param world world
* @return spring, summer, autumn, winter or disabled
*/
- @NotNull String getSeason(World world);
+ @NotNull
+ Season getSeason(World world);
}
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/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/VersionManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/VersionManager.java
index ae3d37ba..bb3a0c67 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/VersionManager.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/manager/VersionManager.java
@@ -23,14 +23,16 @@ public interface VersionManager {
boolean isVersionNewerThan1_19();
- boolean isVersionNewerThan1_19_R3();
+ boolean isVersionNewerThan1_19_4();
- boolean isVersionNewerThan1_19_R2();
+ boolean isVersionNewerThan1_19_3();
CompletableFuture checkUpdate();
boolean isVersionNewerThan1_20();
+ boolean isNewerThan1_20_5();
+
boolean isSpigot();
public boolean hasRegionScheduler();
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
index 0192b1d9..bc87b73f 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/GlobalSettings.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/GlobalSettings.java
@@ -17,10 +17,9 @@
package net.momirealms.customfishing.api.mechanic;
-import net.momirealms.customfishing.api.CustomFishingPlugin;
+import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
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;
@@ -47,7 +46,7 @@ public class GlobalSettings {
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);
+ HashMap map = BukkitCustomFishingPlugin.get().getActionManager().getActionMap(inner);
switch (entry.getKey()) {
case "loot" -> lootActions = map;
case "rod" -> rodActions = map;
@@ -79,13 +78,13 @@ public class GlobalSettings {
* 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.
+ * @param playerContext The condition that triggered the actions.
*/
- public static void triggerLootActions(ActionTrigger trigger, Condition condition) {
+ public static void triggerLootActions(ActionTrigger trigger, PlayerContext playerContext) {
Action[] actions = lootActions.get(trigger);
if (actions != null) {
for (Action action : actions) {
- action.trigger(condition);
+ action.trigger(playerContext);
}
}
}
@@ -94,13 +93,13 @@ public class GlobalSettings {
* 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.
+ * @param playerContext The condition that triggered the actions.
*/
- public static void triggerRodActions(ActionTrigger trigger, Condition condition) {
+ public static void triggerRodActions(ActionTrigger trigger, PlayerContext playerContext) {
Action[] actions = rodActions.get(trigger);
if (actions != null) {
for (Action action : actions) {
- action.trigger(condition);
+ action.trigger(playerContext);
}
}
}
@@ -109,13 +108,13 @@ public class GlobalSettings {
* 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.
+ * @param playerContext The condition that triggered the actions.
*/
- public static void triggerBaitActions(ActionTrigger trigger, Condition condition) {
+ public static void triggerBaitActions(ActionTrigger trigger, PlayerContext playerContext) {
Action[] actions = baitActions.get(trigger);
if (actions != null) {
for (Action action : actions) {
- action.trigger(condition);
+ action.trigger(playerContext);
}
}
}
@@ -124,13 +123,13 @@ public class GlobalSettings {
* 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.
+ * @param playerContext The condition that triggered the actions.
*/
- public static void triggerHookActions(ActionTrigger trigger, Condition condition) {
+ public static void triggerHookActions(ActionTrigger trigger, PlayerContext playerContext) {
Action[] actions = hookActions.get(trigger);
if (actions != null) {
for (Action action : actions) {
- action.trigger(condition);
+ action.trigger(playerContext);
}
}
}
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
index 503ef51e..c3e8a898 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/TempFishingState.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/TempFishingState.java
@@ -17,7 +17,6 @@
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;
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..deb59304 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);
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/ActionManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionManager.java
similarity index 80%
rename from api/src/main/java/net/momirealms/customfishing/api/manager/ActionManager.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionManager.java
index 334bd6bf..7ef3913e 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/ActionManager.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/action/ActionManager.java
@@ -15,17 +15,16 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.manager;
+package net.momirealms.customfishing.api.mechanic.action;
-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 dev.dejvokep.boostedyaml.block.implementation.Section;
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
-public interface ActionManager {
+public interface ActionManager {
/**
* Registers an ActionFactory for a specific action type.
@@ -35,7 +34,7 @@ public interface ActionManager {
* @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);
+ boolean registerAction(String type, ActionFactory actionFactory);
/**
* Unregisters an ActionFactory for a specific action type.
@@ -59,7 +58,7 @@ public interface ActionManager {
* @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);
+ Action getAction(Section section);
/**
* Retrieves a mapping of ActionTriggers to arrays of Actions from a ConfigurationSection.
@@ -74,7 +73,7 @@ public interface ActionManager {
* @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);
+ HashMap[]> getActionMap(Section section);
/**
* Retrieves an array of Action objects from a ConfigurationSection.
@@ -89,7 +88,8 @@ public interface ActionManager {
* @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);
+ @NotNull
+ Action[] getActions(@NotNull Section section);
/**
* Retrieves an ActionFactory associated with a specific action type.
@@ -97,7 +97,8 @@ public interface ActionManager {
* @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);
+ @Nullable
+ ActionFactory getActionFactory(@NotNull String type);
/**
* Retrieves a mapping of success times to corresponding arrays of actions from a ConfigurationSection.
@@ -111,18 +112,19 @@ public interface ActionManager {
* @param section The ConfigurationSection containing success times actions.
* @return A HashMap where success times associated with actions.
*/
- HashMap getTimesActionMap(ConfigurationSection section);
+ @NotNull
+ HashMap[]> getTimesActionMap(@NotNull Section 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.
+ * @param context The context associated with the actions.
*/
- static void triggerActions(Condition condition, Action... actions) {
+ static void trigger(@NotNull Context context, @Nullable Action... actions) {
if (actions != null)
- for (Action action : actions)
- action.trigger(condition);
+ for (Action action : actions)
+ action.trigger(context);
}
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/BagManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/BagManager.java
similarity index 96%
rename from api/src/main/java/net/momirealms/customfishing/api/manager/BagManager.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/BagManager.java
index f83c36d2..8e75fe08 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/BagManager.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/bag/BagManager.java
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.manager;
+package net.momirealms.customfishing.api.mechanic.bag;
import net.momirealms.customfishing.api.data.user.OfflineUser;
import net.momirealms.customfishing.api.mechanic.action.Action;
@@ -30,7 +30,7 @@ import java.util.UUID;
public interface BagManager {
/**
- * Is bag enabled
+ * Is bag mechanics enabled
*
* @return enabled or not
*/
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..e2995779 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
@@ -21,5 +21,6 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
public interface BlockDataModifier {
+
void apply(Player player, BlockData blockData);
}
\ No newline at end of file
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/BlockManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockManager.java
similarity index 94%
rename from api/src/main/java/net/momirealms/customfishing/api/manager/BlockManager.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockManager.java
index baa69366..ab99950e 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/BlockManager.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/block/BlockManager.java
@@ -15,11 +15,8 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.manager;
+package net.momirealms.customfishing.api.mechanic.block;
-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;
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..6cd59654 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
@@ -21,5 +21,6 @@ import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
public interface BlockStateModifier {
+
void apply(Player player, BlockState blockState);
}
\ No newline at end of file
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..077d7373 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,6 +18,8 @@
package net.momirealms.customfishing.api.mechanic.competition;
import net.momirealms.customfishing.api.mechanic.action.Action;
+import net.momirealms.customfishing.api.mechanic.competition.info.ActionBarConfigImpl;
+import net.momirealms.customfishing.api.mechanic.competition.info.BossBarConfigImpl;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,8 +31,8 @@ public class CompetitionConfig {
private final String key;
private int duration;
private int minPlayers;
- private BossBarConfig bossBarConfig;
- private ActionBarConfig actionBarConfig;
+ private BossBarConfigImpl bossBarConfigImpl;
+ private ActionBarConfigImpl actionBarConfigImpl;
private Action[] skipActions;
private Action[] startActions;
private Action[] endActions;
@@ -110,13 +112,13 @@ public class CompetitionConfig {
}
@Nullable
- public BossBarConfig getBossBarConfig() {
- return bossBarConfig;
+ public BossBarConfigImpl getBossBarConfig() {
+ return bossBarConfigImpl;
}
@Nullable
- public ActionBarConfig getActionBarConfig() {
- return actionBarConfig;
+ public ActionBarConfigImpl getActionBarConfig() {
+ return actionBarConfigImpl;
}
public static Builder builder(String key) {
@@ -162,14 +164,14 @@ public class CompetitionConfig {
}
@SuppressWarnings("UnusedReturnValue")
- public Builder actionbar(ActionBarConfig actionBarConfig) {
- config.actionBarConfig = actionBarConfig;
+ public Builder actionbar(ActionBarConfigImpl actionBarConfigImpl) {
+ config.actionBarConfigImpl = actionBarConfigImpl;
return this;
}
@SuppressWarnings("UnusedReturnValue")
- public Builder bossbar(BossBarConfig bossBarConfig) {
- config.bossBarConfig = bossBarConfig;
+ public Builder bossbar(BossBarConfigImpl bossBarConfigImpl) {
+ config.bossBarConfigImpl = bossBarConfigImpl;
return this;
}
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..bbb169b6 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,64 @@
package net.momirealms.customfishing.api.mechanic.competition;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.util.Index;
+
import java.util.concurrent.ThreadLocalRandom;
-public enum CompetitionGoal {
+public final class CompetitionGoal {
- CATCH_AMOUNT,
- TOTAL_SCORE,
- MAX_SIZE,
- TOTAL_SIZE,
- RANDOM;
+ public static final CompetitionGoal CATCH_AMOUNT = new CompetitionGoal(Key.key("customfishing", "catch_amount"));
+ public static final CompetitionGoal TOTAL_SCORE = new CompetitionGoal(Key.key("customfishing", "total_score"));
+ public static final CompetitionGoal MAX_SIZE = new CompetitionGoal(Key.key("customfishing", "max_size"));
+ public static final CompetitionGoal TOTAL_SIZE = new CompetitionGoal(Key.key("customfishing", "total_size"));
+ public static final CompetitionGoal RANDOM = new CompetitionGoal(Key.key("customfishing", "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)];
}
+
+ private final Key key;
+
+ private CompetitionGoal(Key key) {
+ this.key = key;
+ }
+
+ /**
+ * Gets the key representing this competition goal.
+ *
+ * @return The key of the competition goal.
+ */
+ public Key key() {
+ return key;
+ }
}
diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/CompetitionManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionManager.java
similarity index 91%
rename from api/src/main/java/net/momirealms/customfishing/api/manager/CompetitionManager.java
rename to api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionManager.java
index d78ade4a..4795d037 100644
--- a/api/src/main/java/net/momirealms/customfishing/api/manager/CompetitionManager.java
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionManager.java
@@ -15,11 +15,8 @@
* along with this program. If not, see .
*/
-package net.momirealms.customfishing.api.manager;
+package net.momirealms.customfishing.api.mechanic.competition;
-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;
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..4463987c 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
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
public class CompetitionPlayer implements Comparable{
- public static CompetitionPlayer empty = new CompetitionPlayer("", 0);
+ private static CompetitionPlayer empty = new CompetitionPlayer("", 0);
private long time;
private final String player;
private double score;
@@ -32,12 +32,13 @@ public class CompetitionPlayer implements Comparable{
this.time = System.currentTimeMillis();
}
- public void addScore(double score){
+ public void addScore(double score) {
this.score += score;
+ if (score <= 0) return;
this.time = System.currentTimeMillis();
}
- public void setScore(double score){
+ public void setScore(double score) {
this.score = score;
this.time = System.currentTimeMillis();
}
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..b2c9a62e 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
@@ -29,7 +29,7 @@ public interface FishingCompetition {
/**
* Start the fishing competition
*/
- void start();
+ void start(boolean triggerEvent);
/**
* Stop the fishing competition
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/Ranking.java
index 728ac725..7adc09a9 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/Ranking.java
@@ -17,7 +17,7 @@
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;
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 78%
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..ecf84ed1 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.
@@ -28,12 +28,19 @@ public abstract class AbstractCompetitionInfo {
protected boolean showToAll;
protected String[] texts;
+ protected AbstractCompetitionInfo(int refreshRate, int switchInterval, boolean showToAll, String[] texts) {
+ this.refreshRate = refreshRate;
+ this.switchInterval = switchInterval;
+ this.showToAll = showToAll;
+ this.texts = texts;
+ }
+
/**
* Get the refresh rate for updating competition information.
*
* @return The refresh rate in ticks.
*/
- public int getRefreshRate() {
+ public int refreshRate() {
return refreshRate;
}
@@ -42,7 +49,7 @@ public abstract class AbstractCompetitionInfo {
*
* @return The switch interval in ticks.
*/
- public int getSwitchInterval() {
+ public int switchInterval() {
return switchInterval;
}
@@ -51,7 +58,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 +67,7 @@ public abstract class AbstractCompetitionInfo {
*
* @return An array of competition information texts.
*/
- public String[] getTexts() {
+ public String[] texts() {
return texts;
}
}
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..b8122d10
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfig.java
@@ -0,0 +1,91 @@
+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();
+
+ /**
+ * 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);
+
+ /**
+ * 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..f7510460
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/ActionBarConfigImpl.java
@@ -0,0 +1,56 @@
+/*
+ * 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(int refreshRate, int switchInterval, boolean showToAll, String[] texts) {
+ super(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;
+ @Override
+ public BuilderImpl showToAll(boolean showToAll) {
+ this.showToAll = showToAll;
+ return this;
+ }
+ @Override
+ public BuilderImpl refreshRate(int rate) {
+ this.refreshRate = rate;
+ return this;
+ }
+ @Override
+ public BuilderImpl switchInterval(int interval) {
+ this.switchInterval = interval;
+ return this;
+ }
+ @Override
+ public BuilderImpl text(String[] texts) {
+ this.texts = texts;
+ return this;
+ }
+ @Override
+ public ActionBarConfigImpl build() {
+ return new ActionBarConfigImpl(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..08c55a0e
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfig.java
@@ -0,0 +1,125 @@
+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();
+
+ /**
+ * 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);
+
+ /**
+ * 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..a00ed7d6
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/info/BossBarConfigImpl.java
@@ -0,0 +1,85 @@
+/*
+ * 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(int refreshRate, int switchInterval, boolean showToAll, String[] texts, BossBar.Color color, BossBar.Overlay overlay) {
+ super(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;
+ public BossBar.Color color = DEFAULT_COLOR;
+ @Override
+ public BuilderImpl showToAll(boolean showToAll) {
+ this.showToAll = showToAll;
+ return this;
+ }
+ @Override
+ public BuilderImpl refreshRate(int rate) {
+ this.refreshRate = rate;
+ return this;
+ }
+ @Override
+ public BuilderImpl switchInterval(int interval) {
+ this.switchInterval = interval;
+ return this;
+ }
+ @Override
+ public BuilderImpl text(String[] texts) {
+ this.texts = texts;
+ return this;
+ }
+ @Override
+ public BuilderImpl color(BossBar.Color color) {
+ this.color = color;
+ return this;
+ }
+ @Override
+ public BuilderImpl overlay(BossBar.Overlay overlay) {
+ this.overlay = overlay;
+ return this;
+ }
+ @Override
+ public BossBarConfigImpl build() {
+ return new BossBarConfigImpl(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/BukkitConfigManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/BukkitConfigManager.java
new file mode 100644
index 00000000..68ca2965
--- /dev/null
+++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/BukkitConfigManager.java
@@ -0,0 +1,163 @@
+package net.momirealms.customfishing.api.mechanic.config;
+
+import dev.dejvokep.boostedyaml.YamlDocument;
+import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning;
+import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings;
+import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
+import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
+import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
+import net.momirealms.customfishing.api.mechanic.context.Context;
+import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
+import net.momirealms.customfishing.api.mechanic.misc.function.FormatFunction;
+import net.momirealms.customfishing.api.mechanic.misc.function.ItemPropertyFunction;
+import net.momirealms.customfishing.api.mechanic.misc.value.MathValue;
+import net.momirealms.customfishing.api.mechanic.misc.value.TextValue;
+import net.momirealms.customfishing.common.config.ConfigManager;
+import net.momirealms.customfishing.common.config.node.Node;
+import net.momirealms.customfishing.common.helper.AdventureHelper;
+import net.momirealms.customfishing.common.item.Item;
+import net.momirealms.customfishing.common.plugin.CustomFishingPlugin;
+import net.momirealms.customfishing.common.util.ListUtils;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
+public class BukkitConfigManager implements ConfigManager {
+
+ private final CustomFishingPlugin plugin;
+
+ private final HashMap> formatFunctions = new HashMap<>();
+
+ public BukkitConfigManager(CustomFishingPlugin plugin) {
+ this.plugin = plugin;
+ this.registerBuiltInItemProperties();
+ }
+
+ private void registerBuiltInItemProperties() {
+ this.registerItemFunction(arg -> {
+ MathValue mathValue = MathValue.auto(arg);
+ return (item, context) -> item.customModelData((int) mathValue.evaluate(context));
+ }, 4000, "custom-model-data");
+ this.registerItemFunction(arg -> {
+ TextValue textValue = TextValue.auto((String) arg);
+ return (item, context) -> {
+ item.displayName(AdventureHelper.miniMessageToJson(textValue.render(context)));
+ };
+ }, 3000, "display", "name");
+ this.registerItemFunction(arg -> {
+ List list = ListUtils.toList(arg);
+ List> lore = new ArrayList<>();
+ for (String text : list) {
+ lore.add(TextValue.auto(text));
+ }
+ return (item, context) -> {
+ item.lore(lore.stream()
+ .map(it -> AdventureHelper.miniMessageToJson(it.render(context)))
+ .toList());
+ };
+ }, 2000, "display", "lore");
+ this.registerItemFunction(arg -> {
+ boolean enable = (boolean) arg;
+ return (item, context) -> {
+ if (!enable) return;
+ item.setTag(context.arg(ContextKeys.ID), "CustomFishing", "id");
+ item.setTag(context.arg(ContextKeys.TYPE), "CustomFishing", "type");
+ };
+ }, 1000, "tag");
+ }
+
+ private void registerItemFunction(Function