Package com.ordwen.odailyquests.tools
Class RenewSchedule
java.lang.Object
com.ordwen.odailyquests.tools.RenewSchedule
Utility class responsible for computing quest renewal schedules.
It centralizes all time-based calculations related to renewals (next execution, elapsed intervals, offline catch-up logic), ensuring consistent behavior across the plugin.
The schedule is defined by:
- a daily anchor time (
LocalTime) - a renewal interval (
Duration) - a time zone (
ZoneId) - a timestamp mode (raw int, handled elsewhere)
This class is stateless and cannot be instantiated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordImmutable container holding all renewal schedule parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanValidates that the given settings are usable for scheduling calculations.static longReturns the number of milliseconds remaining until the next scheduled execution.static ZonedDateTimeComputes the next scheduled execution time greater than or equal tonow.static RenewSchedule.Settingssettings()Builds aRenewSchedule.Settingsinstance from the current plugin configuration.static booleanshouldRenewSince(ZonedDateTime lastRenew, ZonedDateTime now, RenewSchedule.Settings s) Determines whether at least one scheduled execution occurred afterlastRenewand before or atnow.
-
Method Details
-
settings
Builds aRenewSchedule.Settingsinstance from the current plugin configuration.- Returns:
- the configured renewal schedule settings
-
isValid
Validates that the given settings are usable for scheduling calculations.- Parameters:
s- the schedule settings to validate- Returns:
trueif the settings are valid,falseotherwise
-
nextExecutionAtOrAfter
Computes the next scheduled execution time greater than or equal tonow.The calculation uses an anchor defined as "today at renewTime", then applies
k * intervalto reach the first execution ≥ now.This method is the single source of truth for renewal timing and is used by both timer tasks and remaining-time displays.
- Parameters:
now- the current date-times- the schedule settings- Returns:
- the next scheduled execution time
-
shouldRenewSince
public static boolean shouldRenewSince(ZonedDateTime lastRenew, ZonedDateTime now, RenewSchedule.Settings s) Determines whether at least one scheduled execution occurred afterlastRenewand before or atnow.This method is intended for offline catch-up logic (e.g. when a player reconnects after being offline).
- Parameters:
lastRenew- the last recorded renewal timenow- the current date-times- the schedule settings- Returns:
trueif a renewal should occur,falseotherwise
-
millisUntilNext
Returns the number of milliseconds remaining until the next scheduled execution.- Parameters:
now- the current date-times- the schedule settings- Returns:
- the remaining time in milliseconds (never negative)
-