HungerLib includes a small set of general-purpose utility functions that cover terminal housekeeping, pre-flight connectivity validation, and YAML-based configuration loading.Documentation 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.
clearTerminal and validateAll are importable directly from hungerlib; loadConfig is also exported from the top-level package.
clearTerminal
Clears the terminal screen using the appropriate system command for the current platform. Calls clear on POSIX systems (Linux, macOS) and cls on Windows. Useful at the start of a script loop to keep output readable.
None.
validateAll
Performs a three-step connectivity and state check against both the Pterodactyl panel and a specific server. Returns True only when all three checks pass, making it a reliable guard before running any automation that depends on the panel API and a live server.
The three checks performed internally are:
panel.ping()— verifies that the panel URL is reachable over HTTP.panel.validateAPI()— verifies that the API token is valid and accepted by the panel.server.getStatus() == 'running'— verifies that the target server is in therunningpower state.
An authenticated
Panel instance to check for reachability and API validity.A
GenericServer or MinecraftServer instance whose power state is checked.bool — True if the panel is reachable, the API key is valid, and the server status is "running". Returns False if any check fails.
loadConfig
Loads a typed configuration dataclass from a YAML file. This is HungerLib’s primary configuration system, designed to give automation scripts a structured, validated config with safe fallbacks and attribute-style YAML access.
loadConfig reads from a user-editable YAML file, maps values to dataclass fields by dotted YAML path, applies fallback values when keys are absent, and attaches two special namespaces — .raw and .fallbacks — to the returned instance.
A dataclass class (not an instance) decorated with
@dataclass that defines the configuration structure. The class must set __mode__ = "config" as a class-level attribute for loadConfig to treat field defaults as dotted YAML key paths.Optional filesystem path to the YAML config file. If
None, loadConfig reads __user_config_path__ from the schema class. If the file does not exist, the directory is created and either the default config (from __default_config_path__) is copied in, or an empty file is created.schema populated with values from the YAML file (or fallbacks). Two additional attributes are attached at runtime:
A namespace object providing attribute-style access to the raw parsed YAML values. Attribute lookups resolve dotted YAML paths using the dataclass field defaults. Use this to read YAML values that were not mapped to a dataclass field, or to inspect the raw input before conversion.
The
fallbacks class imported from the same module as schema. Contains the default values used when a YAML key is absent. Also used by Validator during schema validation.Schema class attributes
Your dataclass schema can define the following class-level attributes to controlloadConfig behaviour:
| Attribute | Type | Description |
|---|---|---|
__mode__ | str | Must be "config" to enable dotted-path YAML resolution. |
__user_config_path__ | str | Path to the user’s editable YAML file (e.g. "config/config.yaml"). Used when runtime_path=None. |
__default_config_path__ | str | Package-relative path to a bundled default YAML file. Copied to __user_config_path__ on first run if the user config does not yet exist. |
Full example
If a YAML key is missing,
loadConfig falls back to the value defined in the fallbacks class in the same module as your schema. If no fallback is defined for a field, the value is set to None. Use HungerLib’s Validator system to enforce required fields and raise FatalError when critical keys are absent.