9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

add first capture condition

This commit is contained in:
XiaoMoMi
2025-10-29 02:47:24 +08:00
parent 5a0b54a572
commit 7841a95166
5 changed files with 22 additions and 3 deletions

View File

@@ -96,6 +96,7 @@ public class ContextKeys<T> {
public static final ContextKeys<Double> BASE = of("base", Double.class);
public static final ContextKeys<Integer> LOOT_ORDER = of("loot_order", Integer.class);
public static final ContextKeys<Effect> EFFECT = of("effect", Effect.class);
public static final ContextKeys<Boolean> FIRST_CAPTURE = of("first_capture", Boolean.class);
private final String key;
private final Class<T> type;

View File

@@ -623,6 +623,10 @@ public class CustomFishingHook {
if (!nextLoot.disableStats()) {
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresent(
userData -> {
int amount = userData.statistics().getAmount(nextLoot.statisticKey().amountKey());
if (amount == 0) {
context.arg(ContextKeys.FIRST_CAPTURE, true);
}
Pair<Integer, Integer> result = userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1);
context.arg(ContextKeys.TOTAL_AMOUNT, userData.statistics().getAmount(nextLoot.statisticKey().amountKey()));
Optional.ofNullable(context.arg(ContextKeys.SIZE)).ifPresentOrElse(size -> {

View File

@@ -113,7 +113,7 @@ public class VanillaMechanic implements HookMechanic {
if (player.isOnline() && hook.isValid()) {
AntiAutoFishing.prevent(player, hook);
}
}, RandomUtils.generateRandomInt(20, SparrowHeart.getInstance().getWaitTime(hook) + lureTime - 5), hook.getLocation());
}, RandomUtils.generateRandomInt(20, Math.max(20, SparrowHeart.getInstance().getWaitTime(hook) + lureTime - 5)), hook.getLocation());
}
}, hook.getLocation());
}