Created
February 16, 2019 22:17
-
-
Save blalop/bea4c42f3fdcf0faf6e3d9b9423f4aec to your computer and use it in GitHub Desktop.
Get Minecraft server status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Minecraft Server Info</title> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font-family: sans-serif; | |
color: #ffffff; | |
background-color: #535760; | |
display: none; | |
} | |
</style> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script> | |
let url = "example.com"; | |
$(document).ready(() => { | |
$.getJSON("https://api.mcsrvstat.us/1/" + url, (status) => { | |
if (status.debug.ping) { | |
$("#motd").append(status.motd.raw); | |
$("#status").append("On"); | |
$("#version").append(status.version); | |
$("#players_num").append(status.players.online + "/" + status.players.max) | |
$.each(status.players.list, function (index, player) { | |
$("#players_list").append("<li>" + player + "</li>") | |
}); | |
} else { | |
$("#motd").append(status.hostname); | |
$("#status").append("Off"); | |
$("#version").hide(); | |
$("#players_num").hide(); | |
} | |
$("body").fadeIn(2000); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1 id="motd"></h1> | |
<p id="status">Status: </p> | |
<p id="version">Version: </p> | |
<p id="players_num">Players: </p> | |
<ul id="players_list"></ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment