ModPackageManager class handles all operations related to ZZAR mod packages, including installation, removal, enabling/disabling, load order management, and conflict resolution.
Constructor
Custom path to mod library directory. If None, uses the default from config_manager.
Optional manager for tracking persistent mod changes.
Methods
validate_mod_package
Validates a .zzar package file structure and metadata.Path to the .zzar file to validate.
The mod’s metadata dictionary containing:
name(str): Mod nameauthor(str): Mod authorversion(str): Mod versionreplacements(dict): PCK replacements mappingformat_version(str): Package format version
InvalidModPackageError: If the package is invalid or corrupted
install_mod
Installs a .zzar mod package into the mod library.Path to the .zzar package to install.
Installation result containing:
uuid(str): Unique identifier for the installed modreplaced(bool): Whether this replaced an existing versionmod_name(str): Name of the modversion(str): Version installed
- Automatically replaces older versions of the same mod
- Returns
Noneif trying to install an older version over a newer one - Extracts mod to
mod_library/mods/{uuid}/ - Adds mod to config but keeps it disabled by default
get_installed_mods
Returns a list of all installed mods in load order.List of mod dictionaries, each containing:
uuid(str): Mod unique identifierenabled(bool): Whether mod is enabledpriority(int): Load order priority (0 = highest)metadata(dict): Mod metadata from metadata.jsoninstall_date(str): ISO format installation timestampthumbnail_path(Path): Path to thumbnail image if available
set_mod_enabled
Enables or disables a mod.UUID of the mod to enable/disable.
True to enable, False to disable.
remove_mod
Completely removes a mod from the library.UUID of the mod to remove.
update_load_order
Updates the load order priority of mods.List of mod UUIDs in desired load order (first = highest priority).
ValueError: If any UUID is not a valid installed mod
resolve_conflicts
Resolves file conflicts between enabled mods based on load order.Optional conflict preferences. Keys are
"pck_name:file_id", values are mod names.Nested dictionary:
{pck_name: {file_id: replacement_info}}Each replacement_info contains:wem_path(str): Path to replacement WEM filemod_uuid(str): UUID of winning modmod_name(str): Name of winning modlang_id(int): Language IDbnk_id(int): BNK ID if inside soundbankfile_type(str): File type (“wem”)sound_name(str): Sound name if availableconflicts_with(list): UUIDs of losing mods
- Higher priority mods (earlier in load order) win conflicts
- Automatically removes orphaned mods from config
get_conflicts_summary
Returns a summary of all conflicts.total_replacements(int): Total number of file replacementsaffected_pcks(list[str]): List of PCK names being modifiedconflicts(list[dict]): List of individual conflicts
apply_mods
Applies all enabled mods to the game audio directory.Path to the game’s Audio directory.
Path to Persistent Audio directory for modified PCKs.
Function called with (message, current, total) for progress updates.
Conflict resolution preferences.
ModApplicationError: If application fails
- Creates modified PCK files in persistent_audio_dir
- Sets modified PCKs to read-only (0o444)
- Removes PCKs from disabled mods
- Supports both direct WEM replacement and BNK-embedded WEMs
create_mod_package
Creates a new .zzar mod package from replacements.Where to save the .zzar package.
Metadata dictionary with keys:
name, author, version, description.Replacements dictionary from resolve_conflicts() or similar.
Optional path to thumbnail image (converted to PNG).
Path to the created .zzar package.
Exceptions
InvalidModPackageError
Raised when a .zzar package is invalid or corrupted.ModApplicationError
Raised when mod application fails.Example Usage
Configuration Files
The manager uses these configuration files:-
mod_config.json: Stores installed mods and load order
- Location:
~/.config/ZZAR/mod_config.json(Linux) or%APPDATA%/ZZAR/mod_config.json(Windows) - Structure:
{"installed_mods": {}, "load_order": []}
- Location:
-
Mod library: Stores extracted mod files
- Location:
~/.local/share/ZZAR/mod_library/mods/(Linux) or%LOCALAPPDATA%/ZZAR/mod_library/mods/(Windows) - Each mod in subdirectory named by UUID
- Location: