-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (60 loc) · 2.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bonkers Minecraft Server</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Bonkers Minecraft Server</h1>
</header>
<main>
<p>
Este servidor lo creé como un proyecto personal.<br>
Actualmente está alojado en una raspberry que tengo.<br>
La versión de Minecraft es la 1.21.<br>
Y la lista de mods es la siguiente: <a href="https://drive.google.com/drive/folders/1mogJ1-P6WC7mssMz6tGhCDLD28AMm12b">aquí</a>.<br>
La dirección es la misma que la IP: <a href="http://bonkers-rasp.duckdns.org">bonkers-rasp.duckdns.org</a>.
</p>
<h2>Jugadores Conectados</h2>
<div id="status" class="status">
Cargando...
</div>
<br>
<a href="mapa.html" class="button">Ver Mapa</a>
</main>
<footer>
<p>Más información:</p>
<a href="https://linktr.ee/Konekt4">Mis redes</a> |
<a href="https://ruben-waldo.odoo.com">Sobre mi</a>
</footer>
<script>
async function fetchMinecraftStatus() {
try {
const response = await fetch('https://api.mcsrvstat.us/2/bonkers-rasp.duckdns.org');
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
if (data && data.players && data.players.online !== undefined) {
const statusDiv = document.getElementById('status');
statusDiv.innerHTML = `
<p>Online: ${data.players.online}/${data.players.max}</p>
<ul>${data.players.list ? data.players.list.map(player => `<li>${player}</li>`).join('') : '<li>No hay jugadores conectados</li>'}</ul>
`;
} else {
throw new Error('Datos inesperados en la respuesta de la API');
}
} catch (error) {
const statusDiv = document.getElementById('status');
statusDiv.innerHTML = `<p>Error al obtener el estado del servidor: ${error.message}</p>`;
}
}
// Ejecutar fetchMinecraftStatus inmediatamente y luego cada 30 segundos
fetchMinecraftStatus();
setInterval(fetchMinecraftStatus, 30000); // 30000 milisegundos = 30 segundos
</script>
</body>
</html>