Skip to content

Commit f013609

Browse files
committed
feat: update NPC display name handling to use SurfComponentBuilder and increment version
1 parent 78b09b2 commit f013609

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
kotlin.code.style=official
22
kotlin.stdlib.default.dependency=false
33
org.gradle.parallel=true
4-
version=1.21.7-1.0.1-SNAPSHOT
4+
version=1.21.7-1.1.0-SNAPSHOT

surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/dsl/NpcDslBuilder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dev.slne.surf.npc.api.npc.rotation.NpcRotationType
77
import dev.slne.surf.npc.api.npc.skin.NpcSkin
88
import dev.slne.surf.npc.api.result.NpcCreationResult
99
import dev.slne.surf.npc.api.surfNpcApi
10-
import net.kyori.adventure.text.Component
10+
import dev.slne.surf.surfapi.core.api.messages.builder.SurfComponentBuilder
1111

1212
/**
1313
* Builder class for creating NPCs using a DSL.
@@ -16,7 +16,7 @@ class NpcDslBuilder {
1616
/**
1717
* The display name of the NPC.
1818
*/
19-
lateinit var displayName: Component
19+
lateinit var displayName: SurfComponentBuilder.() -> Unit
2020

2121
/**
2222
* The unique name of the NPC.
@@ -135,7 +135,7 @@ suspend fun skin(name: String): NpcSkin {
135135
fun npc(block: NpcDslBuilder.() -> Unit): NpcCreationResult {
136136
val builder = NpcDslBuilder().apply(block)
137137
return surfNpcApi.createNpc(
138-
displayName = builder.displayName,
138+
displayName = SurfComponentBuilder.builder().apply(builder.displayName).build(),
139139
uniqueName = builder.uniqueName,
140140
skin = builder.skin,
141141
location = builder.location,

surf-npc-example-dsl/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ class SurfNpcExamplePlugin() : SuspendingJavaPlugin() {
1919
* Creates an example NPC using the DSL provided by the Surf-NPC API.
2020
*/
2121
npc {
22-
displayName =
23-
MiniMessage.miniMessage().deserialize("<rainbow>Example Npc by surf-npc-example")
22+
displayName = {
23+
append(
24+
MiniMessage.miniMessage()
25+
.deserialize("<rainbow>Example Npc by surf-npc-example")
26+
)
27+
}
28+
2429
uniqueName = "example_npc"
2530

2631
/**

0 commit comments

Comments
 (0)