Skip to content

Commit bb93760

Browse files
peco2282junie-agent
andcommitted
Restore adventure/README.md
Co-authored-by: Junie <junie@jetbrains.com>
1 parent d6c309d commit bb93760

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

adventure/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# DevCore Adventure
2+
3+
[English] | [[日本語](README.ja.md)]
4+
5+
Provides a DSL for making the Adventure library (KyoriPowered) easier to use from Kotlin.
6+
7+
## Features
8+
9+
- Construct text components using an intuitive DSL
10+
- Type-safe styling
11+
- Easy application of colors, decorations, click, and hover events
12+
- Joining and collecting various components
13+
14+
## Install (Gradle Kotlin DSL)
15+
16+
```kotlin
17+
dependencies {
18+
implementation("com.peco2282.devcore:adventure:<version>")
19+
// or:
20+
// implementation(platform("com.peco2282.devcore:devcore-bom:<version>"))
21+
// implementation("com.peco2282.devcore:adventure")
22+
}
23+
```
24+
25+
## Usage
26+
27+
### Basic Text Construction
28+
29+
Construct within the `component` block using the `text` function.
30+
31+
```kotlin
32+
val msg = component {
33+
text("Hello")
34+
space()
35+
text("World") {
36+
blue()
37+
bold()
38+
italic()
39+
}
40+
}
41+
```
42+
43+
### Styling DSL
44+
45+
A wide range of styling methods are available through the `Styler` interface.
46+
47+
- **Colors**: `red()`, `green()`, `blue()`, `yellow()`, `color(0xFF0000)`, `color("#FF0000")`
48+
- **Decorations**: `bold()`, `italic()`, `underline()`, `strikethrough()`, `obfuscated()`
49+
- **Events**:
50+
- `runCommand("/help")`
51+
- `suggestCommand("/msg ")`
52+
- `openUrl("https://...")`
53+
- `copyToClipboard("text")`
54+
- `showText("Hover message")`
55+
- `showItem(key, count)`
56+
- **Other**: `font("minecraft:default")`, `insertion("shift-click text")`
57+
58+
### Joining Components
59+
60+
You can join multiple components with a specific separator.
61+
62+
```kotlin
63+
val list = component(joiner = { it.join(" | ") }) {
64+
append("Item 1")
65+
append("Item 2")
66+
append("Item 3")
67+
}
68+
// Result: Item 1 | Item 2 | Item 3
69+
```
70+
71+
### Advanced Features
72+
73+
- **Conditional Styling**: `whenTrue(condition) { ... }`
74+
- **Translation**: `translatable("key.name")`, `translatableAny("key", arg1, arg2)`
75+
- **Selectors**: `selector("@a[distance=..5]")`
76+
- **Keybind**: `keybind("key.jump")`
77+
- **NBT**: `blockNbt`, `entityNbt`, `storageNbt` (Experimental)
78+

0 commit comments

Comments
 (0)