Application API Documentation

Provides API functions for application-wide information and actions.

This module offers endpoints to retrieve general details about the Bedrock Server Manager application itself and to perform operations that span across multiple server instances.

Key functionalities include:
  • Retrieving application metadata (name, version, OS, key directories) via get_application_info_api().

  • Listing globally available content like world templates (list_available_worlds_api()) and addons (list_available_addons_api()).

  • Aggregating status and version information for all detected server instances using get_all_servers_data().

These functions are exposed to the plugin system via api_method() and are intended for use by UIs, CLIs, or other high-level components.

bedrock_server_manager.api.application.list_available_worlds_api(app_context: AppContext) Dict[str, Any]

Lists available .mcworld files from the content directory.

Scans the worlds sub-folder within the application’s global content directory.

Returns:

A dictionary with the operation result. On success: {"status": "success", "files": List[str]} where files is a list of absolute paths to .mcworld files. On error: {"status": "error", "message": "<error_message>"}.

Return type:

Dict[str, Any]

Raises:

FileError – If the content directory is not configured or accessible.

bedrock_server_manager.api.application.get_all_servers_data(app_context: AppContext) Dict[str, Any]

Retrieves status and version for all detected servers.

This function acts as an API orchestrator to gather data from all individual server instances. It can handle partial failures, where data for some servers is retrieved successfully while others fail (errors for individual servers are included in the message). The status of each server is also reconciled with its live state during this call.

Returns:

A dictionary with the operation result.

On full success (all servers processed without error):

{"status": "success", "servers": List[ServerDataDict]}

On partial success (some individual server errors occurred during scan):

{"status": "success", "servers": List[ServerDataDict], "message": "Completed with errors: <details>"} The servers list contains data for successfully processed servers.

On total failure (e.g., cannot access base server directory):

{"status": "error", "message": "<error_message>"}

Each ServerDataDict contains keys like “name”, “status”, “version”.

Return type:

Dict[str, Any]

Raises:

BSMError – If there’s a fundamental issue accessing the base server directory (e.g., AppFileNotFoundError).

bedrock_server_manager.api.application.get_system_and_app_info(app_context: AppContext) Dict[str, Any]

Retrieves basic system and application information.

Uses global settings to get OS type and app version.

Returns:

On success: {"status": "success", "os_type": "...", "app_version": "...", "splash_text": "..."}. On error: {"status": "error", "message": "An unexpected error occurred."}

Return type:

Dict[str, Any]

bedrock_server_manager.api.application.update_server_statuses(app_context: AppContext) Dict[str, Any]

Reconciles the status in config files with the runtime state for all servers.

This function calls the core function to get servers data. During that call, for each discovered server, its get_status() method is invoked. This method determines the actual running state of the server process and updates the status field in the server’s JSON configuration file (e.g., <server_name>_config.json) if there’s a discrepancy between the stored status and the live status.

Returns:

A dictionary summarizing the operation. On success (even with individual server errors during discovery): {"status": "success", "message": "Status check completed for <n> servers."} or {"status": "error", "message": "Completed with errors: <details>", "updated_servers_count": <n>} (The “error” status here primarily reflects issues during the overall scan, like directory access problems, rather than individual server status update failures, which are logged and included in the message if discovery_errors occur.)

Return type:

Dict[str, Any]