|
Phpcraft
|
Static Public Member Functions | |
| static | getProfiles (bool $bypass_cache=false) |
| static | getProfilesFile () |
| static | getMinecraftFolder () |
| static | isWindows () |
| static | saveProfiles (array $profiles) |
| static | getCachableJson (string $url) |
| static | maintainCache () |
| static | httpPOST (string $url, array $data) |
| static | resolve (string $server) |
| static | binaryStringToBin (string $str) |
| static | binaryStringToHex (string $str) |
| static | sha1 (string $str) |
| static | chatToText ($chat, int $format=ChatComponent::FORMAT_NONE, ?array $translations=null) |
| static | getServerStatus (string $server_name, int $server_port=25565, float $timeout=3.000, int $method=Phpcraft::METHOD_ALL) |
| static | textToChat (string $text, bool $allow_amp=false) |
| static | colorDiff (array $rgb1, array $rgb2) |
| static | recursivelyDelete (string $path) |
Public Attributes | |
| const | SRC_DIR = __DIR__ |
| const | INSTALL_DIR = self::SRC_DIR.'/..' |
| const | BIN_DIR = self::INSTALL_DIR.'/bin' |
| const | DATA_DIR = self::INSTALL_DIR.'/data' |
| const | FORMAT_NONE = 0 |
| const | FORMAT_ANSI = 1 |
| const | FORMAT_SILCROW = 2 |
| const | FORMAT_AMPERSAND = 3 |
| const | FORMAT_HTML = 4 |
| const | METHOD_ALL = 0 |
| const | METHOD_MODERN = 1 |
| const | METHOD_LEGACY = 2 |
Static Public Attributes | |
| static | $json_cache |
| static | $user_cache |
|
static |
|
static |
|
static |
| array | string | null | ChatComponent | $chat | |
| int | $format | |
| array<string,string>|null | $translations |
|
static |
Calculates the "distance" between two RGB arrays (each 3 integers).
| array{int,int,int} | $rgb1 |
| array{int,int,int} | $rgb2 |
|
static |
Returns the contents of a JSON file as associative array with additional memory and disk caching levels.
| string | $url | The URL of the resource. |
| IOException |
|
static |
Returns the path of the .minecraft folder without a folder seperator at the end.
|
static |
Returns the contents of Minecraft's launcher_profiles.json with some values being set if they are unset.
| bool | $bypass_cache | Set this to true if you anticipate external changes to the file. |
|
static |
Returns the path of Minecraft's launcher_profiles.json.
|
static |
Returns the server list ping as multi-dimensional array with the addition of the "ping" value which is in seconds. In an error case, an empty array is returned. Here's an example:
[
"version" => [
"name" => "1.12.2",
"protocol" => 340
],
"players" => [
"online" => 1,
"max" => 20,
"sample" => [
[
"name" => "timmyRS",
"id" => "e0603b59-2edc-45f7-acc7-b0cccd6656e1"
]
]
],
"description" => [
"text" => "A Minecraft Server"
],
"favicon" => "data:image/png;base64,<data>",
"ping" => 0.068003177642822
] Note that a server might not present all of these values, so always check with isset or array_key_exists first. description should always be a valid chat component.
| string | $server_name | |
| int | $server_port | |
| float | $timeout | The amount of seconds to wait for a response with each method. |
| int | $method | The method(s) used to get the status. 2 = legacy list ping, 1 = modern list ping, 0 = both. |
| IOException |
|
static |
Sends an HTTP POST request with a JSON payload. The response will always contain a "status" value which will be the HTTP response code, e.g. 200.
| string | $url | |
| array | $data |
|
static |
Returns true if the code is running on a Windows machine.
|
static |
|
static |
Recursively deletes a folder.
| string | $path |
|
static |
Resolves the given address.
| string | $server | The server address, e.g. localhost |
|
static |
Saves the profiles array into Minecraft's launcher_profiles.json.
| array | $profiles |
|
static |
Generates a Minecraft-style SHA1 hash.
| string | $str |
|
static |
| string | $text | |
| boolean | $allow_amp |
|
static |
|
static |
| const Phpcraft\Phpcraft::BIN_DIR = self::INSTALL_DIR.'/bin' |
| const Phpcraft\Phpcraft::DATA_DIR = self::INSTALL_DIR.'/data' |
| const Phpcraft\Phpcraft::FORMAT_AMPERSAND = 3 |
| const Phpcraft\Phpcraft::FORMAT_ANSI = 1 |
| const Phpcraft\Phpcraft::FORMAT_HTML = 4 |
| const Phpcraft\Phpcraft::FORMAT_NONE = 0 |
| const Phpcraft\Phpcraft::FORMAT_SILCROW = 2 |
| const Phpcraft\Phpcraft::INSTALL_DIR = self::SRC_DIR.'/..' |
| const Phpcraft\Phpcraft::METHOD_ALL = 0 |
Modern list ping. Legacy if that fails.
| const Phpcraft\Phpcraft::METHOD_LEGACY = 2 |
| const Phpcraft\Phpcraft::METHOD_MODERN = 1 |
| const Phpcraft\Phpcraft::SRC_DIR = __DIR__ |
1.8.17