diff --git a/docker-compose.yml b/docker-compose.yml index 2a91be5..7709173 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: - TZ=Asia/Novosibirsk - DOCKER_ENABLED=true - STATIC_ENABLED=true - - STATIC_RULES=crabs-games.art,^/minecraft/api/readme$,https://git.3crabs.space/api/v1/repos/user-penguin/gmancraft/contents/README.md?ref=main + - STATIC_RULES=crabs-games.art,^/minecraft/api/readme$,https://git.3crabs.space/api/v1/repos/user-penguin/gmancraft/contents/README.md?ref=main;crabs-games.art,^/minecraft/api/status$,https://api.mcsrvstat.us/3/90.189.218.191:25565 - ASSETS_LOCATION=/web - DEBUG=true - SSL_TYPE=auto diff --git a/web/minecraft/app.js b/web/minecraft/app.js index 2151373..ddefd4a 100644 --- a/web/minecraft/app.js +++ b/web/minecraft/app.js @@ -32,4 +32,27 @@ async function loadLatestBuild() { } } +async function loadServerStatus() { + const status = document.getElementById('server-status'); + try { + const response = await fetch('/minecraft/api/status', { + cache: 'no-store', + signal: AbortSignal.timeout(10000), + }); + if (!response.ok) throw new Error('Статус недоступен'); + const data = await response.json(); + if (data?.online === false) { + status.textContent = 'Сервер недоступен'; + } else if (data?.online === true && Number.isSafeInteger(data.players?.online) && data.players.online >= 0) { + status.textContent = `Игроков онлайн: ${data.players.online}`; + } else { + throw new Error('Неизвестный формат статуса'); + } + } catch { + status.textContent = 'Не удалось получить онлайн'; + } +} + loadLatestBuild(); +loadServerStatus(); +setInterval(loadServerStatus, 5 * 60 * 1000); diff --git a/web/minecraft/index.html b/web/minecraft/index.html index da740f0..2f5a169 100644 --- a/web/minecraft/index.html +++ b/web/minecraft/index.html @@ -16,6 +16,8 @@
Скачай сборку, импортируй её в Prism Launcher и заходи на сервер.
Адрес сервера 90.189.218.191:25565
Проверяем онлайн…
+ Подключиться к Телемосту ↗