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:
@@ -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;
|
||||
|
||||
@@ -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 -> {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user