This allows you to easily embed your Eaglercraft server's ping, player list, and MOTD in a <div> element in an HTML5 document using the same style as the game's multiplayer screen
Demo link: https://g.eags.us/eaglercraft/ping.html
-
Download 'embed.min.js' and 'icons.png' and upload them to your server
-
Add the script:
<script type="text/javascript" src="embed.min.js"></script> -
Create a <div> like:
<div id="embed"></div> -
In your Javascript, create a new
ServerEmbedobject. Pass the <div> object and a CSS width as parameters:
var embed = new ServerEmbed(document.getElementById("embed"), "500px"); -
Call the
pingfunction on the new object:embed.ping("127.0.0.1:25565");(Replace
127.0.0.1:25565with theip:portorws://orwss://address of your server) -
You're done
The ping function takes five arguments, four of which are optional:
ping(addr, name, forceName, hideAddress, hideCracked)-
addrIs theip:portorws://orwss://address of your server -
name(Optional) Sets the name to display for the server, if left undefined then the default name displayed for the server is theserver_name:variable of config.yml of the server being pinged (once the server responds) -
forceName(Optional) Sets if thenameparameter should always be shown as the server's name instead of the pinged server's config.ymlserver_name:sent in the response to the ping. Default is false, so by default the optionalnameparameter is only shown until the server responds with it's configuredserver_name:, which is then displayed instead until the ping is sent again -
hideAddress(Optional) Sets if the second line of the server's MOTD should not display theaddrparameter on the canvas while it is still connecting, and then also if it shouldn't display theaddrwhen the destination server's response does not specify a second line in it's MOTD. Default is false -
hideCracked(Optional) Sets if the warning icon and padlock icon, which indicate if the server uses online mode or not, should be hidden from the embed so nobody can tell if your server is cracked or not. Default is false
