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

Fix first size record

This commit is contained in:
XiaoMoMi
2025-01-28 01:20:37 +08:00
parent 231a953f9f
commit eb64b50392

View File

@@ -611,15 +611,15 @@ public class CustomFishingHook {
userData -> {
Pair<Integer, Integer> result = userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1);
context.arg(ContextKeys.TOTAL_AMOUNT, userData.statistics().getAmount(nextLoot.statisticKey().amountKey()));
plugin.getEventManager().trigger(context, id, MechanicType.LOOT, ActionTrigger.SUCCESS, result.left(), result.right());
Optional.ofNullable(context.arg(ContextKeys.SIZE)).ifPresent(size -> {
float max = Math.max(0, userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey()));
float max = Math.max(size, userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey()));
context.arg(ContextKeys.RECORD, max);
context.arg(ContextKeys.RECORD_FORMATTED, String.format("%.2f", max));
if (userData.statistics().updateSize(nextLoot.statisticKey().sizeKey(), size)) {
plugin.getEventManager().trigger(context, id, MechanicType.LOOT, ActionTrigger.NEW_SIZE_RECORD);
}
});
plugin.getEventManager().trigger(context, id, MechanicType.LOOT, ActionTrigger.SUCCESS, result.left(), result.right());
}
);
}