Add literal text docs
This commit is contained in:
119
guide/docs/extensions/literal_text.md
Normal file
119
guide/docs/extensions/literal_text.md
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
# Literal text API
|
||||||
|
|
||||||
|
## Create a text object
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val text = literalText("base text") {
|
||||||
|
// the text builder
|
||||||
|
}
|
||||||
|
|
||||||
|
// or
|
||||||
|
|
||||||
|
val text = literalText {
|
||||||
|
// the text builder
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add children text objects
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
text("children text") {
|
||||||
|
// children text builder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Format the text
|
||||||
|
|
||||||
|
Text formatting:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
bold = true
|
||||||
|
italic = true
|
||||||
|
underline = true
|
||||||
|
strikethrough = true
|
||||||
|
obfuscate = true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Color:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
color = col(0xFF7463)
|
||||||
|
color = col("#FF7463")
|
||||||
|
color = KColors.INDIANRED
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
### Hover event
|
||||||
|
|
||||||
|
#### General hover event
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
hoverEvent = HoverEvent(action, content)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Show hover text
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
hoverText("you hovered me") {
|
||||||
|
// hover text builder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Click event
|
||||||
|
|
||||||
|
#### General click event
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
clickEvent = ClickEvent(action, value)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Execute command
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
onClickCommand("/me hoho", onlySuggest = true)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Copy a String
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
onClickCopy("https://github.com/bluefireoly/KSpigot")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Special
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
// line break
|
||||||
|
newLine()
|
||||||
|
// an empty line (two line breaks)
|
||||||
|
emptyLine()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add bungee components
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
literalText("base text") {
|
||||||
|
// e.g. add a TranslatableComponent
|
||||||
|
text(TranslatableComponent("translation.key")) {
|
||||||
|
// optional text body
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
@@ -39,6 +39,7 @@ nav:
|
|||||||
- Event listener: extensions/listener.md
|
- Event listener: extensions/listener.md
|
||||||
- Tasks: extensions/tasks.md
|
- Tasks: extensions/tasks.md
|
||||||
- Item builder: extensions/itembuilder.md
|
- Item builder: extensions/itembuilder.md
|
||||||
|
- Literal text: extensions/literal_text.md
|
||||||
- Gui:
|
- Gui:
|
||||||
- Compounds: gui/compounds.md
|
- Compounds: gui/compounds.md
|
||||||
- Commands:
|
- Commands:
|
||||||
|
Reference in New Issue
Block a user