-
Notifications
You must be signed in to change notification settings - Fork 1
Hover and Click Events
Hover events use four different methods: textHover { }
, itemHover { }
, entityHover { }
, and hoverEvent { }
. The
hoverEvent { }
method is used when there is already an available HoverEvent object which can be passed directly into
hoverEvent { someHoverEventObject }
. The other three methods are builders for creating (and applying) hover events in
a very simply way.
textHover { }
only requires one thing: the hover text. To apply the hover text, simply do the following:
ekho("hover over me!") {
style {
textHover {
hoverText = ekho("this text will be in the hover")
}
}
}
The hoverText
variable is of type Text
, so any text object can be assigned to it, including a text object built by
ekho.
Item hover events use ItemStacks, and then render information from those when hovered over. This ItemStack can either be directly passed in, or generated by the DSL. To generate the ItemStack, the item type, or a valid CompoundTag representing the ItemStack must be passed in instead. Below are a few examples.
ekho {
// Using just the item type
"show diamond shovel" {
style {
itemHover {
item = Items.DIAMOND_SHOVEL
}
}
}
// Using an already present ItemStack object
"show itemstack" {
style {
itemHover {
stack = player.mainhand.itemStack
}
}
}
// Using an existing CompoundTag
"show tag" {
style {
itemHover {
tag = someCompoundTag
}
}
}
}
Entity hovers show 3 lines: the entity's name, uuid, and entity type. The entityHover { }
allows you to define those
properties with ease, and none of them are required.
entityHover {
name = ekho("the name is a text object") // Default: no name
type = EntityType.PIG // Default: COW
uuid = someEntity.uuid // Default: UUID.randomUUID()
}
There are 6 different click event actions, and all of them only require 1 parameter. This allows for a super simple
click event builder. When creating a click event, simply choose the action and assign it to the appropriate
value. To make a click event that changes the page to page 3, simply do clickEvent { changePage = 3 }
. To run a
teleport command, it is as easy as clickEvent { runCommand = "/tp @s ~ ~10 ~" }
Action Name | Parameter |
---|---|
openUrl | url: String |
openFile | path: String |
runCommand | command: String |
suggestCommand | command: String |
changePage | page: Int |
copyToClipboard | copyText: String |
Thanks for reading, I hope it helped