diff --git a/src/main/java/com/alttd/fishingevent/fish/Fish.java b/src/main/java/com/alttd/fishingevent/fish/Fish.java index c1fded3..5d5c8de 100644 --- a/src/main/java/com/alttd/fishingevent/fish/Fish.java +++ b/src/main/java/com/alttd/fishingevent/fish/Fish.java @@ -3,6 +3,7 @@ package com.alttd.fishingevent.fish; import com.alttd.fishingevent.FishingEvent; import com.alttd.fishingevent.config.Fishes; import com.alttd.fishingevent.objects.Rarity; +import com.alttd.fishingevent.timer.EventManager; import com.alttd.fishingevent.util.Logger; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; @@ -93,15 +94,26 @@ public class Fish { * @return a random length for this fish */ public float generateLength(int luckLevel) { + float modifiedMaxLength = limitMaxLengthBasedOnTime(); + float modifiedMinLength = minLength; if (luckLevel >= 1 && luckLevel <= 5) { - float improvement = luckLevel * 0.1f * (maxLength - minLength); - float availableSpace = maxLength - minLength - 1; + float improvement = luckLevel * 0.1f * (modifiedMaxLength - minLength); + float availableSpace = modifiedMaxLength - minLength - 1; modifiedMinLength += Math.min(improvement, availableSpace); } - return new Random().nextFloat(modifiedMinLength, maxLength); + return new Random().nextFloat(modifiedMinLength, modifiedMaxLength); + } + + private float limitMaxLengthBasedOnTime() { + if (maxLength <= 6000) + return maxLength; + long secondsRemaining = EventManager.getInstance().getTimeRemaining().toSeconds(); + if ((maxLength - minLength) < 2000) + return maxLength; + return Math.max(minLength + 2000, maxLength - secondsRemaining); } public net.kyori.adventure.text.@NotNull Component fishName() {