HungerLib’s scheduling utilities solve the most common timing needs in Pterodactyl automation scripts: finding the next clean clock boundary for a restart, firing warning messages at precise countdown intervals, and blocking script execution until a server has fully started or stopped. Rather than writing ad-hocDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/iFamishedX/HungerLib/llms.txt
Use this file to discover all available pages before exploring further.
time.sleep loops, you can express intent directly — “restart at the next :00 or :30, at least 15 minutes from now” — and let HungerLib handle the arithmetic.
snapSchedule
snapSchedule looks at the current time, adds the required lead time (minimumMinutes), then finds the first minute value from snapMinutes that is strictly greater than minimum.minute. If no snap minute in the current hour qualifies, it rolls over to minute 0 of the next hour. This guarantees scheduled events always land on a clean, predictable boundary rather than an arbitrary offset.
The minimum number of minutes of lead time required before the scheduled event. The function will not schedule anything sooner than
now + minimumMinutes.The set of minute values (within an hour) that are acceptable schedule targets. Values are sorted automatically. For example,
(0, 15, 30, 45) snaps to quarter-hour boundaries.dict with four keys:
| Key | Type | Description |
|---|---|---|
now | datetime | The exact moment snapSchedule was called |
minimum | datetime | now plus minimumMinutes |
scheduled | datetime | The chosen snap target — always ≥ minimum |
formatted | str | scheduled formatted as "HH:MM AM/PM" (e.g. "02:30 PM") |
runCountdownEvents
runCountdownEvents blocks the calling thread until target_time is reached, waking up every tick_interval seconds to check whether any registered callback threshold has been crossed. Each callback is guaranteed to fire at most once — HungerLib tracks which thresholds have already been triggered and skips duplicates.
The future
datetime to count down toward. The function returns as soon as datetime.now() reaches or passes this value.A mapping of
{minutes_remaining: callable}. Each callable is called with no arguments when the countdown crosses that minute threshold. Pass None to skip minute-based events.A mapping of
{seconds_remaining: callable}. Works the same as minute_callbacks but operates at second granularity. Pass None to skip second-based events.Sleep duration in seconds between each poll cycle. Lower values increase precision at the cost of CPU usage. The default of
1 is appropriate for most automation scripts.The function returns
None when the countdown expires — it does not call the scheduled action itself. Place the action (e.g. server.restart()) immediately after runCountdownEvents returns.waitForOnline / waitForOffline
True as soon as the target state is reached or False if the timeout elapses first. They rely on the server’s .isOnline() and .isOffline() methods respectively and are safe to use with any GenericServer or MinecraftServer instance.
Any HungerLib server object that implements
.isOnline() / .isOffline().Maximum number of seconds to wait before giving up and returning
False.Seconds to sleep between each state poll. Increase this to reduce API call frequency against the Pterodactyl panel.
secsUntil / minsUntil
datetime. Both functions truncate (floor division) rather than rounding.
The future point in time to measure toward. Passing a datetime in the past returns a negative integer.
minute_callbacks or second_callbacks passed to runCountdownEvents when you want the callback itself to report remaining time.
clearTerminal
clear on POSIX systems, cls on Windows). Useful in long-running automation scripts to keep the console readable between restart cycles.