Documentation ¶
Overview ¶
Package component provides a way to represent Minecraft text components. Use dot import alias to keep your code lean when using structs a lot from this package.
Index ¶
- Variables
- type ActionType
- type ClickAction
- type ClickEvent
- func ChangePage(page string) ClickEvent
- func CopyToClipboard(text string) ClickEvent
- func NewClickEvent(action ClickAction, value string) ClickEvent
- func OpenFile(file string) ClickEvent
- func OpenUrl(url string) ClickEvent
- func RunCommand(command string) ClickEvent
- func SuggestCommand(command string) ClickEvent
- type Component
- type Decoration
- type Format
- type HoverAction
- type HoverEvent
- type ShowEntityHoverType
- type ShowItemHoverType
- type State
- type Style
- type Text
- type Translation
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DecorationsOrder is the order of applied decorations. DecorationsOrder = []Decoration{ Obfuscated, Bold, Strikethrough, Underlined, Italic, } // Decorations is a map of all decorations. Decorations = func() map[Decoration]struct{} { m := map[Decoration]struct{}{} for _, a := range DecorationsOrder { m[a] = struct{}{} } return m }() )
View Source
var (
DefaultFont = key.New(key.MinecraftNamespace, "default")
)
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ClickAction ¶
type ClickAction interface { Name() string // The ClickAction name. Readable() bool // When an clickAction is not readable it will not be unmarshalled. }
var ( OpenUrlAction ClickAction = &clickAction{"open_url", true} OpenFileAction ClickAction = &clickAction{"open_file", false} RunCommandAction ClickAction = &clickAction{"run_command", true} SuggestCommandAction ClickAction = &clickAction{"suggest_command", true} ChangePageAction ClickAction = &clickAction{"change_page", true} CopyToClipboardAction ClickAction = &clickAction{"copy_to_clipboard", true} ClickActions = func() map[string]ClickAction { m := map[string]ClickAction{} for _, a := range []ClickAction{ OpenUrlAction, OpenFileAction, RunCommandAction, SuggestCommandAction, ChangePageAction, CopyToClipboardAction, } { m[a.Name()] = a } return m }() )
type ClickEvent ¶
type ClickEvent interface { Action() ClickAction Value() string }
func ChangePage ¶
func ChangePage(page string) ClickEvent
func CopyToClipboard ¶
func CopyToClipboard(text string) ClickEvent
func NewClickEvent ¶
func NewClickEvent(action ClickAction, value string) ClickEvent
func OpenFile ¶
func OpenFile(file string) ClickEvent
func OpenUrl ¶
func OpenUrl(url string) ClickEvent
func RunCommand ¶
func RunCommand(command string) ClickEvent
func SuggestCommand ¶
func SuggestCommand(command string) ClickEvent
type Decoration ¶
type Decoration string
Decoration is a text decoration such as "underlined". Use the provided decoration constants.
const ( // Obfuscated is a decoration which makes text obfuscated/unreadable. Obfuscated Decoration = "obfuscated" // Bold is a decoration which makes text appear bold. Bold Decoration = "bold" // Strikethrough is a decoration which makes text have a strike through it. Strikethrough Decoration = "strikethrough" // Underlined is a decoration which makes text have an underline. Underlined Decoration = "underlined" // Italic is a decoration which makes text appear in italics. Italic Decoration = "italic" )
Decoration styles
type HoverAction ¶
type HoverAction interface { Name() string Type() ActionType Readable() bool // When a HoverAction is not readable it will not be unmarshalled. }
var ( ShowTextAction HoverAction = &hoverAction{"show_text", reflect.TypeOf(Text{}), true} ShowItemAction HoverAction = &hoverAction{"show_item", reflect.TypeOf(ShowItemHoverType{}), true} ShowEntityAction HoverAction = &hoverAction{"show_entity", reflect.TypeOf(ShowEntityHoverType{}), true} HoverActions = func() map[string]HoverAction { m := map[string]HoverAction{} for _, a := range []HoverAction{ ShowTextAction, ShowItemAction, ShowEntityAction, } { m[a.Name()] = a } return m }() )
type HoverEvent ¶
type HoverEvent interface { Action() HoverAction Value() interface{} }
func NewHoverEvent ¶
func NewHoverEvent(action HoverAction, value interface{}) HoverEvent
func ShowEntity ¶
func ShowEntity(entity *ShowEntityHoverType) HoverEvent
func ShowItem ¶
func ShowItem(item *ShowItemHoverType) HoverEvent
func ShowText ¶
func ShowText(text Component) HoverEvent
type ShowEntityHoverType ¶
type ShowItemHoverType ¶
type ShowItemHoverType struct { Item key.Key Count int NBT nbt.BinaryTagHolder // nil-able }
type Style ¶
type Style struct {
Obfuscated, Bold, Strikethrough, Underlined, Italic State
Font key.Key
Color color.Color
ClickEvent ClickEvent
HoverEvent HoverEvent
Insertion *string // Gets the string to be inserted when this component is shift-clicked.
}
Style is the style of a Component.
func (*Style) Decoration ¶
func (s *Style) Decoration(decoration Decoration) State
func (*Style) SetDecoration ¶
func (s *Style) SetDecoration(decoration Decoration, state State)
type Text ¶
func (*Text) MarshalJSON ¶ added in v0.0.6
func (*Text) SetChildren ¶
func (*Text) UnmarshalJSON ¶ added in v0.0.6
type Translation ¶
func (*Translation) Children ¶
func (t *Translation) Children() []Component
func (*Translation) MarshalJSON ¶ added in v0.0.6
func (t *Translation) MarshalJSON() ([]byte, error)
func (*Translation) SetChildren ¶
func (t *Translation) SetChildren(children []Component)
func (*Translation) Style ¶
func (t *Translation) Style() *Style
func (*Translation) UnmarshalJSON ¶ added in v0.0.6
func (t *Translation) UnmarshalJSON(b []byte) error
Click to show internal directories.
Click to hide internal directories.