Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php-minecraft/minecraftquery
🛰️ Minecraft PHP library for retrieving server query data
https://github.com/php-minecraft/minecraftquery
minecraft minecraft-ping minecraft-query php ping query
Last synced: 3 months ago
JSON representation
🛰️ Minecraft PHP library for retrieving server query data
- Host: GitHub
- URL: https://github.com/php-minecraft/minecraftquery
- Owner: PHP-Minecraft
- License: mit
- Created: 2019-07-18T19:28:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-27T18:45:13.000Z (about 2 years ago)
- Last Synced: 2024-02-23T04:20:25.047Z (11 months ago)
- Topics: minecraft, minecraft-ping, minecraft-query, php, ping, query
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MinecraftQuery
🛰️ Minecraft PHP library for retrieving server query data# Installation
Required at least PHP 7.2
```
composer require php-minecraft/minecraft-query
```# Example usage
```PHP
declare(strict_types=1);require __DIR__ . '/../vendor/autoload.php';
use PHPMinecraft\MinecraftQuery\MinecraftQueryResolver;
```## Minecraft v1.7+
```PHP
$resolver = new MinecraftQueryResolver('play.minecord.net', 25565);$result = $resolver->getResult();
```
## Minecraft <= v1.6
```PHP
$resolver = new MinecraftQueryResolver('play.minecord.net', 25565);$resolver->retrieveDataPre17();
$result = $resolver->getResult();
```
## Autodetect minecraft version (if 1.7+ query fails, older will be used)
```PHP
$resolver = new MinecraftQueryResolver('play.minecord.net', 25565);$result = $resolver->getResult($tryOldQueryProtocolPre17 = true);
```
## Result data
```PHP
$result->getMaxPlayers() // integer
$result->getOnlinePlayers() // integer
$result->getPlayersSample() // array (players -> sample at https://wiki.vg/Server_List_Ping)
$result->getVersion() // string
$result->getProtocolVersion() // integer
$result->getMessageOfTheDay() // string
$result->getLatency() // integer (ms)
$result->getFavicon() // string or null
```## Tweaks
```PHP
// use this cosntructor if you dont want separate address to host and port
$resolver = MinecraftQueryResolver::fromAddress('play.minecord.net');// use this method if you want raw data in array retrieved from minecraft server
$rawData = $resolver->getRawData();// use this method if you want construct MinecraftQueryResult from raw data
$result = MinecraftQueryResult::fromRawData($rawData);
```Library (socket logic) is inspired by xPaw/PHP-Minecraft-Query