Documentation
¶
Index ¶
- Constants
- Variables
- func EscapeTags(input string, placeholders ...Placeholder) string
- func FromHex(s string) *colorful.Color
- func HSVColor(h, s, v float64) *colorful.Color
- func LerpColor(t float64, a, b *colorful.Color) *colorful.Color
- func NamedColorName(c *colorful.Color) string
- func Parse(str string) string
- func PlainText(c *Component) string
- func RGB(r, g, b float64) *colorful.Color
- func ResolveColor(name string) *colorful.Color
- func Serialize(c *Component) string
- func StripTags(input string, placeholders ...Placeholder) string
- type ClickAction
- type ClickEvent
- type Component
- type HoverAction
- type HoverEvent
- type ParseError
- type Placeholder
- type Style
- type TokenType
- type TriState
Constants ¶
View Source
const ( Bold = "bold" Italic = "italic" Underlined = "underlined" Strikethrough = "strikethrough" Obfuscated = "obfuscated" )
Decoration names
Variables ¶
View Source
var AllDecorations = []string{Bold, Italic, Underlined, Strikethrough, Obfuscated}
Functions ¶
func EscapeTags ¶
func EscapeTags(input string, placeholders ...Placeholder) string
func NamedColorName ¶
NamedColorName returns the Minecraft name of c if it exactly matches one of minekube's named colors, or "" otherwise. (We do not use NearestNamed because that would report a nearest match for arbitrary colors.)
func ResolveColor ¶
ResolveColor resolves a named Minecraft color (delegating to minekube's color.Names) or a #rrggbb / #rgb hex literal into a *colorful.Color. colorful is kept as the public exchange type since minekube's color.RGB is a colorful.Color underneath.
func StripTags ¶
func StripTags(input string, placeholders ...Placeholder) string
Types ¶
type ClickAction ¶
type ClickAction string
const ( OpenURL ClickAction = "open_url" OpenFile ClickAction = "open_file" RunCommand ClickAction = "run_command" SuggestCommand ClickAction = "suggest_command" ChangePage ClickAction = "change_page" CopyToClipboard ClickAction = "copy_to_clipboard" )
Click actions
type ClickEvent ¶
type ClickEvent struct {
Action ClickAction
Value string
}
type Component ¶
func Deserialize ¶
func Deserialize(input string, placeholders ...Placeholder) (*Component, error)
func DeserializeStrict ¶
func DeserializeStrict(input string, placeholders ...Placeholder) (*Component, error)
type HoverAction ¶
type HoverAction string
const (
ShowText HoverAction = "show_text"
)
Hover actions
type HoverEvent ¶
type HoverEvent struct {
Action HoverAction
Value *Component
}
type ParseError ¶
type ParseError struct {
Message string
}
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Placeholder ¶
func ComponentPlaceholder ¶
func ComponentPlaceholder(name string, c *Component) Placeholder
func StringPlaceholder ¶
func StringPlaceholder(name, value string) Placeholder
func TextPlaceholder ¶
func TextPlaceholder(name, miniMessage string) Placeholder
type Style ¶
type Style struct {
Color *colorful.Color
Decorations map[string]TriState
ClickEvent *ClickEvent
HoverEvent *HoverEvent
Insertion *string
Font *string
}
Click to show internal directories.
Click to hide internal directories.