|
Phpcraft
|
Public Member Functions | |
| toString (int $format=ChatComponent::FORMAT_NONE) | |
| toArray (bool $explicit=false) | |
| add ($chat) | |
| insertion (string $insertion) | |
| onClickOpenLink (string $url) | |
| onClickSendMessage (string $message) | |
| onClickSuggestMessage (string $message) | |
| onClickChangePage (int $page) | |
| black () | |
| dark_blue () | |
| dark_green () | |
| dark_aqua () | |
| dark_red () | |
| dark_purple () | |
| gold () | |
| gray () | |
| dark_gray () | |
| blue () | |
| green () | |
| aqua () | |
| red () | |
| light_purple () | |
| yellow () | |
| white () | |
| bold () | |
| strikethrough () | |
| underline () | |
| italic () | |
| obfuscate () | |
Static Public Member Functions | |
| static | downloadTranslations (string $language_code="en_GB") |
| static | container (ChatComponent... $children) |
| static | text (string $text, bool $allow_amp=false) |
| static | translate (string $key, array $with=[]) |
| static | cast ($value) |
| static | fromArray (array $array) |
| static | keybind (string $name) |
Public Attributes | |
| const | FORMAT_NONE = 0 |
| const | FORMAT_ANSI = 1 |
| const | FORMAT_SILCROW = 2 |
| const | FORMAT_AMPERSAND = 3 |
| const | FORMAT_HTML = 4 |
| $text | |
| $color = null | |
| $bold = false | |
| $italic = false | |
| $underlined = false | |
| $strikethrough = false | |
| $obfuscated = false | |
| $extra = [] | |
| $translate = null | |
| $with = [] | |
| $keybind = null | |
| $insertion = null | |
| $click_event = null | |
Static Public Attributes | |
| static | $translations |
| static | $hex_to_color |
| static | $color_to_hex |
| static | $color_to_ansi |
| static | $color_to_rgb_hex |
| static | $attributes |
| static | $attributes_legacy |
| static | $attributes_ansi |
| static | $attributes_html |
| Phpcraft\ChatComponent::add | ( | $chat | ) |
Casts $chat to a ChatComponent and adds it to $this->extra.
| array | string | null | ChatComponent | $chat |
| Phpcraft\ChatComponent::aqua | ( | ) |
Sets $this->color to "aqua".
| Phpcraft\ChatComponent::black | ( | ) |
Sets $this->color to "black".
| Phpcraft\ChatComponent::blue | ( | ) |
Sets $this->color to "blue".
| Phpcraft\ChatComponent::bold | ( | ) |
Sets $this->bold to true.
|
static |
Casts the given value into a ChatComponent.
| array | string | null | ChatComponent | $value |
|
static |
Instantiates a blank ChatComponent that only serves to contain other ChatComponent instances.
| $children | ChatComponent[] |
| Phpcraft\ChatComponent::dark_aqua | ( | ) |
Sets $this->color to "dark_aqua".
| Phpcraft\ChatComponent::dark_blue | ( | ) |
Sets $this->color to "dark_blue".
| Phpcraft\ChatComponent::dark_gray | ( | ) |
Sets $this->color to "dark_gray".
| Phpcraft\ChatComponent::dark_green | ( | ) |
Sets $this->color to "dark_green".
| Phpcraft\ChatComponent::dark_purple | ( | ) |
Sets $this->color to "dark_purple".
| Phpcraft\ChatComponent::dark_red | ( | ) |
Sets $this->color to "dark_red".
|
static |
Downloads the latest supported Minecraft version's translation for the given language into ChatComponent::$translations, so messages using a "translate" component will be displayed correctly. Note that we can't use en_US because that is compiled into Minecraft's jar and not (legally) accessible otherwise.
| string | $language_code |
|
static |
| Phpcraft\ChatComponent::gold | ( | ) |
Sets $this->color to "gold".
| Phpcraft\ChatComponent::gray | ( | ) |
Sets $this->color to "gray".
| Phpcraft\ChatComponent::green | ( | ) |
Sets $this->color to "green".
| Phpcraft\ChatComponent::insertion | ( | string | $insertion | ) |
Sets text to be inserted into the client's chat box when they shift-click the ChatComponent.
| string | $insertion |
| Phpcraft\ChatComponent::italic | ( | ) |
Sets $this->italic to true.
|
static |
Initiates a "keybind" ChatComponent.
| string | $name | The name of the key, named after the value in the options.txt, e.g. "key_key.forward" in options.txt would mean "key.forward" here, and "w" would be displayed. |
| Phpcraft\ChatComponent::light_purple | ( | ) |
Sets $this->color to "light_purple".
| Phpcraft\ChatComponent::obfuscate | ( | ) |
Sets $this->obfuscated to true.
| Phpcraft\ChatComponent::onClickChangePage | ( | int | $page | ) |
When the client clicks on the ChatComponent, the given page in the book will be opened, where 1 is the first page. Only usable in books. A ChatComponent can only have one click event.
| int | $page |
| Phpcraft\ChatComponent::onClickOpenLink | ( | string | $url | ) |
When the client clicks on the ChatComponent, the given URL will be opened. A ChatComponent can only have one click event.
| string | $url | Protocol must be "http" or "https" |
| Phpcraft\ChatComponent::onClickSendMessage | ( | string | $message | ) |
When the client clicks on the ChatComponent, the given message will be sent in chat. A ChatComponent can only have one click event.
| string | $message |
| Phpcraft\ChatComponent::onClickSuggestMessage | ( | string | $message | ) |
When the client clicks on the ChatComponent, the given message will be put into their chat box. Only usable in chat messages. A ChatComponent can only have one click event.
| string | $message |
| Phpcraft\ChatComponent::red | ( | ) |
Sets $this->color to "red".
| Phpcraft\ChatComponent::strikethrough | ( | ) |
Sets $this->strikethrough to true.
|
static |
Instantiates a ChatComponent with the given text. If the text has § format codes, they will be applied to the ChatComponent.
| string | $text | |
| bool | $allow_amp | If true, '&' will be handled like '§'. |
| Phpcraft\ChatComponent::toArray | ( | bool | $explicit = false | ) |
| bool | $explicit | Explicitly set every property, even if its value can be implied. |
| Phpcraft\ChatComponent::toString | ( | int | $format = ChatComponent::FORMAT_NONE | ) |
Converts the ChatComponent to a string.
| int | $format | The format to apply. Note that HTML format will provide a non-standard "obfuscated" tag, should any text require it. |
|
static |
Instantiates a "translate" ChatComponent.
| string | $key | |
| array | $with | An array of ChatComponent (or castable) to be used to fill in blanks in the message. |
| Phpcraft\ChatComponent::underline | ( | ) |
Sets $this->underlined to true.
| Phpcraft\ChatComponent::white | ( | ) |
Sets $this->color to "white".
| Phpcraft\ChatComponent::yellow | ( | ) |
Sets $this->color to "yellow".
|
static |
|
static |
|
static |
|
static |
| bool Phpcraft\ChatComponent::$bold = false |
| array null Phpcraft\ChatComponent::$click_event = null |
| string null Phpcraft\ChatComponent::$color = null |
|
static |
|
static |
|
static |
| Phpcraft\ChatComponent::$extra = [] |
|
static |
| string null Phpcraft\ChatComponent::$insertion = null |
Text to be inserted into the client's chat box when they shift-click the ChatComponent.
| bool Phpcraft\ChatComponent::$italic = false |
| string null Phpcraft\ChatComponent::$keybind = null |
| bool Phpcraft\ChatComponent::$obfuscated = false |
| bool Phpcraft\ChatComponent::$strikethrough = false |
| string null Phpcraft\ChatComponent::$text |
| string null Phpcraft\ChatComponent::$translate = null |
|
static |
| bool Phpcraft\ChatComponent::$underlined = false |
| Phpcraft\ChatComponent::$with = [] |
| const Phpcraft\ChatComponent::FORMAT_AMPERSAND = 3 |
&-format
| const Phpcraft\ChatComponent::FORMAT_ANSI = 1 |
| const Phpcraft\ChatComponent::FORMAT_HTML = 4 |
| const Phpcraft\ChatComponent::FORMAT_NONE = 0 |
| const Phpcraft\ChatComponent::FORMAT_SILCROW = 2 |
§-format
1.8.17