Skip to content

Commit

Permalink
added a display for minecraft specialization servers to display the p…
Browse files Browse the repository at this point in the history
…layer count, max player count, along with the ready state, this does not require modding the game
  • Loading branch information
Sturdyfool10 committed Dec 6, 2023
1 parent bbaaa14 commit 6163095
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/html_src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,24 @@ function checkAllServers() {
})
});
}
function updateServerInfoMCSpecialization() {
const serverInfo = window.serverInfoObj
serverInfo.servers.forEach(server => {
if (server.specialization === 'Minecraft') { // Check if the specialization is Minecraft
const serverElement = $(`.${server.name}dropdown`).find(".serverName")[0];
if (serverElement) {
if (server.active) {
const specializedInfo = server.specializedInfo['Minecraft'];
const [playerCount, maxPlayers, isReady] = specializedInfo;
const statusText = isReady ? 'Ready To Join' : 'Starting up';
serverElement.textContent = `${server.name} (${playerCount}/${maxPlayers}) (${statusText})`;
} else {
serverElement.textContent = `${server.name} (inactive)`;
}
}
}
});
}
function generateSecureSalt(lengthInBytes) {
lengthInBytes = lengthInBytes / 2
const saltArray = new Uint8Array(lengthInBytes);
Expand Down Expand Up @@ -217,6 +235,9 @@ $(document).ready(function() {
socket.onerror = function() {
hotReloadWhenReady()
}
// Set interval to update server info every quarter second
setInterval(updateServerInfoMCSpecialization, 250);

socket.onclose = function() {
hotReloadWhenReady()
}
Expand Down

0 comments on commit 6163095

Please sign in to comment.