Documentation

MCQuery
in package

Abstraction over xPaw\MinecraftQuery & xPaw\MinecraftPing to make them fit with our needs.

Tags
author

Samerton

version
2.0.0-pr13
license

MIT

Table of Contents

Constants

COLOUR_CHAR  = '§'
COLOURS  = ['AA0000' => '4', 'FF5555' => 'c', 'FFAA00' => '6', 'FFFF55' => 'e', '00AA00' => '2', '55FF55' => 'a', '55FFFF' => 'b', '00AAAA' => '3', '0000AA' => '1', '5555FF' => '9', 'FF55FF' => 'd', 'AA00AA' => '5', 'FFFFFF' => 'f', 'AAAAAA' => '7', '555555' => '8', '000000' => '0']

Methods

formatPlayerList()  : array<string|int, mixed>
Formats a list of players into something useful for the frontend.
multiQuery()  : array<string|int, mixed>
Query multiple servers.
singleQuery()  : array<string|int, mixed>
Query a single server.
colorDiff()  : int
Find the numerical difference between two RGB colours.
getColor()  : string
Find the closest MC colour to a given hex colour.
getMotd()  : string
Convert a Minecraft MOTD to its legacy colour codes.

Constants

COLOUR_CHAR

private mixed COLOUR_CHAR = '§'

COLOURS

private mixed COLOURS = ['AA0000' => '4', 'FF5555' => 'c', 'FFAA00' => '6', 'FFFF55' => 'e', '00AA00' => '2', '55FF55' => 'a', '55FFFF' => 'b', '00AAAA' => '3', '0000AA' => '1', '5555FF' => '9', 'FF55FF' => 'd', 'AA00AA' => '5', 'FFFFFF' => 'f', 'AAAAAA' => '7', '555555' => '8', '000000' => '0']

Methods

formatPlayerList()

Formats a list of players into something useful for the frontend.

public static formatPlayerList(array<string|int, mixed> $player_list) : array<string|int, mixed>
Parameters
$player_list : array<string|int, mixed>

Unformatted array of players in format 'id' => string (UUID), 'name' => string (username)

Return values
array<string|int, mixed>

Array of formatted players

multiQuery()

Query multiple servers.

public static multiQuery(array<string|int, mixed> $servers, string $type, Language $language, bool $accumulate) : array<string|int, mixed>
Parameters
$servers : array<string|int, mixed>

Servers

$type : string

Type of query to use (internal or external)

$language : Language

Query language object

$accumulate : bool

Whether to return as one accumulated result or not

Return values
array<string|int, mixed>

Array containing query result

singleQuery()

Query a single server.

public static singleQuery(array<string|int, mixed> $ip, string $type, bool $bedrock, Language $language) : array<string|int, mixed>
Parameters
$ip : array<string|int, mixed>

Array ['ip' => string, 'pre' => int] - 'ip' contains ip:port, 'pre' 1 for pre-Minecraft 1.7 otherwise 0

$type : string

Type of query to use (internal or external).

$bedrock : bool

Whether this is a Bedrock server or not.

$language : Language

Query language object.

Return values
array<string|int, mixed>

Array containing query result.

colorDiff()

Find the numerical difference between two RGB colours.

private static colorDiff(mixed $rgb1, mixed $rgb2) : int
Parameters
$rgb1 : mixed

RGB colour code

$rgb2 : mixed

RGB colour code

Return values
int

The difference between two RGB colours

getColor()

Find the closest MC colour to a given hex colour.

private static getColor(string $rgb) : string
Parameters
$rgb : string

RGB colour code

Return values
string

The closest Minecraft colour code to the given RGB value

getMotd()

Convert a Minecraft MOTD to its legacy colour codes.

private static getMotd(string $text, array<string|int, mixed> $modern_format) : string
Parameters
$text : string

Legacy MOTD single-line text

$modern_format : array<string|int, mixed>

Array of modern MOTD format strings

Return values
string

MOTD as legacy MC colours


        
On this page

Search results