PHP code example of adrien-nf / minecraft-server-status
1. Go to this page and download the library: Download adrien-nf/minecraft-server-status library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adrien-nf / minecraft-server-status example snippets
use Ping\Ping;
$infos = (new Ping("localhost", 25565))->getInfos();
echo $infos->getVersion(); // 1.20.1
echo $infos->getServerType(); // Vanilla
echo $infos->getMotd(); // A Minecraft Server
echo $infos->getMaxPlayers(); // 20
echo $infos->getPlayersCount(); // 3
echo $infos->getIp(); // localhost
echo $infos->getPort(); // 25565
// With Ping, you only get a partial player list
var_dump($infos->getPlayers()); // ["Notch", "Deadmau5"]
// Some helper functions
echo $infos->isPlayerConnected("Notch"); // true
echo $infos->isVanilla(); // true
echo $infos->isBukkit(); // false
echo $infos->isSpigot(); // false
echo $infos->isPaper(); // false
use Queries\JavaServerQuery;
$infos = (new JavaServerQuery("localhost", 25565))->getInfos();
echo $infos->getGameType(); // SMP
echo $infos->getWorldName(); // world
// With Query, you get a full players list
var_dump($infos->getPlayers()); // ["Notch", "Deadmau5", "Jeb"]
var_dump($infos->getPlugins()); // [["name" => "Shopkeepers", "version" => "2.17.1"], ["name" => "HolographicDisplays", "version" => "3.0.2"]]
// Some helper functions
echo $infos->getPluginsAsString(); // "Shopkeepers, HolographicDisplays"
echo $infos->getPluginsAsString(true); // "Shopkeepers 2.17.1, HolographicDisplays 3.0.2"
echo $infos->hasPlugin("Shopkeepers"); // true
var_dump($infos->getPluginsAsArray()) // ["Shopkeepers", "HolographicDisplays"]
var_dump($infos->getPluginsAsArray(true)) // ["Shopkeepers 2.17.1", "HolographicDisplays 3.0.2"]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.