Skip to content

Commit 6c9b47b

Browse files
committed
fix: correct README spelling, update modpack URLs, and improve task management in the launcher
1 parent e092b03 commit 6c9b47b

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Launcher Release-Build](https://github.com/cubedvij/launcher/actions/workflows/release.yml/badge.svg)](https://github.com/cubedvij/launcher/actions/workflows/release.yml)
44
[![Launcher Dev-Build](https://github.com/cubedvij/launcher/actions/workflows/dev.yml/badge.svg)](https://github.com/cubedvij/launcher/actions/workflows/dev.yml)
55

6-
🎮 Лаунчер для гри на сервері "Кубіний Двіж"
6+
🎮 Лаунчер для гри на сервері "Кубічний Двіж"
77

88
<img src="https://github.com/user-attachments/assets/7535707f-41ac-42ef-a1dd-4f3fdbaa7315" width="640" />
99

src/config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@
3131
STATS_API_VERSION = "v1"
3232
SERVER_IP = "play.cubedvij.pp.ua"
3333
AUTHLIB_INJECTOR_URL = "https://auth.cubedvij.pp.ua/authlib-injector"
34+
35+
MODPACK_REPO = "cubedvij/modpack"
36+
3437
CHANGELOG_URL = (
35-
"https://raw.githubusercontent.com/cubedvij/modpack/refs/heads/main/README.md"
38+
f"https://raw.githubusercontent.com/{MODPACK_REPO}/refs/heads/main/README.md"
39+
)
40+
41+
MODPACK_INDEX_URL = (
42+
f"https://raw.githubusercontent.com/{MODPACK_REPO}/refs/heads/main/modrinth.index.json"
3643
)
37-
MODPACK_REPO_URL = "https://github.com/cubedvij/modpack"
44+
MODPACK_REPO_URL = f"https://github.com/{MODPACK_REPO}"
3845
LATEST_LAUNCHER_RELEASE_URL = (
3946
"https://api.github.com/repos/cubedvij/launcher/releases/latest"
4047
)

src/modpack.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import httpx
1111

12-
from config import APPDATA_FOLDER, MODPACK_REPO_URL
12+
from config import APPDATA_FOLDER, MODPACK_REPO_URL, MODPACK_INDEX_URL
1313
from settings import settings
1414
from minecraft_launcher_lib._helper import (
1515
check_path_inside_minecraft_directory,
@@ -30,9 +30,8 @@
3030

3131
class Modpack:
3232
def __init__(self):
33-
self._repo_url = MODPACK_REPO_URL
34-
self._index_url = f"{self._repo_url}/raw/refs/heads/main/modrinth.index.json"
35-
self._zip_url = f"{self._repo_url}/archive/refs/heads/main.zip"
33+
self._index_url = MODPACK_INDEX_URL
34+
self._zip_url = f"{MODPACK_REPO_URL}/archive/refs/heads/main.zip"
3635
self._modpack_index_file = None
3736
self.name = "cubedvij"
3837
self.installed_version = None
@@ -42,9 +41,9 @@ def __init__(self):
4241
self._setup_paths()
4342
self._etag = self._get_saved_index_etag()
4443

45-
self._fetch_latest_index(force=True)
44+
# self._fetch_latest_index(force=True)
4645
self._get_installed_modpack_version()
47-
self._load_modpack_info()
46+
# self._load_modpack_info()
4847
# self._ensure_modpack_exists()
4948
# run on thread - self._ensure_modpack_exists()
5049
# executor = ThreadPoolExecutor(max_workers=1)
@@ -223,7 +222,7 @@ def install_mrpack(
223222
callback.get("setMax", empty)(len(file_list))
224223

225224
mods = []
226-
for count, file in enumerate(file_list):
225+
for _, file in enumerate(file_list):
227226
full_path = os.path.abspath(
228227
os.path.join(modpack_directory, file["path"])
229228
)
@@ -236,6 +235,9 @@ def install_mrpack(
236235
}
237236
)
238237

238+
# Clean old mods
239+
self._clean_old_mods()
240+
239241
# Download the files in parallel
240242
self.download_mods(callback, max_workers, mods)
241243

@@ -468,9 +470,6 @@ def update(self, callback: Optional[dict[Callable]] = None) -> None:
468470
if not self._download_modpack():
469471
raise RuntimeError("Failed to download modpack update")
470472

471-
# Clean old mods
472-
self._clean_old_mods()
473-
474473
options = {
475474
"skipDependenciesInstall": True,
476475
}
@@ -506,7 +505,7 @@ def _clean_old_mods(self) -> None:
506505
mod_path = os.path.join(mods_dir, mod)
507506
if os.path.isfile(mod_path) and mod.endswith(".jar"):
508507
os.remove(mod_path)
509-
logging.info(f"Removed old mod: {mod_path}")
508+
logging.info("Old mods cleaned up successfully.")
510509
else:
511510
logging.info("Mods directory does not exist, skipping cleanup.")
512511

src/routes/index.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,20 @@ async def init_tasks(self):
6666
self._latest_tasks_inited = self.page.loop.time()
6767

6868
async def on_window_event(self, event: ft.WindowEvent):
69-
logging.info(f"Window event: {event.type}")
7069
if (
7170
event.type == ft.WindowEventType.MINIMIZE
7271
or event.type == ft.WindowEventType.HIDE
72+
or event.type == ft.WindowEventType.BLUR
7373
):
7474
# kill all tasks when window is minimized
7575
self._server_status_task.cancel()
7676
self._check_launcher_updates_task.cancel()
7777
self._check_modpack_update_task.cancel()
7878
self._playtime_update_task.cancel()
79-
elif event.type == ft.WindowEventType.FOCUS or event.type == ft.WindowEventType.RESTORE:
79+
elif (
80+
event.type == ft.WindowEventType.FOCUS
81+
or event.type == ft.WindowEventType.RESTORE
82+
):
8083
# restart tasks when window is restored
8184
await self.init_tasks()
8285

@@ -105,14 +108,14 @@ async def _check_launcher_updates(self):
105108
self.page.update()
106109

107110
async def _check_modpack_update_async(self):
108-
await asyncio.to_thread(self._check_modpack_update)
111+
await asyncio.to_thread(self._check_modpack_update, force=True)
109112
while True:
110113
await asyncio.sleep(60)
111114
await asyncio.to_thread(self._check_modpack_update)
112115

113-
def _check_modpack_update(self):
116+
def _check_modpack_update(self, force: bool = False):
114117
if self.page:
115-
modpack._fetch_latest_index()
118+
modpack._fetch_latest_index(force=force)
116119
if modpack.is_up_to_date():
117120
return
118121
if modpack.installed_version == "unknown":
@@ -457,10 +460,10 @@ async def _server_status_update(self):
457460
while True:
458461
try:
459462
await asyncio.to_thread(self._update_server_status)
460-
await asyncio.sleep(10)
463+
await asyncio.sleep(5)
461464
except Exception as e:
462465
logging.info(f"Error updating server status: {e}")
463-
await asyncio.sleep(10)
466+
await asyncio.sleep(5)
464467

465468
async def _playtime_update(self):
466469
while True:
@@ -528,10 +531,10 @@ def _check_game(self, event: ft.TapEvent):
528531
self._install_minecraft()
529532
# check if modpack version is latest
530533
elif not modpack.is_up_to_date():
531-
self._update_modpack()
534+
self._update_modpack(event)
532535
# check if modpack installed correctly
533536
elif not modpack.verify_installation():
534-
self._update_modpack()
537+
self._update_modpack(event)
535538
else:
536539
self._launch_minecraft(modpack.modloader_full)
537540

@@ -633,7 +636,7 @@ def _install_minecraft(self):
633636
if self.page is not None:
634637
self.page.update()
635638

636-
def _update_modpack(self):
639+
def _update_modpack(self, event: ft.TapEvent):
637640
logging.info("Updating modpack...")
638641
self._progress_bar.visible = True
639642
self._progress_text.visible = True
@@ -654,12 +657,9 @@ def _update_modpack(self):
654657
self._check_game_button_enable()
655658
self._play_button_enable()
656659
# update version column
657-
self._version_column.controls[
658-
0
659-
].value = f"Встановлена версія: {modpack.installed_version}"
660-
self._version_column.controls[
661-
1
662-
].value = f"Остання версія: {modpack.remote_version}"
660+
self._version_tooltip.message = (
661+
f"Встановлено останню версію: {modpack.installed_version}"
662+
)
663663

664664
if self.page is not None:
665665
self.page.update()

src/stats.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ async def get_player_stats(self, uuid: str):
1717
params={"player": uuid}
1818
)
1919
# Raise an error if the request was unsuccessful
20-
response.raise_for_status()
2120
if response.status_code == 403:
2221
# rate limit exceeded
2322
return None

0 commit comments

Comments
 (0)