Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jarne/querylibrary
🗄 A library to fetch the query information of Minecraft: Bedrock Edition servers
https://github.com/jarne/querylibrary
library minecraft player pocketmine-mp query
Last synced: 3 months ago
JSON representation
🗄 A library to fetch the query information of Minecraft: Bedrock Edition servers
- Host: GitHub
- URL: https://github.com/jarne/querylibrary
- Owner: jarne
- License: mit
- Created: 2017-12-08T14:13:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-22T14:12:06.000Z (over 2 years ago)
- Last Synced: 2024-10-09T23:22:22.913Z (3 months ago)
- Topics: library, minecraft, player, pocketmine-mp, query
- Language: PHP
- Homepage:
- Size: 45.9 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
QueryLibrary
A library to fetch the query information of Minecraft: Bedrock Edition servers
##
[• Install](#-install)
[• Usage](#-usage)
[• Examples](#%EF%B8%8F-examples)
[• Contribution](#-contribution)
[• License](#%EF%B8%8F-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.```php
/**
* 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](https://github.com/jarne/QueryLibrary/blob/master/src/jarne/querylibrary/utils/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.```php
$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](CONTRIBUTING.md)** before creating an issue or submitting a pull request.
Thanks for your interest 🎉👍!
## 👨⚖️ License
[MIT](https://github.com/jarne/QueryLibrary/blob/master/LICENSE)