jarne / QueryLibrary

πŸ—„ A library to fetch the query information of Minecraft: Bedrock Edition servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QueryLibrary

A library to fetch the query information of Minecraft: Bedrock Edition servers


Packagist version PHP version CircleCI License

β€’ Install
β€’ Usage
β€’ Examples
β€’ Contribution
β€’ License

πŸ“¦ Install

This library requires PHP 7.2 or newer in order to work correctly. You can install it with:

$ composer require jarne/querylibrary

If you don't like Composer, you can also clone the repository with:

$ git clone https://github.com/jarne/QueryLibrary

πŸ‘¨β€πŸ’» Usage

There is only one function called fetch to get the query information of a server. You must enter the IP of the server. If you don't specify the port or the timeout, it'll use the default port 19132 and a timeout of 5 seconds. The data is returned in a Result-object which has functions to get each value.

/**
 * Fetch query information of a server
 *
 * @param string $ip
 * @param int $port
 * @param int $timeoutSeconds
 *
 * @return Result
 */
public function fetch(
    string $ip,
    int $port = 19132,
    int $timeoutSeconds = 5
): Result

For a list of all available get-value-functions, take a look into the Result.php file.

⌨️ Examples

As an example, we're going to fetch the default level name of a PocketMine-MP server running on the local machine.

$queryLibrary = new QueryLibrary();
$result = $queryLibrary->fetch("127.0.0.1");

echo "The default level name is " . $result->getDefaultLevelName();

πŸ™‹β€ Contribution

Contributions are always very welcome! It's completely equal if you're a beginner or a more experienced developer.

Please read our Contribution Guidelines before creating an issue or submitting a pull request.

Thanks for your interest πŸŽ‰πŸ‘!

πŸ‘¨β€βš–οΈ License

MIT

About

πŸ—„ A library to fetch the query information of Minecraft: Bedrock Edition servers

License:MIT License


Languages

Language:PHP 100.0%