From 5e778e9fd74bcb5d20539a4a2894837e586bae74 Mon Sep 17 00:00:00 2001 From: --unset Date: Sun, 5 May 2024 10:12:10 -0400 Subject: [PATCH] Allow self-hosted repo for server builder jars --- app/classes/minecraft/bigbucket.py | 7 ++++--- app/classes/shared/helpers.py | 1 + app/classes/shared/tasks.py | 6 +++--- app/classes/web/routes/api/crafty/config/index.py | 1 + app/classes/web/server_handler.py | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/classes/minecraft/bigbucket.py b/app/classes/minecraft/bigbucket.py index 1a0eddec..203cb484 100644 --- a/app/classes/minecraft/bigbucket.py +++ b/app/classes/minecraft/bigbucket.py @@ -18,8 +18,9 @@ logger = logging.getLogger(__name__) class BigBucket: def __init__(self, helper): self.helper = helper - self.base_url = "https://jars.arcadiatech.org" - self.paper_base = "https://api.papermc.io" + self.base_url = str( + self.helper.get_setting("big_bucket_repo", "https://jars.arcadiatech.org") + ).rstrip("/") def _read_cache(self) -> dict: cache_file = self.helper.big_bucket_cache @@ -29,7 +30,7 @@ class BigBucket: cache = json.load(f) except Exception as e: - logger.error(f"Unable to read serverjars.com cache file: {e}") + logger.error(f"Unable to read big_bucket cache file: {e}") return cache diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index f0073b19..55a588fc 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -516,6 +516,7 @@ class Helpers: "monitored_mounts": mounts, "dir_size_poll_freq_minutes": 5, "crafty_logs_delete_after_days": 0, + "big_bucket_repo": "https://jars.arcadiatech.org", } def get_all_settings(self): diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index f24afdb6..b9513441 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -686,15 +686,15 @@ class TasksManager: ) def big_bucket_cache_refresher(self): - logger.info("Refreshing serverjars.com cache on start") + logger.info("Refreshing big bucket cache on start") self.controller.big_bucket.refresh_cache() - logger.info("Scheduling Serverjars.com cache refresh service every 12 hours") + logger.info("Scheduling big bucket cache refresh service every 12 hours") self.scheduler.add_job( self.controller.big_bucket.refresh_cache, "interval", hours=12, - id="serverjars", + id="big_bucket", ) def realtime(self): diff --git a/app/classes/web/routes/api/crafty/config/index.py b/app/classes/web/routes/api/crafty/config/index.py index 40504d76..0c2f196c 100644 --- a/app/classes/web/routes/api/crafty/config/index.py +++ b/app/classes/web/routes/api/crafty/config/index.py @@ -31,6 +31,7 @@ config_json_schema = { "monitored_mounts": {"type": "array"}, "dir_size_poll_freq_minutes": {"type": "integer"}, "crafty_logs_delete_after_days": {"type": "integer"}, + "big_bucket_repo": {"type": "string"}, }, "additionalProperties": False, "minProperties": 1, diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py index c44de945..6bb2e5c2 100644 --- a/app/classes/web/server_handler.py +++ b/app/classes/web/server_handler.py @@ -146,8 +146,8 @@ class ServerHandler(BaseHandler): return page_data["server_api"] = False if page_data["online"]: - page_data["server_api"] = self.helper.check_address_status( - "https://api.serverjars.com" + page_data["server_api"] = ( + self.controller.big_bucket._check_bucket_alive() ) page_data["server_types"] = self.controller.big_bucket.get_bucket_data() page_data["js_server_types"] = json.dumps(