From 6136fee405c0563f99b71cb0f8bc180bc3637196 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Fri, 3 Jun 2022 15:40:55 +0300 Subject: [PATCH] tool4make jar's list move to project... again --- README.md | 11 +------ TODO.md | 8 ----- tools/make_libs.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 18 deletions(-) delete mode 100644 TODO.md create mode 100644 tools/make_libs.py diff --git a/README.md b/README.md index dd4dc1a..62aeb8e 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,15 @@ # Minecraft [Java Edition] Batch Launcher -[![Download this](https://img.shields.io/badge/Download-this-lightgrey?style=for-the-badge)](https://github.com/iiiypuk/minecraft-launcher/releases/latest) [![Support me](https://img.shields.io/badge/Support-me-ff4646?style=for-the-badge)](https://ko-fi.com/iiiypuk) [![Contact me](https://img.shields.io/badge/Contact-me-blue?style=for-the-badge)](https://t.me/slexbc) +**Features:** -## Features: * 📋 Open source. Just launch the game, nothing more * 🏷️ Change player name * 🧰 No need for extra deps * ⚙️ No configuration required -![License](https://img.shields.io/github/license/iiiypuk/minecraft-launcher?style=for-the-badge) ![Latest release](https://img.shields.io/github/v/release/iiiypuk/minecraft-launcher?style=for-the-badge) ![Total downloads](https://img.shields.io/github/downloads/iiiypuk/minecraft-launcher/total?style=for-the-badge) - ## Minecraft Natives The natives catalog is located on [Mega.nz](https://mega.nz/#F!hUNg0Y6I!93cYw1NZg4MUWUHaVrCO7w). -**Notes:** -- Natives for `1.16.3` identical for `1.16.4`. - -## TODO -See [TODO.md](TODO.md). - ## ChangeLog See [CHANGELOG.md](CHANGELOG.md). diff --git a/TODO.md b/TODO.md deleted file mode 100644 index d647338..0000000 --- a/TODO.md +++ /dev/null @@ -1,8 +0,0 @@ -## TODO -- [ ] Script for automatic make release **zip** -- [ ] Make binary archives with this launcher for vanilla and forge version - -## Complete -- [x] Move docs to `gh-pages` -- [x] Реализовать параметр вывода в файл [[b38e3ca](https://github.com/iiiypuk/minecraft-launcher/commit/b38e3ca913ece59809cd98c65bf29d7cdb08750e)] -- [x] Исправить автоматический выхлоп для Windows, либо сделать оповещение об этом [[1ecc7be](https://github.com/iiiypuk/minecraft-launcher/commit/1ecc7be9ce5e074b0fa920efa9480502dba34e3a)] diff --git a/tools/make_libs.py b/tools/make_libs.py new file mode 100644 index 0000000..6af58b1 --- /dev/null +++ b/tools/make_libs.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +## Requirements PIP: click + +"""Parse Minecraft version.json file and return using libs""" + +__version__ = "1.0.5" + +import sys +import json +import click + + +@click.command() +@click.option("-p", "--platform", default=sys.platform, help="Output platform (win32, linux, darwin).") +@click.option("-o", "--output", default="tty", help="Output option (tty, txt).") +def make_output(platform, output): + """Return libraries list""" + + libraries = parse_libs() + + # OS libs separate + _ = {"win32": ";", "linux": ":", "darwin": ":"} + + out_lib = str() + + # Generate libraries list + for lib in libraries: + out_lib = out_lib + "$MC_DIR/libraries/{0}".format(lib) + _[platform] + + out_lib = out_lib + "$MC_DIR/versions/$GAME_VERSION/$GAME_VERSION.jar" + + # Replace for OS shell variable symbol + if platform == "win32": + out_lib = out_lib.replace("$MC_DIR", "%MC_DIR%") + out_lib = out_lib.replace("$GAME_VERSION", "%GAME_VERSION%") + + if output == "tty": + click.echo(out_lib) + + if platform == "win32": + print("\nWindows generate libraries list complete!") + elif platform in ("linux", "darwin"): + print("\nUnix generate libraries list complete!") + elif output == "txt": + with open("./libs.txt", "w", encoding="utf-8") as f: + f.write(out_lib) + + if platform == "win32": + print("\nWindows generate libraries list complete!\n" "See libs.txt file.") + elif platform in ("linux", "darwin"): + print("\nUnix generate libraries list complete!\n" "See libs.txt file.") + + +def parse_libs(): + """Make libraries list from version.json file""" + + _ = [] + + try: + with open("./version.json", "r", encoding="utf-8") as f: + file_data = json.loads(f.read()) + + for lib in file_data["libraries"]: + _.append(lib["downloads"]["artifact"]["path"]) + except FileNotFoundError: + print("ERROR: File version.json not found.") + sys.exit(-1) + + return _ + + +if __name__ == "__main__": + # pylint: disable=no-value-for-parameter + make_output()