A javascript function for checking changes in a minecraft server's list of players without using query or a custom plugin.
Options can be an object:
var options = {
name: 'name',
ip: 'ip'
}
Or an array of objects:
var options = [
{
name: 'name1',
ip: 'ip1'
},
{
name: 'name2',
ip: 'ip2'
}
]
var mcstatus = require('mcserverstatus').mcstatus; // only include if using npm
mcstatus({
name: 'senious survival', // can be anything
ip: 'senious.mcph.co' // the IP of the server
}, function response(response) {
console.log(response);
});
If used in an interval, it will return the current players only once and then return consecutive join and leave messages.
setInterval(function(){
mcstatus({
name: 'name',
ip: 'ip'
},function(response){
console.log(response);
});
},1000);
When first ran it returns:
Currently [list of players] are playing on [server name].
Then if a player joins the server and the function is run again:
[playername] joined [server name]. Now there are [current players]/[max players] on the server, including [list of players].
npm install mcserverstatus
<script src="
https://rawgit.com/arcusdevteam/mcserverstatus/master/mcstatus.min.js"></script>