Make HoverEvent struct work.
This commit is contained in:
@ -2,12 +2,17 @@ package chat
|
|||||||
|
|
||||||
// HoverEvent defines an event that occurs when this component hovered over.
|
// HoverEvent defines an event that occurs when this component hovered over.
|
||||||
type HoverEvent struct {
|
type HoverEvent struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
Value Message `json:"value"`
|
Value []HoverSub `json:"value"` // The issue i found is the fact the json is different now, it wasnt parsing properly because Message was invalid, its a listed dict.
|
||||||
|
}
|
||||||
|
|
||||||
|
type HoverSub struct {
|
||||||
|
Color string `json:"color"`
|
||||||
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShowText show the text to display.
|
// ShowText show the text to display.
|
||||||
func ShowText(text Message) *HoverEvent {
|
func ShowText(text []HoverSub) *HoverEvent {
|
||||||
return &HoverEvent{
|
return &HoverEvent{
|
||||||
Action: "show_text",
|
Action: "show_text",
|
||||||
Value: text,
|
Value: text,
|
||||||
@ -18,17 +23,29 @@ func ShowText(text Message) *HoverEvent {
|
|||||||
// Item is encoded as the S-NBT format, nbt.StringifiedMessage could help.
|
// Item is encoded as the S-NBT format, nbt.StringifiedMessage could help.
|
||||||
// See: https://wiki.vg/Chat#:~:text=show_item,in%20red%20instead.
|
// See: https://wiki.vg/Chat#:~:text=show_item,in%20red%20instead.
|
||||||
func ShowItem(item string) *HoverEvent {
|
func ShowItem(item string) *HoverEvent {
|
||||||
|
T := Text(item)
|
||||||
return &HoverEvent{
|
return &HoverEvent{
|
||||||
Action: "show_item",
|
Action: "show_item",
|
||||||
Value: Text(item),
|
Value: []HoverSub{
|
||||||
|
{
|
||||||
|
Color: T.Color,
|
||||||
|
Text: T.Text,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShowEntity show an entity describing by the S-NBT, nbt.StringifiedMessage could help.
|
// ShowEntity show an entity describing by the S-NBT, nbt.StringifiedMessage could help.
|
||||||
// See: https://wiki.vg/Chat#:~:text=show_entity,given%20entity%20loaded.
|
// See: https://wiki.vg/Chat#:~:text=show_entity,given%20entity%20loaded.
|
||||||
func ShowEntity(entity string) *HoverEvent {
|
func ShowEntity(entity string) *HoverEvent {
|
||||||
|
T := Text(entity)
|
||||||
return &HoverEvent{
|
return &HoverEvent{
|
||||||
Action: "show_entity",
|
Action: "show_entity",
|
||||||
Value: Text(entity),
|
Value: []HoverSub{
|
||||||
|
{
|
||||||
|
Color: T.Color,
|
||||||
|
Text: T.Color,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user