Move to new, _good_ API
This commit is contained in:
parent
053c263439
commit
13ee7f05ff
2 changed files with 17 additions and 14 deletions
21
forgeserv.js
21
forgeserv.js
|
|
@ -25,10 +25,13 @@ const update = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderServer = async (server) => {
|
const renderServer = async (server) => {
|
||||||
const { name, id, port, hasPackVer, dynmapUrl } = server;
|
const { name, id, url, hasPackVer, dynmapUrl } = server;
|
||||||
|
|
||||||
const resp = await fetch(`https://mc.api.forgeserv.net/server/status?ip=forgeserv.net&port=${port}`);
|
// const resp = await fetch(`https://mc.api.forgeserv.net/server/status?ip=forgeserv.net&port=${port}`);
|
||||||
const data = await resp.json();
|
const resp = await fetch(`https://api.mcsrvstat.us/2/${url}`);
|
||||||
|
const { motd, players, software, version, online, icon } = await resp.json();
|
||||||
|
console.log(motd);
|
||||||
|
// const data = await resp.json();
|
||||||
|
|
||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
card.className = 'card';
|
card.className = 'card';
|
||||||
|
|
@ -52,7 +55,7 @@ const renderServer = async (server) => {
|
||||||
|
|
||||||
const icn = document.createElement('img');
|
const icn = document.createElement('img');
|
||||||
icn.className = 'icn';
|
icn.className = 'icn';
|
||||||
icn.src = data.favicon ? data.favicon : '/Resources/default-icon.png';
|
icn.src = icon || '/Resources/default-icon.png';
|
||||||
|
|
||||||
card.appendChild(img);
|
card.appendChild(img);
|
||||||
card.appendChild(icn);
|
card.appendChild(icn);
|
||||||
|
|
@ -63,19 +66,19 @@ const renderServer = async (server) => {
|
||||||
|
|
||||||
const title = document.createElement('h4');
|
const title = document.createElement('h4');
|
||||||
title.className = 'card-title mb-3';
|
title.className = 'card-title mb-3';
|
||||||
title.innerText = `${name}: (${data.online ? 'Online' : 'Offline'})`;
|
title.innerText = `${name}: (${online ? 'Online' : 'Offline'})`;
|
||||||
title.style.color = data.online ? '#7cb342' : '#ff4340';
|
title.style.color = online ? '#7cb342' : '#ff4340';
|
||||||
container.appendChild(title);
|
container.appendChild(title);
|
||||||
|
|
||||||
const ver = document.createElement('h5');
|
const ver = document.createElement('h5');
|
||||||
ver.innerText = `Server Running ${data.server.name}`;
|
ver.innerText = online ? `Server Running ${software ? software : 'Version'} ${version}` : 'Offline';
|
||||||
|
|
||||||
const cnt = document.createElement('h6');
|
const cnt = document.createElement('h6');
|
||||||
cnt.innerText = `${data.players.now}/${data.players.max} Players Online`;
|
cnt.innerText = online ? `${players.online}/${players.max} Players Online` : 'Offline';
|
||||||
|
|
||||||
if (hasPackVer) {
|
if (hasPackVer) {
|
||||||
const packVer = document.createElement('h5');
|
const packVer = document.createElement('h5');
|
||||||
packVer.innerText = `Modpack Version ${extractVersion(data.motd)}`;
|
packVer.innerText = `Modpack Version ${extractVersion(motd.clean.join(" "))}`;
|
||||||
container.appendChild(packVer);
|
container.appendChild(packVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
10
servers.json
10
servers.json
|
|
@ -4,7 +4,7 @@
|
||||||
"name": "Vanilla",
|
"name": "Vanilla",
|
||||||
"id": "vanilla",
|
"id": "vanilla",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"port": 25566,
|
"url": "vanilla.forgeserv.net",
|
||||||
"hasPackVer": false,
|
"hasPackVer": false,
|
||||||
"dynmapUrl": "https://dynmap.vanilla.forgeserv.net"
|
"dynmapUrl": "https://dynmap.vanilla.forgeserv.net"
|
||||||
},
|
},
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"name": "UntouchableMC",
|
"name": "UntouchableMC",
|
||||||
"id": "untouchable",
|
"id": "untouchable",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"port": 25555,
|
"url": "untouchable.forgeserv.net",
|
||||||
"hasPackVer": false,
|
"hasPackVer": false,
|
||||||
"dynmapUrl": "https://dynmap.untouchable.forgeserv.net"
|
"dynmapUrl": "https://dynmap.untouchable.forgeserv.net"
|
||||||
},
|
},
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
"name": "Drehmal Primordial",
|
"name": "Drehmal Primordial",
|
||||||
"id": "drehmal",
|
"id": "drehmal",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"port": 25570,
|
"url": "drehmal.primordial.forgeserv.net",
|
||||||
"hasPackVer": false,
|
"hasPackVer": false,
|
||||||
"dynmapUrl": "https://dynmap.drehmal.forgeserv.net"
|
"dynmapUrl": "https://dynmap.drehmal.forgeserv.net"
|
||||||
},
|
},
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
"name": "Caves 'n Cliffs",
|
"name": "Caves 'n Cliffs",
|
||||||
"id": "caves",
|
"id": "caves",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"port": 25569,
|
"url": "caves.forgeserv.net",
|
||||||
"hasPackVer": false,
|
"hasPackVer": false,
|
||||||
"dynmapUrl": null
|
"dynmapUrl": null
|
||||||
},
|
},
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
"name": "CUIP",
|
"name": "CUIP",
|
||||||
"id": "cuip",
|
"id": "cuip",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"port": 25567,
|
"url": "cuip.vanilla.forgeserv.net",
|
||||||
"hasPackVer": null,
|
"hasPackVer": null,
|
||||||
"dynmapUrl": null
|
"dynmapUrl": null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue