mops1k/minecraftserverstatus

Minecraft Server Status Query, written in PHP, with online players, motd, favicon and more server related informations without plugins and enable-query.

1.0.1 2017-02-04 22:26 UTC

This package is auto-updated.

Last update: 2024-04-29 03:50:28 UTC


README

#Minecraft Server Status

Minecraft Server Status, library to make query with online players, motd, favicon and more server related informations without plugins and enable-query.

*Tested with Spigot 1.11

Installation

composer require mops1k/minecraftserverstatus

###Tutorial

<?php
use MinecraftServerStatus\MinecraftServerStatus;

require '../vendor/autoload.php';

$status = new MinecraftServerStatus();
$status
    ->setHost('localhost')
    ->setPort(25565)
;

if (!$status->query()) {
    echo "The Server is offline!";
} else {
    $data = $status->getData();

    if ($data->getFavicon()) {
        echo "<img width=\"64\" height=\"64\" src=\"" . $data->getFavicon() . "\" /> <br>";
    }
    echo "The Server " . $data->getHostname() . " is running on " . $data->getVersion() . " and is online,
		currently are " . $data->getPlayers() . " players online
		of a maximum of " . $data->getMaxPlayers() . ". The motd of the server is '" . $data->getDescription() . "'.
		The server has a ping of " . $data->getPing() . " milliseconds.";
}

If the server is offline $status->query() returns false else it returns true and fill the server informations to $status->getData().