diff --git a/api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java b/api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java index cee14285..649c0612 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java +++ b/api/src/main/java/net/momirealms/customfishing/api/CustomFishingPlugin.java @@ -21,9 +21,11 @@ import net.momirealms.customfishing.api.manager.*; import net.momirealms.customfishing.api.scheduler.Scheduler; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; public abstract class CustomFishingPlugin extends JavaPlugin { + protected boolean initialized; protected Scheduler scheduler; protected CommandManager commandManager; protected VersionManager versionManager; @@ -54,9 +56,10 @@ public abstract class CustomFishingPlugin extends JavaPlugin { } public static CustomFishingPlugin get() { - return instance; + return getInstance(); } + @NotNull public static CustomFishingPlugin getInstance() { return instance; } @@ -145,15 +148,15 @@ public abstract class CustomFishingPlugin extends JavaPlugin { return placeholderManager; } + public CompetitionManager getCompetitionManager() { + return competitionManager; + } + public abstract void reload(); public abstract YamlConfiguration getConfig(String file); public abstract boolean isHookedPluginEnabled(String plugin); - public CompetitionManager getCompetitionManager() { - return competitionManager; - } - public abstract void debug(String message); } diff --git a/api/src/main/java/net/momirealms/customfishing/api/event/CompetitionEvent.java b/api/src/main/java/net/momirealms/customfishing/api/event/CompetitionEvent.java index 26fe2636..76f7e093 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/event/CompetitionEvent.java +++ b/api/src/main/java/net/momirealms/customfishing/api/event/CompetitionEvent.java @@ -1,3 +1,20 @@ +/* + * 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.event; import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition; 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 new file mode 100644 index 00000000..1219d485 --- /dev/null +++ b/api/src/main/java/net/momirealms/customfishing/api/event/CustomFishingReloadEvent.java @@ -0,0 +1,47 @@ +/* + * 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.event; + +import net.momirealms.customfishing.api.CustomFishingPlugin; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +public class CustomFishingReloadEvent extends Event { + + private static final HandlerList handlerList = new HandlerList(); + private final CustomFishingPlugin plugin; + + public CustomFishingReloadEvent(CustomFishingPlugin plugin) { + this.plugin = plugin; + } + + public static HandlerList getHandlerList() { + return handlerList; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return getHandlerList(); + } + + public CustomFishingPlugin getPluginInstance() { + return plugin; + } +} diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/Effect.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/Effect.java index 6247dd41..a0d72540 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/Effect.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/Effect.java @@ -28,15 +28,25 @@ public interface Effect { double getMultipleLootChance(); + double getSize(); + double getSizeMultiplier(); + double getScore(); + double getScoreMultiplier(); - double getHookTimeModifier(); + double getWaitTime(); - double getGameTimeModifier(); + double getWaitTimeMultiplier(); - double getDifficultyModifier(); + double getGameTime(); + + double getGameTimeMultiplier(); + + double getDifficulty(); + + double getDifficultyMultiplier(); List> getWeightModifier(); diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/FishingEffect.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/FishingEffect.java index 1c5125b4..26d0dd5d 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/FishingEffect.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/FishingEffect.java @@ -27,11 +27,17 @@ public class FishingEffect implements Effect { private boolean lavaFishing = false; private double multipleLootChance = 0; + private double waitTime = 0; + private double waitTimeMultiplier = 1; + private double size = 0; private double sizeMultiplier = 1; + private double score = 0; private double scoreMultiplier = 1; - private double hookTimeModifier = 1; - private double difficultyModifier = 0; - private double gameTimeModifier = 0; + private double difficulty = 0; + private double difficultyMultiplier = 1; + private double gameTime = 0; + private double gameTimeMultiplier = 1; + private final List> weightModifier = new ArrayList<>(); private final List> weightModifierIgnored = new ArrayList<>(); @@ -68,6 +74,17 @@ public class FishingEffect implements Effect { return this; } + /** + * Sets the size. + * + * @param size The size value to set. + * @return The FishingEffect instance for method chaining. + */ + public FishingEffect setSize(double size) { + this.size = size; + return this; + } + /** * Sets the score multiplier. * @@ -80,38 +97,83 @@ public class FishingEffect implements Effect { } /** - * Sets the hook time modifier. + * Sets the score * - * @param timeModifier The hook time modifier value to set. + * @param score The score value to set. * @return The FishingEffect instance for method chaining. */ - public FishingEffect setHookTimeModifier(double timeModifier) { - this.hookTimeModifier = timeModifier; + public FishingEffect setScore(double score) { + this.score = score; return this; } /** - * Sets the difficulty modifier. + * Sets the wait time multiplier. * - * @param difficultyModifier The difficulty modifier value to set. + * @param timeMultiplier The wait time multiplier value to set. * @return The FishingEffect instance for method chaining. */ - public FishingEffect setDifficultyModifier(double difficultyModifier) { - this.difficultyModifier = difficultyModifier; + public FishingEffect setWaitTimeMultiplier(double timeMultiplier) { + this.waitTimeMultiplier = timeMultiplier; return this; } /** - * Sets the game time modifier. + * Sets the wait time. * - * @param gameTimeModifier The game time modifier value to set. + * @param waitTime The wait time value to set. * @return The FishingEffect instance for method chaining. */ - public FishingEffect setGameTimeModifier(double gameTimeModifier) { - this.gameTimeModifier = gameTimeModifier; + public FishingEffect setWaitTime(double waitTime) { + this.waitTime = waitTime; return this; } + /** + * Sets the difficulty. + * + * @param difficulty The difficulty value to set. + * @return The FishingEffect instance for method chaining. + */ + public FishingEffect setDifficulty(double difficulty) { + this.difficulty = difficulty; + return this; + } + + /** + * Sets the difficulty multiplier. + * + * @param difficultyMultiplier The difficulty multiplier value to set. + * @return The FishingEffect instance for method chaining. + */ + public FishingEffect setDifficultyMultiplier(double difficultyMultiplier) { + this.difficultyMultiplier = difficultyMultiplier; + return this; + } + + /** + * Sets the game time. + * + * @param gameTime The game time value to set. + * @return The FishingEffect instance for method chaining. + */ + public FishingEffect setGameTime(double gameTime) { + this.gameTime = gameTime; + return this; + } + + /** + * Sets the game time multiplier. + * + * @param gameTimeMultiplier The game time multiplier value to set. + * @return The FishingEffect instance for method chaining. + */ + public FishingEffect setGameTimeMultiplier(double gameTimeMultiplier) { + this.gameTimeMultiplier = gameTimeMultiplier; + return this; + } + + /** * Adds weight modifiers to the FishingEffect. * @@ -164,6 +226,16 @@ public class FishingEffect implements Effect { return sizeMultiplier; } + /** + * Retrieves the size. + * + * @return The size value. + */ + @Override + public double getSize() { + return size; + } + /** * Retrieves the score multiplier. * @@ -175,33 +247,73 @@ public class FishingEffect implements Effect { } /** - * Retrieves the hook time modifier. + * Retrieves the wait time multiplier. * - * @return The hook time modifier value. + * @return The wait time multiplier value. */ @Override - public double getHookTimeModifier() { - return hookTimeModifier; + public double getWaitTimeMultiplier() { + return waitTimeMultiplier; } /** - * Retrieves the game time modifier. + * Retrieves the wait time. * - * @return The game time modifier value. + * @return The wait time . */ @Override - public double getGameTimeModifier() { - return gameTimeModifier; + public double getWaitTime() { + return waitTime; } /** - * Retrieves the difficulty modifier. + * Retrieves the game time. * - * @return The difficulty modifier value. + * @return The game time value. */ @Override - public double getDifficultyModifier() { - return difficultyModifier; + public double getGameTime() { + return gameTime; + } + + /** + * Retrieves the game time multiplier. + * + * @return The game time value multiplier. + */ + @Override + public double getGameTimeMultiplier() { + return gameTimeMultiplier; + } + + /** + * Retrieves score modifier. + * + * @return The score value. + */ + @Override + public double getScore() { + return score; + } + + /** + * Retrieves the difficulty. + * + * @return The difficulty value. + */ + @Override + public double getDifficulty() { + return difficulty; + } + + /** + * Retrieves the difficulty multiplier. + * + * @return The difficulty multiplier value. + */ + @Override + public double getDifficultyMultiplier() { + return difficultyMultiplier; } /** @@ -234,136 +346,16 @@ public class FishingEffect implements Effect { if (another == null) return; if (another.canLavaFishing()) this.lavaFishing = true; this.scoreMultiplier += (another.getScoreMultiplier() -1); + this.score += another.getScore(); this.sizeMultiplier += (another.getSizeMultiplier() -1); - this.hookTimeModifier += (another.getHookTimeModifier() -1); + this.size += another.getSize(); + this.difficultyMultiplier += (another.getDifficultyMultiplier() -1); + this.difficulty += another.getDifficulty(); + this.gameTimeMultiplier += (another.getGameTimeMultiplier() - 1); + this.gameTime += another.getGameTime(); + this.waitTimeMultiplier += (another.getWaitTimeMultiplier() -1); this.multipleLootChance += another.getMultipleLootChance(); - this.difficultyModifier += another.getDifficultyModifier(); - this.gameTimeModifier += another.getGameTimeModifier(); this.weightModifierIgnored.addAll(another.getWeightModifierIgnored()); this.weightModifier.addAll(another.getWeightModifier()); } - - public static Builder builder() { - return new Builder(); - } - - /** - * Builder class for creating instances of the {@link FishingEffect} class with customizable properties. - */ - public static class Builder { - - private final FishingEffect effect; - - public Builder() { - this.effect = new FishingEffect(); - } - - /** - * Adds weight modifiers to the FishingEffect. - * - * @param modifier A list of pairs representing weight modifiers. - * @return The Builder instance for method chaining. - */ - public Builder addWeightModifier(List> modifier) { - effect.weightModifier.addAll(modifier); - return this; - } - - /** - * Adds weight modifiers ignoring conditions to the FishingEffect. - * - * @param modifier A list of pairs representing ignoring conditions weight modifiers. - * @return The Builder instance for method chaining. - */ - public Builder addWeightModifierIgnored(List> modifier) { - effect.weightModifierIgnored.addAll(modifier); - return this; - } - - /** - * Sets the multiple loot chance for the FishingEffect. - * - * @param multipleLootChance The multiple loot chance value to set. - * @return The Builder instance for method chaining. - */ - public Builder multipleLootChance(double multipleLootChance) { - effect.multipleLootChance = multipleLootChance; - return this; - } - - /** - * Sets the difficulty modifier for the FishingEffect. - * - * @param difficultyModifier The difficulty modifier value to set. - * @return The Builder instance for method chaining. - */ - public Builder difficultyModifier(double difficultyModifier) { - effect.difficultyModifier = difficultyModifier; - return this; - } - - /** - * Sets the size multiplier for the FishingEffect. - * - * @param sizeMultiplier The size multiplier value to set. - * @return The Builder instance for method chaining. - */ - public Builder sizeMultiplier(double sizeMultiplier) { - effect.sizeMultiplier = sizeMultiplier; - return this; - } - - /** - * Sets the time modifier for the FishingEffect. - * - * @param timeModifier The time modifier value to set. - * @return The Builder instance for method chaining. - */ - public Builder timeModifier(double timeModifier) { - effect.hookTimeModifier = timeModifier; - return this; - } - - /** - * Sets the score multiplier for the FishingEffect. - * - * @param scoreMultiplier The score multiplier value to set. - * @return The Builder instance for method chaining. - */ - public Builder scoreMultiplier(double scoreMultiplier) { - effect.scoreMultiplier = scoreMultiplier; - return this; - } - - /** - * Sets the game time modifier for the FishingEffect. - * - * @param gameTimeModifier The game time modifier value to set. - * @return The Builder instance for method chaining. - */ - public Builder gameTimeModifier(double gameTimeModifier) { - effect.gameTimeModifier = gameTimeModifier; - return this; - } - - /** - * Sets whether lava fishing is enabled for the FishingEffect. - * - * @param lavaFishing True if lava fishing is enabled, false otherwise. - * @return The Builder instance for method chaining. - */ - public Builder lavaFishing(boolean lavaFishing) { - effect.lavaFishing = lavaFishing; - return this; - } - - /** - * Builds and returns the finalized FishingEffect instance. - * - * @return The created FishingEffect instance. - */ - public FishingEffect build() { - return effect; - } - } } diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/game/BasicGameConfig.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/game/BasicGameConfig.java index ecbba685..5983cc79 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/game/BasicGameConfig.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/game/BasicGameConfig.java @@ -79,8 +79,8 @@ public class BasicGameConfig { @Nullable public GameSettings getGameSetting(Effect effect) { return new GameSettings( - ThreadLocalRandom.current().nextInt(minTime, maxTime + 1) + effect.getGameTimeModifier(), - (int) Math.min(100, Math.max(1, ThreadLocalRandom.current().nextInt(minDifficulty, maxDifficulty + 1) + effect.getDifficultyModifier())) + ThreadLocalRandom.current().nextInt(minTime, maxTime + 1) * effect.getGameTimeMultiplier() + effect.getGameTime(), + (int) Math.min(100, Math.max(1, ThreadLocalRandom.current().nextInt(minDifficulty, maxDifficulty + 1) * effect.getDifficultyMultiplier() + effect.getDifficulty())) ); } } \ No newline at end of file diff --git a/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java b/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java index d57263a2..d86af724 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/CustomFishingPluginImpl.java @@ -23,6 +23,7 @@ import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion; import de.tr7zw.changeme.nbtapi.utils.VersionChecker; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.api.CustomFishingPlugin; +import net.momirealms.customfishing.api.event.CustomFishingReloadEvent; import net.momirealms.customfishing.api.util.LogUtils; import net.momirealms.customfishing.api.util.ReflectionUtils; import net.momirealms.customfishing.command.CommandManagerImpl; @@ -107,6 +108,7 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin { this.hookManager = new HookManagerImpl(this); this.chatCatcherManager = new ChatCatcherManager(this); this.reload(); + super.initialized = true; if (CFConfig.metrics) new Metrics(this, 16648); if (CFConfig.updateChecker) @@ -191,6 +193,9 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin { this.coolDownManager.load(); this.chatCatcherManager.unload(); this.chatCatcherManager.load(); + + CustomFishingReloadEvent event = new CustomFishingReloadEvent(this); + Bukkit.getPluginManager().callEvent(event); } /** diff --git a/plugin/src/main/java/net/momirealms/customfishing/command/sub/CompetitionCommand.java b/plugin/src/main/java/net/momirealms/customfishing/command/sub/CompetitionCommand.java index 9ef24ba6..42b3e887 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/command/sub/CompetitionCommand.java +++ b/plugin/src/main/java/net/momirealms/customfishing/command/sub/CompetitionCommand.java @@ -18,10 +18,7 @@ package net.momirealms.customfishing.command.sub; import dev.jorel.commandapi.CommandAPICommand; -import dev.jorel.commandapi.IStringTooltip; -import dev.jorel.commandapi.StringTooltip; import dev.jorel.commandapi.arguments.ArgumentSuggestions; -import dev.jorel.commandapi.arguments.BooleanArgument; import dev.jorel.commandapi.arguments.StringArgument; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.api.CustomFishingPlugin; diff --git a/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/CFPapi.java b/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/CFPapi.java index 34ffbcee..d57d56e6 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/CFPapi.java +++ b/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/CFPapi.java @@ -20,16 +20,12 @@ package net.momirealms.customfishing.compatibility.papi; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import net.momirealms.customfishing.api.CustomFishingPlugin; import net.momirealms.customfishing.api.data.user.OnlineUser; -import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition; -import net.momirealms.customfishing.setting.CFLocale; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Optional; - public class CFPapi extends PlaceholderExpansion { private final CustomFishingPlugin plugin; diff --git a/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/PlaceholderManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/PlaceholderManagerImpl.java index 493f621b..f607b597 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/PlaceholderManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/compatibility/papi/PlaceholderManagerImpl.java @@ -24,14 +24,12 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; diff --git a/plugin/src/main/java/net/momirealms/customfishing/libraries/libraryloader/LibraryLoader.java b/plugin/src/main/java/net/momirealms/customfishing/libraries/libraryloader/LibraryLoader.java index 3ab873c3..6d913f18 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/libraries/libraryloader/LibraryLoader.java +++ b/plugin/src/main/java/net/momirealms/customfishing/libraries/libraryloader/LibraryLoader.java @@ -27,6 +27,7 @@ package net.momirealms.customfishing.libraries.libraryloader; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; +import net.momirealms.customfishing.CustomFishingPluginImpl; import net.momirealms.customfishing.api.CustomFishingPlugin; import net.momirealms.customfishing.api.util.LogUtils; @@ -46,7 +47,7 @@ import java.util.StringJoiner; public final class LibraryLoader { @SuppressWarnings("Guava") - private static final Supplier URL_INJECTOR = Suppliers.memoize(() -> URLClassLoaderAccess.create((URLClassLoader) CustomFishingPlugin.getInstance().getClass().getClassLoader())); + private static final Supplier URL_INJECTOR = Suppliers.memoize(() -> URLClassLoaderAccess.create((URLClassLoader) CustomFishingPluginImpl.getInstance().getClass().getClassLoader())); /** * Resolves all {@link MavenLibrary} annotations on the given object. diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/bag/BagManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/bag/BagManagerImpl.java index 94d2d5f5..cd9fdf79 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/bag/BagManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/bag/BagManagerImpl.java @@ -42,7 +42,6 @@ import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.UUID; public class BagManagerImpl implements BagManager, Listener { diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/competition/CompetitionManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/competition/CompetitionManagerImpl.java index 4473c0bc..74905853 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/competition/CompetitionManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/competition/CompetitionManagerImpl.java @@ -25,7 +25,6 @@ import net.momirealms.customfishing.api.mechanic.competition.*; import net.momirealms.customfishing.api.mechanic.condition.Condition; import net.momirealms.customfishing.api.scheduler.CancellableTask; import net.momirealms.customfishing.api.util.LogUtils; -import net.momirealms.customfishing.setting.CFConfig; import net.momirealms.customfishing.setting.CFLocale; import net.momirealms.customfishing.storage.method.database.nosql.RedisManager; import net.momirealms.customfishing.util.ConfigUtils; diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/effect/EffectManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/effect/EffectManagerImpl.java index 755293cc..f04d8dcd 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/effect/EffectManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/effect/EffectManagerImpl.java @@ -187,7 +187,7 @@ public class EffectManagerImpl implements EffectManager { @NotNull @Override public FishingEffect getInitialEffect() { - return new FishingEffect.Builder().build(); + return new FishingEffect(); } /** @@ -270,16 +270,28 @@ public class EffectManagerImpl implements EffectManager { effect.addWeightModifierIgnored(modList); }); } - case "hook-time" -> { + case "wait-time" -> { var value = ConfigUtils.getValue(section.get("value")); return ((effect, condition) -> { - effect.setHookTimeModifier(effect.getHookTimeModifier() + value.get(condition.getPlayer()) - 1); + effect.setWaitTime(effect.getWaitTime() + value.get(condition.getPlayer())); + }); + } + case "hook-time", "wait-time-multiplier" -> { + var value = ConfigUtils.getValue(section.get("value")); + return ((effect, condition) -> { + effect.setWaitTimeMultiplier(effect.getWaitTimeMultiplier() + value.get(condition.getPlayer()) - 1); }); } case "difficulty" -> { var value = ConfigUtils.getValue(section.get("value")); return ((effect, condition) -> { - effect.setDifficultyModifier(effect.getDifficultyModifier() + value.get(condition.getPlayer())); + effect.setDifficulty(effect.getDifficulty() + value.get(condition.getPlayer())); + }); + } + case "difficulty-multiplier", "difficulty-bonus" -> { + var value = ConfigUtils.getValue(section.get("value")); + return ((effect, condition) -> { + effect.setDifficultyMultiplier(effect.getDifficultyMultiplier() + value.get(condition.getPlayer()) - 1); }); } case "multiple-loot" -> { @@ -288,13 +300,25 @@ public class EffectManagerImpl implements EffectManager { effect.setMultipleLootChance(effect.getMultipleLootChance() + value.get(condition.getPlayer())); }); } - case "score-bonus" -> { + case "score" -> { + var value = ConfigUtils.getValue(section.get("value")); + return ((effect, condition) -> { + effect.setScore(effect.getScore() + value.get(condition.getPlayer())); + }); + } + case "score-bonus", "score-multiplier" -> { var value = ConfigUtils.getValue(section.get("value")); return ((effect, condition) -> { effect.setScoreMultiplier(effect.getScoreMultiplier() + value.get(condition.getPlayer()) - 1); }); } - case "size-bonus" -> { + case "size" -> { + var value = ConfigUtils.getValue(section.get("value")); + return ((effect, condition) -> { + effect.setSize(effect.getSize() + value.get(condition.getPlayer())); + }); + } + case "size-bonus", "size-multiplier" -> { var value = ConfigUtils.getValue(section.get("value")); return ((effect, condition) -> { effect.setSizeMultiplier(effect.getSizeMultiplier() + value.get(condition.getPlayer()) - 1); @@ -303,7 +327,13 @@ public class EffectManagerImpl implements EffectManager { case "game-time" -> { var value = ConfigUtils.getValue(section.get("value")); return ((effect, condition) -> { - effect.setGameTimeModifier(effect.getGameTimeModifier() + value.get(condition.getPlayer())); + effect.setGameTime(effect.getGameTime() + value.get(condition.getPlayer())); + }); + } + case "game-time-bonus", "game-time-multiplier" -> { + var value = ConfigUtils.getValue(section.get("value")); + return ((effect, condition) -> { + effect.setGameTimeMultiplier(effect.getGameTimeMultiplier() + value.get(condition.getPlayer()) - 1); }); } case "lava-fishing" -> { diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/FishingManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/FishingManagerImpl.java index 357ec408..9baf6d5e 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/FishingManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/FishingManagerImpl.java @@ -302,8 +302,9 @@ public class FishingManagerImpl implements Listener, FishingManager { // Store fishhook entity and apply the effects final FishHook fishHook = event.getHook(); this.hookCacheMap.put(player.getUniqueId(), fishHook); - fishHook.setMaxWaitTime((int) (fishHook.getMaxWaitTime() * initialEffect.getHookTimeModifier())); - fishHook.setMinWaitTime((int) (fishHook.getMinWaitTime() * initialEffect.getHookTimeModifier())); +// fishHook.setMaxWaitTime(Math.max(100, (int) (fishHook.getMaxWaitTime() * initialEffect.getHookTimeModifier()))); +// fishHook.setMinWaitTime(Math.max(100, (int) (fishHook.getMinWaitTime() * initialEffect.getHookTimeModifier()))); + fishHook.setWaitTime(Math.max(1, (int) (fishHook.getWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime()))); // Reduce amount & Send animation var baitItem = fishingPreparation.getBaitItemStack(); if (baitItem != null) { @@ -594,6 +595,7 @@ public class FishingManagerImpl implements Listener, FishingManager { var fishingPreparation = state.getPreparation(); var player = fishingPreparation.getPlayer(); fishingPreparation.insertArg("{size-multiplier}", String.valueOf(effect.getSizeMultiplier())); + fishingPreparation.insertArg("{size-fixed}", String.valueOf(effect.getSize())); int amount; if (loot.getType() == LootType.ITEM) { amount = (int) effect.getMultipleLootChance(); @@ -668,27 +670,27 @@ public class FishingManagerImpl implements Listener, FishingManager { } else { switch (competition.getGoal()) { case CATCH_AMOUNT -> { - double score = effect.getScoreMultiplier(); - fishingPreparation.insertArg("{score}", String.format("%.2f", score)); - competition.refreshData(player, score); + fishingPreparation.insertArg("{score}", "1.00"); + competition.refreshData(player, 1); } case MAX_SIZE, TOTAL_SIZE -> { String size = fishingPreparation.getArg("{size}"); if (size != null) { - double score = Double.parseDouble(size) * effect.getScoreMultiplier(); + double score = Double.parseDouble(size); fishingPreparation.insertArg("{score}", String.format("%.2f", score)); competition.refreshData(player, score); } else { - fishingPreparation.insertArg("{score}", "0"); + fishingPreparation.insertArg("{score}", "0.00"); } } case TOTAL_SCORE -> { double score = loot.getScore(); if (score != 0) { - fishingPreparation.insertArg("{score}", String.format("%.2f", score * effect.getScoreMultiplier())); - competition.refreshData(player, score * effect.getScoreMultiplier()); + double finalScore = score * effect.getScoreMultiplier() + effect.getScore(); + fishingPreparation.insertArg("{score}", String.format("%.2f", finalScore)); + competition.refreshData(player, finalScore); } else { - fishingPreparation.insertArg("{score}", "0"); + fishingPreparation.insertArg("{score}", "0.00"); } } } diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/HookCheckTimerTask.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/HookCheckTimerTask.java index e020d75c..254e1764 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/HookCheckTimerTask.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/HookCheckTimerTask.java @@ -206,7 +206,7 @@ public class HookCheckTimerTask implements Runnable { // get random time int random = ThreadLocalRandom.current().nextInt(CFConfig.lavaMinTime, CFConfig.lavaMaxTime); random -= lureLevel * 100; - random *= initialEffect.getHookTimeModifier(); + random *= initialEffect.getWaitTimeMultiplier(); random = Math.max(CFConfig.lavaMinTime, random); // lava effect task (Three seconds in advance) diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java index de75cee7..596c15c9 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java @@ -670,7 +670,9 @@ public class ItemManagerImpl implements ItemManager, Listener { NBTCompound cfCompound = nbtItem.getOrCreateCompound("CustomFishing"); float random = size.left() + ThreadLocalRandom.current().nextFloat(size.right() - size.left()); float bonus = Float.parseFloat(placeholders.getOrDefault("{size-multiplier}", "1.0")); + double fixed = Double.parseDouble(placeholders.getOrDefault("{size-fixed}", "0.0")); random *= bonus; + random += fixed; cfCompound.setFloat("size", random); placeholders.put("{size}", String.format("%.2f", random)); }); diff --git a/plugin/src/main/java/net/momirealms/customfishing/util/ConfigUtils.java b/plugin/src/main/java/net/momirealms/customfishing/util/ConfigUtils.java index be29aef4..ee679e74 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/util/ConfigUtils.java +++ b/plugin/src/main/java/net/momirealms/customfishing/util/ConfigUtils.java @@ -25,7 +25,6 @@ import net.momirealms.customfishing.compatibility.papi.PlaceholderManagerImpl; import net.momirealms.customfishing.mechanic.misc.value.ExpressionValue; import net.momirealms.customfishing.mechanic.misc.value.PlainValue; import net.momirealms.customfishing.mechanic.misc.value.Value; -import net.objecthunter.exp4j.Expression; import net.objecthunter.exp4j.ExpressionBuilder; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/plugin/src/main/resources/contents/bait/default.yml b/plugin/src/main/resources/contents/bait/default.yml index ae9d3e1b..b2419fe7 100644 --- a/plugin/src/main/resources/contents/bait/default.yml +++ b/plugin/src/main/resources/contents/bait/default.yml @@ -54,13 +54,13 @@ magnetic_bait: - 'can''t help but investigate.' - '' - '<#FFD700>Effects:' - - ' - Reduce hook time' + - ' - Reduce wait time' - ' - More time for fishing' - '' custom-model-data: 50002 effects: hooktime: - type: hook-time + type: wait-time-multiplier value: 0.9 gametime: type: game-time @@ -86,9 +86,9 @@ wild_bait: effects: difficulty: type: difficulty - value: 20 + value: +20 size: - type: size-bonus + type: size-multiplier value: 1.5 gametime: type: game-time diff --git a/plugin/src/main/resources/contents/rod/default.yml b/plugin/src/main/resources/contents/rod/default.yml index bd71091f..163a75ec 100644 --- a/plugin/src/main/resources/contents/rod/default.yml +++ b/plugin/src/main/resources/contents/rod/default.yml @@ -10,7 +10,7 @@ FISHING_ROD: material: fishing_rod effects: time_effect: - type: hook-time + type: wait-time-multiplier value: 1.5 # Custom rods @@ -32,7 +32,7 @@ beginner_rod: max-durability: 64 effects: time_effect: - type: hook-time + type: wait-time-multiplier value: 1.8 difficulty: type: difficulty @@ -176,7 +176,7 @@ magical_rod: value: - enchantments:+10 time_effect: - type: hook-time + type: wait-time-multiplier value: 3 master_rod: @@ -200,7 +200,7 @@ master_rod: max-durability: 128 effects: time_effect: - type: hook-time + type: wait-time-multiplier value: 0.95 difficulty: type: difficulty