From 0f7612ae98d8b700b4ab91b33ba77b65e7a6b6dc Mon Sep 17 00:00:00 2001 From: XiaoMoMi <972454774@qq.com> Date: Wed, 3 Apr 2024 20:32:58 +0800 Subject: [PATCH] 2.1.3.1 --- .../customfishing/api/manager/LootManager.java | 4 ++-- build.gradle.kts | 2 +- .../mechanic/fishing/HookCheckTimerTask.java | 5 +---- .../mechanic/item/ItemManagerImpl.java | 4 +--- .../mechanic/loot/LootManagerImpl.java | 14 +++++++------- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java b/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java index 9e7a98c1..75acc6f8 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java +++ b/api/src/main/java/net/momirealms/customfishing/api/manager/LootManager.java @@ -88,9 +88,9 @@ public interface LootManager { /** * Get the next loot item based on fishing effect and condition. * - * @param initialEffect The effect to apply weight modifiers. + * @param effect The effect to apply weight modifiers. * @param condition The condition to determine possible loot. * @return The next loot item, or null if it doesn't exist. */ - @Nullable Loot getNextLoot(Effect initialEffect, Condition condition); + @Nullable Loot getNextLoot(Effect effect, Condition condition); } diff --git a/build.gradle.kts b/build.gradle.kts index aa14178f..23f5a88f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { allprojects { - version = "2.1.3" + version = "2.1.3.1" apply() apply(plugin = "java") 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 718b2436..564e64e3 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 @@ -92,7 +92,6 @@ public class HookCheckTimerTask implements Runnable { this.tempEffect = new FishingEffect(); } - @Override public void run() { if ( @@ -225,13 +224,11 @@ public class HookCheckTimerTask implements Runnable { } private void setNextLoot() { - Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(tempEffect, fishingPreparation); + Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(initialEffect, fishingPreparation); if (nextLoot == null) { this.loot = null; - CustomFishingPlugin.get().debug("No loot available at " + fishingPreparation.getLocation()); return; } - this.loot = nextLoot; } 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 94ca6f81..5890084e 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 @@ -996,11 +996,9 @@ public class ItemManagerImpl implements ItemManager, Listener { } // because the id can be from other plugins, so we can't infer the type of the item - for (String type : List.of("util", "bait", "rod", "hook")) { + for (String type : List.of("util", "bait", "hook")) { EffectCarrier carrier = plugin.getEffectManager().getEffectCarrier(type, id); if (carrier != null) { - if (!RequirementManager.isRequirementMet(condition, carrier.getRequirements())) - return; Action[] actions = carrier.getActions(ActionTrigger.INTERACT); if (actions != null) for (Action action : actions) { diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/loot/LootManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/loot/LootManagerImpl.java index c7cc88cc..d2f0dd86 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/loot/LootManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/loot/LootManagerImpl.java @@ -168,21 +168,21 @@ public class LootManagerImpl implements LootManager { /** * Get a map of possible loot keys with their corresponding weights, considering fishing effect and condition. * - * @param initialEffect The effect to apply weight modifiers. + * @param effect The effect to apply weight modifiers. * @param condition The condition to determine possible loot. * @return A map of loot keys and their weights. */ @NotNull @Override - public Map getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition) { + public Map getPossibleLootKeysWithWeight(Effect effect, Condition condition) { Map lootWithWeight = ((RequirementManagerImpl) plugin.getRequirementManager()).getLootWithWeight(condition); Player player = condition.getPlayer(); - for (Pair pair : initialEffect.getWeightModifier()) { + for (Pair pair : effect.getWeightModifier()) { Double previous = lootWithWeight.get(pair.left()); if (previous != null) lootWithWeight.put(pair.left(), pair.right().modify(player, previous)); } - for (Pair pair : initialEffect.getWeightModifierIgnored()) { + for (Pair pair : effect.getWeightModifierIgnored()) { double previous = lootWithWeight.getOrDefault(pair.left(), 0d); lootWithWeight.put(pair.left(), pair.right().modify(player, previous)); } @@ -192,14 +192,14 @@ public class LootManagerImpl implements LootManager { /** * Get the next loot item based on fishing effect and condition. * - * @param initialEffect The effect to apply weight modifiers. + * @param effect The effect to apply weight modifiers. * @param condition The condition to determine possible loot. * @return The next loot item, or null if it doesn't exist. */ @Override @Nullable - public Loot getNextLoot(Effect initialEffect, Condition condition) { - String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(initialEffect, condition)); + public Loot getNextLoot(Effect effect, Condition condition) { + String key = WeightUtils.getRandom(getPossibleLootKeysWithWeight(effect, condition)); if (key == null) { return null; }