Simple implementation of Server List Ping and Query for getting status of Minecraft Server.
composer require loper/minecraft-query-clientexamples/java-ping.php
#!/usr/bin/env php<?phpdeclare(strict_types=1);
useLoper\Minecraft\Protocol\Struct\JavaProtocolVersion;
useLoper\MinecraftQueryClient\MinecraftQuery;
require_once__DIR__ . '/bootstrap.php';
returnstaticfunction (string$host, int$port) {
var_dump(MinecraftQuery::javaPing(
host: $host,
port: $port,
protocol: JavaProtocolVersion::JAVA_1_7_1
));
};examples/java-query.php
#!/usr/bin/env php<?phpdeclare(strict_types=1);
useLoper\Minecraft\Protocol\Struct\JavaProtocolVersion;
useLoper\MinecraftQueryClient\MinecraftQuery;
require_once__DIR__ . '/bootstrap.php';
returnstaticfunction (string$host, int$port) {
var_dump(MinecraftQuery::queryPing(
host: $host,
port: $port,
protocol: JavaProtocolVersion::JAVA_1_7_1
));
};examples/java-both.php
#!/usr/bin/env php<?phpdeclare(strict_types=1);
useLoper\Minecraft\Protocol\Struct\JavaProtocolVersion;
useLoper\MinecraftQueryClient\MinecraftQuery;
require_once__DIR__ . '/bootstrap.php';
returnstaticfunction (string$host, int$port) {
var_dump(MinecraftQuery::javaQueryPing(
host: $host,
port: $port,
protocol: JavaProtocolVersion::JAVA_1_7_1
));
};examples/bedrock-ping.php
#!/usr/bin/env php<?phpdeclare(strict_types=1);
useLoper\Minecraft\Protocol\Struct\BedrockProtocolVersion;
useLoper\MinecraftQueryClient\MinecraftQuery;
require_once__DIR__ . '/bootstrap.php';
returnstaticfunction (string$host, int$port) {
var_dump(MinecraftQuery::bedrockPing(
host: $host,
port: $port,
protocol: BedrockProtocolVersion::BEDROCK_1_20_15
));
};