Update to v0.1.3-alpha
- Add Forge/Neoforge support. - Now launcher will try to recreate the manifest if specific version does not exist. - Themed "ItLooksLikeOfficial" scrollbar. CoreLib update to 0.1.6
This commit is contained in:
1 parent
ef3667ae5e
commit
8316722169
23 files changed
+3000
-127
No files matched your search
+670
-3
@@ -1,6 +1,673 @@
|
||||
__version__ = '0.1.5'
|
||||
__version__ = '0.1.6'
|
||||
__description__ = """
|
||||
The core library of the *Launcher*
|
||||
A library for Python-based block game launcher.
|
||||
|
||||
Some reference implementation are from bk_core.
|
||||
"""
|
||||
"""
|
||||
|
||||
from .common.common import (
|
||||
DEFAULT_HASH_CHUNK_SIZE,
|
||||
DEFAULT_DOWNLOAD_CHUNK_SIZE,
|
||||
THREADED_DOWNLOAD_MAX_WORKERS,
|
||||
SUPPORTED_HASH_ALGORITHMS,
|
||||
FileObject,
|
||||
generate_random_suffix,
|
||||
download_file,
|
||||
download_multiple_files,
|
||||
unzip,
|
||||
get_platform_info,
|
||||
is_valid_zipfile,
|
||||
bytes_to_data_url,
|
||||
attempt,
|
||||
)
|
||||
|
||||
from .common.exception import (
|
||||
LauncherException,
|
||||
LauncherHTTPException,
|
||||
HashMismatchException,
|
||||
UnsupportedHashAlgorithmException,
|
||||
UnsupportedPlatformException,
|
||||
VersionNotSelectedException,
|
||||
VersionManifestFetchException,
|
||||
VersionManifestSaveException,
|
||||
NoVersionFoundException,
|
||||
NoSpecifiedVersionKeyException,
|
||||
VersionDataKeyNotFoundException,
|
||||
VersionManifestException,
|
||||
DependencyException,
|
||||
NativeResolveException,
|
||||
DownloadException,
|
||||
ExtractException,
|
||||
AssetManifestFetchException,
|
||||
AssetManifestSaveException,
|
||||
AssetManifestException,
|
||||
AssetDataKeyNotFoundException,
|
||||
JavaRuntimeException,
|
||||
JavaRuntimeParseException,
|
||||
RuntimeManifestFetchException,
|
||||
RuntimeManifestDataException,
|
||||
ProfileException,
|
||||
ProfileSaveException,
|
||||
ProfileLoadException,
|
||||
ProfileKeyNotFoundException,
|
||||
AccountException,
|
||||
AccountSaveException,
|
||||
AccountLoadException,
|
||||
AccountKeyNotFoundException,
|
||||
AuthenticationException,
|
||||
AuthenticationConnectException,
|
||||
AuthenticationSessionException,
|
||||
ThirdPartyAPIException,
|
||||
SettingsError,
|
||||
ModelRegistrationError,
|
||||
ConfigValidationError,
|
||||
ArgumentError,
|
||||
ArgumentValueError,
|
||||
)
|
||||
|
||||
from .common.python import (
|
||||
is_function_in_file,
|
||||
)
|
||||
|
||||
from .game.account import (
|
||||
get_account_sample,
|
||||
get_accounts_sample,
|
||||
Account,
|
||||
create_account_data_from_object,
|
||||
SUPPORT_DATA_URL_IMAGE_TYPE,
|
||||
is_valid_account_avatar,
|
||||
is_account_valid,
|
||||
is_accounts_valid,
|
||||
list_accounts,
|
||||
is_account_exists,
|
||||
get_account,
|
||||
get_current_account_id,
|
||||
get_active_account_id,
|
||||
get_current_account,
|
||||
get_active_account,
|
||||
set_current_account_id,
|
||||
set_active_account_id,
|
||||
add_account,
|
||||
create_account,
|
||||
update_account,
|
||||
remove_account,
|
||||
convert_account_data_to_object,
|
||||
read_account_file,
|
||||
read_accounts_file,
|
||||
create_or_save_account_file,
|
||||
get_account_avatar,
|
||||
save_account_avatar,
|
||||
create_or_save_accounts_file,
|
||||
)
|
||||
|
||||
from .game.argument import (
|
||||
FeatureSpec,
|
||||
validate_resolution,
|
||||
FEATURE_SPECS,
|
||||
compare_versions,
|
||||
is_argument_allowed,
|
||||
PLACEHOLDER_PATTERN,
|
||||
replace_placeholders,
|
||||
ArgumentMappings,
|
||||
convert_argument_to_multiple_string,
|
||||
find_game_and_jvm_args,
|
||||
parse_and_generate_arguments,
|
||||
append_missing_necessary_jvm_arguments,
|
||||
find_match_feature_argument,
|
||||
generate_enabled_feature_arguments,
|
||||
generate_feature_placeholders,
|
||||
generate_launch_command,
|
||||
is_a_argument,
|
||||
generate_argument_details,
|
||||
is_same_argument,
|
||||
)
|
||||
|
||||
from .game.asset import (
|
||||
MOJANG_RESOURCE_ENDPOINT,
|
||||
ASSET_DOWNLOAD_MAX_WORKERS,
|
||||
ASSET_CHECK_MAX_WORKERS,
|
||||
fetch_asset_manifest,
|
||||
fetch_and_save_asset_manifest,
|
||||
collect_assets_from_manifest,
|
||||
download_assets_and_copy,
|
||||
correct_assets_name_and_copy,
|
||||
download_assets,
|
||||
check_assets_exist,
|
||||
read_exist_assets_indexes,
|
||||
find_correct_assets_dir,
|
||||
)
|
||||
|
||||
from .game.authentication import (
|
||||
MICROSOFT_DEVICE_CODE_URL,
|
||||
MICROSOFT_TOKEN_URL,
|
||||
XBOX_AUTH_URL,
|
||||
XSTS_AUTH_URL,
|
||||
MINECRAFT_LOGIN_URL,
|
||||
MINECRAFT_ENTITLEMENTS_URL,
|
||||
MINECRAFT_PROFILE_URL,
|
||||
auth_exception_handler,
|
||||
get_device_code,
|
||||
get_microsoft_token,
|
||||
get_xbox_token_and_user_hash,
|
||||
get_xsts_token,
|
||||
extract_xuid,
|
||||
get_xbox_xuid,
|
||||
get_minecraft_access_token,
|
||||
get_account_entitlements,
|
||||
get_minecraft_profile,
|
||||
has_minecraft_license,
|
||||
refresh_microsoft_token,
|
||||
is_access_token_valid,
|
||||
)
|
||||
|
||||
from .game.library import (
|
||||
parse_maven_coordinate,
|
||||
convert_maven_version,
|
||||
generate_filename_from_maven_coordinate,
|
||||
generate_repo_path,
|
||||
is_complete_maven_url,
|
||||
generate_repo_url,
|
||||
is_library_allowed,
|
||||
filter_platform_libraries,
|
||||
get_natives_platform_info,
|
||||
is_native_allowed,
|
||||
is_legacy_native_allowed,
|
||||
generate_relative_path_by_maven_coordinate,
|
||||
remove_duplicate_artifacts,
|
||||
generate_formatted_artifact_with_name,
|
||||
)
|
||||
|
||||
from .game.library_core import (
|
||||
collect_library_artifacts,
|
||||
locate_natives_extract_dir,
|
||||
locate_natives_extract_dir_by_manifest,
|
||||
collect_native_artifacts,
|
||||
download_libraries,
|
||||
unzip_natives,
|
||||
check_libraries_exists,
|
||||
check_natives_exists,
|
||||
check_full_libraries_exists,
|
||||
generate_classpath,
|
||||
download_full_libraries,
|
||||
)
|
||||
|
||||
from .game.libraryx import (
|
||||
convert_maven_version_with_extra,
|
||||
generate_unique_library_key,
|
||||
normalize_library_to_common_struct,
|
||||
LibraryPreference,
|
||||
PREFER_BY_HIGHER_VERSION,
|
||||
PREFER_BY_LOWER_VERSION,
|
||||
PREFER_MOD_LIBRARY,
|
||||
PREFER_INHERITS_LIBRARY,
|
||||
LIBRARY_PREFER_OPTIONS,
|
||||
compare_library_versions,
|
||||
deduplicate_libraries,
|
||||
)
|
||||
|
||||
from .game.mod.fabric import (
|
||||
FABRIC_META_VERSION_ENDPOINT_V2,
|
||||
FABRIC_META_LOADER_VERSION_ENDPOINT_V2,
|
||||
FABRIC_META_LOADER_MANIFEST_ENDPOINT_V2,
|
||||
FABRIC_MAVEN_URL,
|
||||
get_full_version_string,
|
||||
fetch_fabric_versions,
|
||||
is_version_supported_and_stable,
|
||||
get_version_support_loader_list,
|
||||
get_loader_manifest_from_loader_data,
|
||||
)
|
||||
|
||||
from .game.mod.forge_like import (
|
||||
FORGE_MAVEN_URL,
|
||||
FORGE_METADATA_URL,
|
||||
fetch_forge_versions,
|
||||
)
|
||||
|
||||
from .game.mod.mod_core import (
|
||||
LOADER_LIBRARY_MARKERS,
|
||||
detect_loader_name,
|
||||
find_useful_part_in_mod_version_manifest,
|
||||
merge_necessary_dependencies,
|
||||
merge_arguments,
|
||||
merge_game_and_jvm_args,
|
||||
merge_manifest,
|
||||
)
|
||||
|
||||
from .game.mod.rules import (
|
||||
MOD_LOADER_RULES,
|
||||
)
|
||||
|
||||
from .game.profile import (
|
||||
get_profile_sample,
|
||||
Profile,
|
||||
create_profile_data_from_object,
|
||||
create_profile,
|
||||
create_or_save_profile_file,
|
||||
read_profile_file,
|
||||
is_profiles_valid,
|
||||
is_profile_valid,
|
||||
is_profile_exists,
|
||||
list_profiles,
|
||||
get_profile,
|
||||
set_current_profile_id,
|
||||
get_current_profile_id,
|
||||
get_last_played_profile_id,
|
||||
add_profile,
|
||||
remove_profile,
|
||||
duplicate_profile,
|
||||
convert_profile_data_to_object,
|
||||
update_profile,
|
||||
set_last_used_time,
|
||||
set_last_used_time_to_current,
|
||||
)
|
||||
|
||||
from .game.third_party import (
|
||||
MC_HEADS_HEAD_ENDPOINT,
|
||||
get_minecraft_head_url,
|
||||
get_minecraft_head,
|
||||
)
|
||||
|
||||
from .game.version_info import (
|
||||
MOJANG_VERSION_MANIFEST_V2,
|
||||
MOJANG_VERSION_MANIFEST,
|
||||
MOJANG_LIBRARIES_ENDPOINT,
|
||||
NATIVE_OS_KEY_MAP,
|
||||
NATIVE_OS_RULE_MAP,
|
||||
NATIVE_ARCH_KEY_MAP,
|
||||
NATIVE_OLD_TO_NEW_ARCH,
|
||||
NATIVE_NEW_TO_OLD_ARCH,
|
||||
RUNTIME_PLATFORM_MAP,
|
||||
RUNTIME_ARCH_EMPTY,
|
||||
RUNTIME_ARCH_MAP,
|
||||
get_version_manifest,
|
||||
get_latest_version,
|
||||
get_all_versions,
|
||||
get_available_version_types,
|
||||
get_specific_version_manifest_url,
|
||||
get_specific_version_manifest_url_and_hash,
|
||||
fetch_specific_version_manifest,
|
||||
get_specific_version_manifest,
|
||||
default_java_version,
|
||||
find_useful_part_in_specific_version_manifest,
|
||||
get_core_file_download_url_and_hash,
|
||||
validate_version_manifest,
|
||||
save_version_manifest,
|
||||
fetch_and_save_version_manifest,
|
||||
download_core_file,
|
||||
check_core_file_exists_and_verify,
|
||||
LATEST_VERSION_ALIASES,
|
||||
)
|
||||
|
||||
from .i18n import (
|
||||
SUPPORTED_LANGUAGES,
|
||||
TranslationManager,
|
||||
)
|
||||
|
||||
from .launcher.object import (
|
||||
Launcher,
|
||||
)
|
||||
|
||||
from .log.default import (
|
||||
DEFAULT_FORMAT,
|
||||
DEFAULT_DATE_FORMAT,
|
||||
get_colorful_handler,
|
||||
LogEmitter,
|
||||
LogCaptureHandler,
|
||||
)
|
||||
|
||||
from .qt.hack import (
|
||||
move_window_to_center,
|
||||
is_main_thread,
|
||||
recolor_standard_icon,
|
||||
recolor_pixmap,
|
||||
recolor_icon,
|
||||
is_light_theme,
|
||||
add_icon_padding,
|
||||
data_url_to_qt_image,
|
||||
)
|
||||
|
||||
from .qt.item_button import (
|
||||
ItemButton,
|
||||
)
|
||||
|
||||
from .qt.messagebox import (
|
||||
create_messagebox,
|
||||
error,
|
||||
info,
|
||||
warning,
|
||||
error_with_plain_text,
|
||||
ask_yes_no_with_plain_text,
|
||||
)
|
||||
|
||||
from .qt.progress_dialog import (
|
||||
ProgressRow,
|
||||
ProgressDialog,
|
||||
)
|
||||
|
||||
from .runtime.java import (
|
||||
get_java_version,
|
||||
find_java_installations,
|
||||
)
|
||||
|
||||
from .runtime.mojang import (
|
||||
MOJANG_RUNTIME_MANIFEST,
|
||||
RUNTIME_CHECK_MAX_WORKERS,
|
||||
RUNTIME_DOWNLOAD_MAX_WORKERS,
|
||||
get_current_platform_runtime_key,
|
||||
fetch_runtime_manifest,
|
||||
find_support_runtime_manifests_info,
|
||||
get_support_runtime_manifest,
|
||||
RuntimeCheckResult,
|
||||
collect_runtime_files,
|
||||
post_process_runtime_dir,
|
||||
download_java_runtimes,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# common.common
|
||||
"DEFAULT_HASH_CHUNK_SIZE",
|
||||
"DEFAULT_DOWNLOAD_CHUNK_SIZE",
|
||||
"THREADED_DOWNLOAD_MAX_WORKERS",
|
||||
"SUPPORTED_HASH_ALGORITHMS",
|
||||
"FileObject",
|
||||
"generate_random_suffix",
|
||||
"download_file",
|
||||
"download_multiple_files",
|
||||
"unzip",
|
||||
"get_platform_info",
|
||||
"is_valid_zipfile",
|
||||
"bytes_to_data_url",
|
||||
"attempt",
|
||||
# common.exception
|
||||
"LauncherException",
|
||||
"LauncherHTTPException",
|
||||
"HashMismatchException",
|
||||
"UnsupportedHashAlgorithmException",
|
||||
"UnsupportedPlatformException",
|
||||
"VersionNotSelectedException",
|
||||
"VersionManifestFetchException",
|
||||
"VersionManifestSaveException",
|
||||
"NoVersionFoundException",
|
||||
"NoSpecifiedVersionKeyException",
|
||||
"VersionDataKeyNotFoundException",
|
||||
"VersionManifestException",
|
||||
"DependencyException",
|
||||
"NativeResolveException",
|
||||
"DownloadException",
|
||||
"ExtractException",
|
||||
"AssetManifestFetchException",
|
||||
"AssetManifestSaveException",
|
||||
"AssetManifestException",
|
||||
"AssetDataKeyNotFoundException",
|
||||
"JavaRuntimeException",
|
||||
"JavaRuntimeParseException",
|
||||
"RuntimeManifestFetchException",
|
||||
"RuntimeManifestDataException",
|
||||
"ProfileException",
|
||||
"ProfileSaveException",
|
||||
"ProfileLoadException",
|
||||
"ProfileKeyNotFoundException",
|
||||
"AccountException",
|
||||
"AccountSaveException",
|
||||
"AccountLoadException",
|
||||
"AccountKeyNotFoundException",
|
||||
"AuthenticationException",
|
||||
"AuthenticationConnectException",
|
||||
"AuthenticationSessionException",
|
||||
"ThirdPartyAPIException",
|
||||
"SettingsError",
|
||||
"ModelRegistrationError",
|
||||
"ConfigValidationError",
|
||||
"ArgumentError",
|
||||
"ArgumentValueError",
|
||||
# common.python
|
||||
"is_function_in_file",
|
||||
# game.account
|
||||
"get_account_sample",
|
||||
"get_accounts_sample",
|
||||
"Account",
|
||||
"create_account_data_from_object",
|
||||
"SUPPORT_DATA_URL_IMAGE_TYPE",
|
||||
"is_valid_account_avatar",
|
||||
"is_account_valid",
|
||||
"is_accounts_valid",
|
||||
"list_accounts",
|
||||
"is_account_exists",
|
||||
"get_account",
|
||||
"get_current_account_id",
|
||||
"get_active_account_id",
|
||||
"get_current_account",
|
||||
"get_active_account",
|
||||
"set_current_account_id",
|
||||
"set_active_account_id",
|
||||
"add_account",
|
||||
"create_account",
|
||||
"update_account",
|
||||
"remove_account",
|
||||
"convert_account_data_to_object",
|
||||
"read_account_file",
|
||||
"read_accounts_file",
|
||||
"create_or_save_account_file",
|
||||
"get_account_avatar",
|
||||
"save_account_avatar",
|
||||
"create_or_save_accounts_file",
|
||||
# game.argument
|
||||
"FeatureSpec",
|
||||
"validate_resolution",
|
||||
"FEATURE_SPECS",
|
||||
"compare_versions",
|
||||
"is_argument_allowed",
|
||||
"PLACEHOLDER_PATTERN",
|
||||
"replace_placeholders",
|
||||
"ArgumentMappings",
|
||||
"convert_argument_to_multiple_string",
|
||||
"find_game_and_jvm_args",
|
||||
"parse_and_generate_arguments",
|
||||
"append_missing_necessary_jvm_arguments",
|
||||
"find_match_feature_argument",
|
||||
"generate_enabled_feature_arguments",
|
||||
"generate_feature_placeholders",
|
||||
"generate_launch_command",
|
||||
"is_a_argument",
|
||||
"generate_argument_details",
|
||||
"is_same_argument",
|
||||
# game.asset
|
||||
"MOJANG_RESOURCE_ENDPOINT",
|
||||
"ASSET_DOWNLOAD_MAX_WORKERS",
|
||||
"ASSET_CHECK_MAX_WORKERS",
|
||||
"fetch_asset_manifest",
|
||||
"fetch_and_save_asset_manifest",
|
||||
"collect_assets_from_manifest",
|
||||
"download_assets_and_copy",
|
||||
"correct_assets_name_and_copy",
|
||||
"download_assets",
|
||||
"check_assets_exist",
|
||||
"read_exist_assets_indexes",
|
||||
"find_correct_assets_dir",
|
||||
# game.authentication
|
||||
"MICROSOFT_DEVICE_CODE_URL",
|
||||
"MICROSOFT_TOKEN_URL",
|
||||
"XBOX_AUTH_URL",
|
||||
"XSTS_AUTH_URL",
|
||||
"MINECRAFT_LOGIN_URL",
|
||||
"MINECRAFT_ENTITLEMENTS_URL",
|
||||
"MINECRAFT_PROFILE_URL",
|
||||
"auth_exception_handler",
|
||||
"get_device_code",
|
||||
"get_microsoft_token",
|
||||
"get_xbox_token_and_user_hash",
|
||||
"get_xsts_token",
|
||||
"extract_xuid",
|
||||
"get_xbox_xuid",
|
||||
"get_minecraft_access_token",
|
||||
"get_account_entitlements",
|
||||
"get_minecraft_profile",
|
||||
"has_minecraft_license",
|
||||
"refresh_microsoft_token",
|
||||
"is_access_token_valid",
|
||||
# game.library
|
||||
"parse_maven_coordinate",
|
||||
"convert_maven_version",
|
||||
"generate_filename_from_maven_coordinate",
|
||||
"generate_repo_path",
|
||||
"is_complete_maven_url",
|
||||
"generate_repo_url",
|
||||
"is_library_allowed",
|
||||
"filter_platform_libraries",
|
||||
"get_natives_platform_info",
|
||||
"is_native_allowed",
|
||||
"is_legacy_native_allowed",
|
||||
"generate_relative_path_by_maven_coordinate",
|
||||
"remove_duplicate_artifacts",
|
||||
"generate_formatted_artifact_with_name",
|
||||
# game.library_core
|
||||
"collect_library_artifacts",
|
||||
"locate_natives_extract_dir",
|
||||
"locate_natives_extract_dir_by_manifest",
|
||||
"collect_native_artifacts",
|
||||
"download_libraries",
|
||||
"unzip_natives",
|
||||
"check_libraries_exists",
|
||||
"check_natives_exists",
|
||||
"check_full_libraries_exists",
|
||||
"generate_classpath",
|
||||
"download_full_libraries",
|
||||
# game.libraryx
|
||||
"convert_maven_version_with_extra",
|
||||
"generate_unique_library_key",
|
||||
"normalize_library_to_common_struct",
|
||||
"LibraryPreference",
|
||||
"PREFER_BY_HIGHER_VERSION",
|
||||
"PREFER_BY_LOWER_VERSION",
|
||||
"PREFER_MOD_LIBRARY",
|
||||
"PREFER_INHERITS_LIBRARY",
|
||||
"LIBRARY_PREFER_OPTIONS",
|
||||
"compare_library_versions",
|
||||
"deduplicate_libraries",
|
||||
# game.mod.fabric
|
||||
"FABRIC_META_VERSION_ENDPOINT_V2",
|
||||
"FABRIC_META_LOADER_VERSION_ENDPOINT_V2",
|
||||
"FABRIC_META_LOADER_MANIFEST_ENDPOINT_V2",
|
||||
"FABRIC_MAVEN_URL",
|
||||
"get_full_version_string",
|
||||
"fetch_fabric_versions",
|
||||
"is_version_supported_and_stable",
|
||||
"get_version_support_loader_list",
|
||||
"get_loader_manifest_from_loader_data",
|
||||
# game.mod.forge
|
||||
"FORGE_MAVEN_URL",
|
||||
"FORGE_METADATA_URL",
|
||||
"fetch_forge_versions",
|
||||
# game.mod.mod_core
|
||||
"LOADER_LIBRARY_MARKERS",
|
||||
"detect_loader_name",
|
||||
"find_useful_part_in_mod_version_manifest",
|
||||
"merge_necessary_dependencies",
|
||||
"merge_arguments",
|
||||
"merge_game_and_jvm_args",
|
||||
"merge_manifest",
|
||||
# game.mod.rules
|
||||
"MOD_LOADER_RULES",
|
||||
# game.profile
|
||||
"get_profile_sample",
|
||||
"Profile",
|
||||
"create_profile_data_from_object",
|
||||
"create_profile",
|
||||
"create_or_save_profile_file",
|
||||
"read_profile_file",
|
||||
"is_profiles_valid",
|
||||
"is_profile_valid",
|
||||
"is_profile_exists",
|
||||
"list_profiles",
|
||||
"get_profile",
|
||||
"set_current_profile_id",
|
||||
"get_current_profile_id",
|
||||
"get_last_played_profile_id",
|
||||
"add_profile",
|
||||
"remove_profile",
|
||||
"duplicate_profile",
|
||||
"convert_profile_data_to_object",
|
||||
"update_profile",
|
||||
"set_last_used_time",
|
||||
"set_last_used_time_to_current",
|
||||
# game.third_party
|
||||
"MC_HEADS_HEAD_ENDPOINT",
|
||||
"get_minecraft_head_url",
|
||||
"get_minecraft_head",
|
||||
# game.version_info
|
||||
"MOJANG_VERSION_MANIFEST_V2",
|
||||
"MOJANG_VERSION_MANIFEST",
|
||||
"MOJANG_LIBRARIES_ENDPOINT",
|
||||
"NATIVE_OS_KEY_MAP",
|
||||
"NATIVE_OS_RULE_MAP",
|
||||
"NATIVE_ARCH_KEY_MAP",
|
||||
"NATIVE_OLD_TO_NEW_ARCH",
|
||||
"NATIVE_NEW_TO_OLD_ARCH",
|
||||
"RUNTIME_PLATFORM_MAP",
|
||||
"RUNTIME_ARCH_EMPTY",
|
||||
"RUNTIME_ARCH_MAP",
|
||||
"get_version_manifest",
|
||||
"get_latest_version",
|
||||
"get_all_versions",
|
||||
"get_available_version_types",
|
||||
"get_specific_version_manifest_url",
|
||||
"get_specific_version_manifest_url_and_hash",
|
||||
"fetch_specific_version_manifest",
|
||||
"get_specific_version_manifest",
|
||||
"default_java_version",
|
||||
"find_useful_part_in_specific_version_manifest",
|
||||
"get_core_file_download_url_and_hash",
|
||||
"validate_version_manifest",
|
||||
"save_version_manifest",
|
||||
"fetch_and_save_version_manifest",
|
||||
"download_core_file",
|
||||
"check_core_file_exists_and_verify",
|
||||
"LATEST_VERSION_ALIASES",
|
||||
# i18n
|
||||
"SUPPORTED_LANGUAGES",
|
||||
"TranslationManager",
|
||||
# launcher.object
|
||||
"Launcher",
|
||||
# log.default
|
||||
"DEFAULT_FORMAT",
|
||||
"DEFAULT_DATE_FORMAT",
|
||||
"get_colorful_handler",
|
||||
"LogEmitter",
|
||||
"LogCaptureHandler",
|
||||
# qt.hack
|
||||
"move_window_to_center",
|
||||
"is_main_thread",
|
||||
"recolor_standard_icon",
|
||||
"recolor_pixmap",
|
||||
"recolor_icon",
|
||||
"is_light_theme",
|
||||
"add_icon_padding",
|
||||
"data_url_to_qt_image",
|
||||
# qt.item_button
|
||||
"ItemButton",
|
||||
# qt.messagebox
|
||||
"create_messagebox",
|
||||
"error",
|
||||
"info",
|
||||
"warning",
|
||||
"error_with_plain_text",
|
||||
"ask_yes_no_with_plain_text",
|
||||
# qt.progress_dialog
|
||||
"ProgressRow",
|
||||
"ProgressDialog",
|
||||
# runtime.java
|
||||
"get_java_version",
|
||||
"find_java_installations",
|
||||
# runtime.mojang
|
||||
"MOJANG_RUNTIME_MANIFEST",
|
||||
"RUNTIME_CHECK_MAX_WORKERS",
|
||||
"RUNTIME_DOWNLOAD_MAX_WORKERS",
|
||||
"get_current_platform_runtime_key",
|
||||
"fetch_runtime_manifest",
|
||||
"find_support_runtime_manifests_info",
|
||||
"get_support_runtime_manifest",
|
||||
"RuntimeCheckResult",
|
||||
"collect_runtime_files",
|
||||
"post_process_runtime_dir",
|
||||
"download_java_runtimes",
|
||||
]
|
||||
@@ -147,4 +147,15 @@ class ArgumentError(LauncherException):
|
||||
user_message = "An error occurred while parsing arguments."
|
||||
|
||||
class ArgumentValueError(ArgumentError):
|
||||
user_message = "An invalid argument value was provided."
|
||||
user_message = "An invalid argument value was provided."
|
||||
|
||||
class LoaderUnsupportedSpecificVersion(LauncherException):
|
||||
user_message = "Loader does not support specific version."
|
||||
|
||||
def __init__(self, loader_name: str, target_version: str):
|
||||
self.loader_name = loader_name
|
||||
self.target_version = target_version
|
||||
super().__init__(f"{loader_name} does not support Minecraft {target_version}.")
|
||||
|
||||
class LoaderInstallError(LauncherException):
|
||||
user_message = "An error occurred while installing loader."
|
||||
@@ -173,7 +173,7 @@ class ArgumentMappings:
|
||||
user_type=None, user_properties=None, version_type=None, natives_directory=None,
|
||||
launcher_name=None, launcher_version=None,
|
||||
classpath=None, classpath_separator=None, library_directory=None,
|
||||
resolution: tuple[int, int] | None = None):
|
||||
resolution: tuple[int, int] | None = None, client_jar_name: str | None = None):
|
||||
self.player_name = player_name
|
||||
self.version_name = version_name
|
||||
self.game_directory = game_directory
|
||||
@@ -201,6 +201,7 @@ class ArgumentMappings:
|
||||
self.launcher_name = launcher_name
|
||||
self.launcher_version = launcher_version
|
||||
self.classpath = classpath
|
||||
self.client_jar_name = client_jar_name
|
||||
self.classpath_separator = classpath_separator
|
||||
self.library_directory = library_directory
|
||||
|
||||
@@ -443,6 +444,18 @@ def generate_launch_command(arg_maps: ArgumentMappings, main_class: str, java_pa
|
||||
arg_maps,
|
||||
)
|
||||
|
||||
# BootstrapLauncher must ignore the original client when the loader supplies
|
||||
# its patched Minecraft module. The client filename can differ from the
|
||||
# profile's version_name because manifests inherit the vanilla client JAR.
|
||||
if arg_maps.client_jar_name:
|
||||
prefix = "-DignoreList="
|
||||
for index, argument in enumerate(parsed_jvm_args):
|
||||
if argument.startswith(prefix):
|
||||
ignored = [item for item in argument[len(prefix):].split(",") if item]
|
||||
if not any(arg_maps.client_jar_name.startswith(item) for item in ignored):
|
||||
ignored.append(arg_maps.client_jar_name)
|
||||
parsed_jvm_args[index] = prefix + ",".join(ignored)
|
||||
|
||||
cmd.extend(parsed_jvm_args)
|
||||
cmd.append(main_class)
|
||||
cmd.extend(parsed_game_args)
|
||||
|
||||
@@ -15,6 +15,17 @@ from ..common.exception import UnsupportedPlatformException, NativeResolveExcept
|
||||
|
||||
logger = logging.getLogger("Launcher.CoreLib")
|
||||
|
||||
def _is_native_only_library(library: dict) -> bool:
|
||||
name = library.get("name", "")
|
||||
if re.search(r":natives-[^:@]+(?:@[^:]+)?$", name):
|
||||
return True
|
||||
downloads = library.get("downloads") or {}
|
||||
has_natives = library.get("natives") or any(
|
||||
key.startswith("natives-") for key in (downloads.get("classifiers") or {})
|
||||
)
|
||||
return bool(has_natives and not downloads.get("artifact"))
|
||||
|
||||
|
||||
def collect_library_artifacts(specific_version_manifest):
|
||||
_, _, _, _, libraries, _, _ = find_useful_part_in_specific_version_manifest(specific_version_manifest)
|
||||
|
||||
@@ -32,12 +43,8 @@ def collect_library_artifacts(specific_version_manifest):
|
||||
name = library.get("name", "")
|
||||
artifact_raw = library.get("downloads", {}).get("artifact", {})
|
||||
rules = library.get("rules", [])
|
||||
classifiers = library.get("downloads", {}).get("classifiers", {})
|
||||
natives = library.get("natives", {})
|
||||
|
||||
# Ignore natives
|
||||
if (len(natives) > 0 or bool(re.search(r":natives-[^:]+$", name)) or
|
||||
any(native.startswith("natives-") for native in classifiers)):
|
||||
# Mixed entries also contain a Java JAR needed on the classpath.
|
||||
if _is_native_only_library(library):
|
||||
logger.info(f"Skipping {name} because its a native library.")
|
||||
continue
|
||||
|
||||
@@ -350,12 +357,8 @@ def check_libraries_exists(manifest: dict, libraries_dir: Path):
|
||||
name = library.get("name", "")
|
||||
artifact_raw = library.get("downloads", {}).get("artifact", {})
|
||||
rules = library.get("rules", [])
|
||||
classifiers = library.get("downloads", {}).get("classifiers", {})
|
||||
natives = library.get("natives", {})
|
||||
|
||||
# Ignore natives
|
||||
if (len(natives) > 0 or bool(re.search(r":natives-[^:]+$", name)) or
|
||||
any(native.startswith("natives-") for native in classifiers)):
|
||||
# Mixed entries also contain a Java JAR needed on the classpath.
|
||||
if _is_native_only_library(library):
|
||||
logger.info(f"Skipping {name} because its a native library.")
|
||||
continue
|
||||
|
||||
@@ -561,12 +564,8 @@ def generate_classpath(manifest: dict, libraries_dir: Path, core_file_path: Path
|
||||
name = library.get("name", "")
|
||||
artifact_raw = library.get("downloads", {}).get("artifact", {})
|
||||
rules = library.get("rules", [])
|
||||
classifiers = library.get("downloads", {}).get("classifiers", {})
|
||||
natives = library.get("natives", {})
|
||||
|
||||
# Ignore natives
|
||||
if (len(natives) > 0 or bool(re.search(r":natives-[^:]+$", name)) or
|
||||
any(native.startswith("natives-") for native in classifiers)):
|
||||
# Mixed entries also contain a Java JAR needed on the classpath.
|
||||
if _is_native_only_library(library):
|
||||
logger.info(f"Skipping {name} because its a native library.")
|
||||
continue
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ def generate_unique_library_key(group: str, artifact: str, classifier: str | Non
|
||||
|
||||
|
||||
def normalize_library_to_common_struct(library: dict, default_maven_url: str | None = MOJANG_LIBRARIES_ENDPOINT,
|
||||
default_extension: str = "jar") -> dict:
|
||||
default_extension: str = "jar",
|
||||
ignore_missing_url=False) -> dict:
|
||||
result = deepcopy(library)
|
||||
name: str | None = library.get("name")
|
||||
|
||||
@@ -70,6 +71,13 @@ def normalize_library_to_common_struct(library: dict, default_maven_url: str | N
|
||||
|
||||
artifact_raw = dict(downloads.get("artifact") or {})
|
||||
|
||||
# Legacy native-only entries have classifiers, not a Java artifact.
|
||||
# Do not invent a base JAR that may not exist in the repository.
|
||||
if not artifact_raw and (result.get("natives") or any(
|
||||
key.startswith("natives-") for key in (downloads.get("classifiers") or {}))):
|
||||
result["downloads"] = downloads
|
||||
return result
|
||||
|
||||
# Generate new relative path and put back
|
||||
if not artifact_raw.get("path"):
|
||||
filename = generate_filename_from_maven_coordinate(
|
||||
@@ -85,7 +93,7 @@ def normalize_library_to_common_struct(library: dict, default_maven_url: str | N
|
||||
filename,
|
||||
)
|
||||
|
||||
if not artifact_raw.get("url"):
|
||||
if not artifact_raw.get("url") and not ignore_missing_url:
|
||||
top_level_url: str | None = result.get("url")
|
||||
|
||||
if top_level_url:
|
||||
@@ -231,4 +239,4 @@ def deduplicate_libraries(libraries: list[dict], preference: LibraryPreference,
|
||||
|
||||
indexed[key] = library
|
||||
|
||||
return list(indexed.values())
|
||||
return list(indexed.values())
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
import requests
|
||||
|
||||
from core_lib.common.exception import VersionManifestFetchException, VersionDataKeyNotFoundException, \
|
||||
VersionManifestException
|
||||
VersionManifestException, LoaderUnsupportedSpecificVersion
|
||||
|
||||
logger = logging.getLogger("Launcher.CoreLib")
|
||||
|
||||
@@ -16,7 +16,7 @@ FABRIC_MAVEN_URL = "https://maven.fabricmc.net/"
|
||||
def get_full_version_string(version: str, loader_version: str) -> str:
|
||||
return f"fabric-loader-{loader_version}-{version}"
|
||||
|
||||
def fetch_fabric_version_list(version_manifest_url: str=FABRIC_META_VERSION_ENDPOINT_V2, timeout: int=5) -> list[dict]:
|
||||
def fetch_fabric_versions(version_manifest_url: str=FABRIC_META_VERSION_ENDPOINT_V2, timeout: int=5) -> list[dict]:
|
||||
try:
|
||||
r = requests.get(version_manifest_url, timeout=timeout)
|
||||
except requests.exceptions.Timeout:
|
||||
@@ -80,10 +80,7 @@ def get_version_support_loader_list(target_version: str, loader_version_url: str
|
||||
)
|
||||
except requests.exceptions.HTTPError as e:
|
||||
if e.response.status_code == 404 or e.response.status_code == 400:
|
||||
raise VersionManifestFetchException(
|
||||
"HTTP error while fetch from {}: {}".format(loader_version_url, e),
|
||||
user_message="Target version {} no fabric version found".format(target_version)
|
||||
)
|
||||
raise LoaderUnsupportedSpecificVersion("fabric", target_version) from e
|
||||
else:
|
||||
raise VersionManifestFetchException(
|
||||
"HTTP error while fetch from {}: HTTP Status: {}".format(loader_version_url, e.response.status_code)
|
||||
@@ -111,10 +108,7 @@ def get_version_support_loader_list(target_version: str, loader_version_url: str
|
||||
loaders.append(loader)
|
||||
|
||||
if not loaders:
|
||||
raise VersionManifestException(
|
||||
"No available loader found in {}".format(loader_version_url),
|
||||
user_message="Target version {} no fabric version found".format(target_version)
|
||||
)
|
||||
raise LoaderUnsupportedSpecificVersion("fabric", target_version)
|
||||
|
||||
return loaders
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,26 +22,19 @@ LOADER_LIBRARY_MARKERS = {
|
||||
|
||||
|
||||
def detect_loader_name(manifest: dict) -> str | None:
|
||||
candidates = set()
|
||||
"""Read the recorded loader identity without inferring it from dependencies."""
|
||||
loader_name = manifest.get("loader")
|
||||
if isinstance(loader_name, str) and loader_name:
|
||||
return loader_name
|
||||
|
||||
for library in manifest.get("libraries", []):
|
||||
name = library.get("name", "")
|
||||
parts = name.split(":")
|
||||
# Older Forge installations already record the identity in their receipt.
|
||||
receipt = manifest.get("forgeInstall")
|
||||
if isinstance(receipt, dict):
|
||||
loader_name = receipt.get("loader")
|
||||
if isinstance(loader_name, str) and loader_name:
|
||||
return loader_name
|
||||
|
||||
if len(parts) < 3:
|
||||
continue
|
||||
|
||||
loader_name = LOADER_LIBRARY_MARKERS.get(
|
||||
(parts[0], parts[1])
|
||||
)
|
||||
if loader_name:
|
||||
candidates.add(loader_name)
|
||||
|
||||
# Return None if no loader is found or multiple loaders are found.
|
||||
if len(candidates) != 1:
|
||||
return None
|
||||
|
||||
return next(iter(candidates))
|
||||
return None
|
||||
|
||||
def find_useful_part_in_mod_version_manifest(mod_version_manifest: dict):
|
||||
ver_id = mod_version_manifest.get("id", None)
|
||||
@@ -95,7 +88,20 @@ def find_useful_part_in_mod_version_manifest(mod_version_manifest: dict):
|
||||
|
||||
def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list, inherits_maven_url=MOJANG_LIBRARIES_ENDPOINT,
|
||||
mod_maven_url=None, default_extension="jar",
|
||||
prefer_libraries_by: LibraryPreference = PREFER_MOD_LIBRARY) -> list[dict]:
|
||||
prefer_libraries_by: LibraryPreference = PREFER_MOD_LIBRARY,
|
||||
ignore_missing_url_libraries=False) -> list[dict]:
|
||||
"""
|
||||
Merge necessary dependencies
|
||||
:param inherits_libraries:
|
||||
:param mod_libraries:
|
||||
:param inherits_maven_url:
|
||||
:param mod_maven_url:
|
||||
:param default_extension:
|
||||
:param prefer_libraries_by:
|
||||
:param ignore_missing_url_libraries: Skip url regeneration if library url is missing and contains the key
|
||||
"ignoreMissingURL": true
|
||||
:return:
|
||||
"""
|
||||
|
||||
inherits = {}
|
||||
result_pre = []
|
||||
@@ -286,8 +292,9 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
# Check library download url
|
||||
endpoint = library["parsed"]["endpoint"] # maven url
|
||||
artifact_url = ((library.get("downloads") or {}).get("artifact") or {}).get("url")
|
||||
ignore_missing_url = library.get("ignoreMissingURL", False)
|
||||
|
||||
if not artifact_url and not library.get("url") and not endpoint:
|
||||
if not artifact_url and not library.get("url") and not endpoint and not ignore_missing_url:
|
||||
raise DependencyException(
|
||||
f"No download source for library {library['name']!r}."
|
||||
)
|
||||
@@ -295,7 +302,8 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
library_normalized = normalize_library_to_common_struct(
|
||||
library,
|
||||
default_maven_url=endpoint,
|
||||
default_extension=default_extension
|
||||
default_extension=default_extension,
|
||||
ignore_missing_url=ignore_missing_url
|
||||
)
|
||||
|
||||
# Cleanup and append
|
||||
@@ -363,11 +371,23 @@ def merge_manifest(inherits_version_manifest: dict, mod_version_manifest: dict,
|
||||
prefer_libraries_by=prefer_libraries_by
|
||||
)
|
||||
|
||||
# arguments
|
||||
inherits_arguments = inherits_version_manifest.get("arguments", []) or inherits_version_manifest.get("minecraftArguments", "")
|
||||
mod_arguments = mod_version_manifest.get("arguments", {}) or mod_version_manifest.get("minecraftArguments", {})
|
||||
# Modern argument arrays extend the parent. Legacy minecraftArguments is a
|
||||
# complete game command line (including vanilla options), so it replaces it.
|
||||
def read_arguments(manifest: dict) -> dict:
|
||||
arguments = deepcopy(manifest.get("arguments") or {})
|
||||
if "game" not in arguments and manifest.get("minecraftArguments"):
|
||||
arguments["game"] = shlex.split(manifest["minecraftArguments"])
|
||||
return arguments
|
||||
|
||||
inherits_arguments = read_arguments(inherits_version_manifest)
|
||||
mod_arguments = read_arguments(mod_version_manifest)
|
||||
if (mod_version_manifest.get("minecraftArguments")
|
||||
and "game" not in (mod_version_manifest.get("arguments") or {})):
|
||||
inherits_arguments.pop("game", None)
|
||||
|
||||
merged_manifest["arguments"] = merge_game_and_jvm_args(inherits_arguments, mod_arguments)
|
||||
# The merged manifest now has a single canonical argument representation.
|
||||
merged_manifest.pop("minecraftArguments", None)
|
||||
|
||||
# Update version number
|
||||
mod_id = mod_version_manifest.get("id")
|
||||
@@ -379,4 +399,14 @@ def merge_manifest(inherits_version_manifest: dict, mod_version_manifest: dict,
|
||||
if inherits_id:
|
||||
merged_manifest["inheritsFrom"] = inherits_id
|
||||
|
||||
return merged_manifest
|
||||
# Keep the child's recorded identity instead of inheriting the parent's.
|
||||
merged_manifest.pop("loader", None)
|
||||
loader_name = detect_loader_name(mod_version_manifest)
|
||||
if loader_name is not None:
|
||||
merged_manifest["loader"] = loader_name
|
||||
|
||||
# Processor output receipts must survive inheritance for launch-time checks.
|
||||
if "forgeInstall" in mod_version_manifest:
|
||||
merged_manifest["forgeInstall"] = deepcopy(mod_version_manifest["forgeInstall"])
|
||||
|
||||
return merged_manifest
|
||||
@@ -3,14 +3,32 @@ from core_lib.game.mod.mod_core import PREFER_MOD_LIBRARY
|
||||
MOD_LOADER_RULES = {
|
||||
"fabric": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
"maven": {
|
||||
"group": "net.fabricmc",
|
||||
"name": "fabric-loader"
|
||||
}
|
||||
},
|
||||
"forge": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
"maven": {
|
||||
"group": "net.minecraftforge",
|
||||
"name": "forge"
|
||||
}
|
||||
},
|
||||
"neoforge": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
"maven": {
|
||||
"group": "net.neoforged",
|
||||
"name": "neoforge"
|
||||
}
|
||||
},
|
||||
"quilt": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
"maven": {
|
||||
"group": "net.quiltmc",
|
||||
"name": "quilt-loader"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FORGE_LIKE_LOADERS = ["forge", "neoforge"]
|
||||
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import tempfile
|
||||
import warnings
|
||||
from collections.abc import Callable
|
||||
@@ -12,7 +13,6 @@ from ..common.common import FileObject, download_file, SUPPORTED_HASH_ALGORITHMS
|
||||
from ..common.exception import VersionManifestFetchException, NoVersionFoundException, \
|
||||
NoSpecifiedVersionKeyException, VersionDataKeyNotFoundException, VersionManifestSaveException, \
|
||||
HashMismatchException, UnsupportedHashAlgorithmException
|
||||
from ..i18n import SUPPORTED_LANGUAGES
|
||||
|
||||
MOJANG_VERSION_MANIFEST_V2 = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"
|
||||
MOJANG_VERSION_MANIFEST = "https://piston-meta.mojang.com/mc/game/version_manifest.json"
|
||||
@@ -602,6 +602,13 @@ def check_core_file_exists_and_verify(manifest: dict, core_file_path: Path,
|
||||
return True
|
||||
|
||||
|
||||
def validate_minecraft_version(version: str) -> bool:
|
||||
if not isinstance(version, str) or not re.fullmatch(
|
||||
r"[A-Za-z0-9][A-Za-z0-9._+\-]*", version):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
LATEST_VERSION_ALIASES = {
|
||||
"latest-release": {"displayName": "Latest Release"},
|
||||
"latest-snapshot": {"displayName": "Latest Snapshot"},
|
||||
|
||||
Reference in new issue
Block a user