Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 5ef6899

Browse files
committed
fix tests
1 parent 0839874 commit 5ef6899

File tree

6 files changed

+181
-177
lines changed

6 files changed

+181
-177
lines changed

src/main/kotlin/io/github/dockyardmc/scroll/HoverEvent.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ sealed class HoverEvent {
8585
override val type: String = "show_entity"
8686

8787
override fun getNbt(): CompoundBinaryTag {
88-
val nbt = super.getNbt()
89-
nbt.putString("id", id)
90-
nbt.putString("uuid", uuid)
91-
if (name != null) nbt.put("name", name.toNBT())
88+
var nbt = super.getNbt()
89+
nbt = nbt.putString("id", id)
90+
nbt = nbt.putString("uuid", uuid)
91+
if (name != null) nbt = nbt.put("name", name.toNBT())
9292

9393
return nbt
9494
}

src/main/kotlin/io/github/dockyardmc/scroll/extensions/ExtendedMutableNBTCompound.kt

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
package io.github.dockyardmc.scroll.extensions
22

33
import io.github.dockyardmc.scroll.Component
4-
import io.github.dockyardmc.scroll.serializers.NbtToComponentSerializer
4+
import io.github.dockyardmc.scroll.serializers.ComponentSerializer
5+
import net.kyori.adventure.nbt.BinaryTag
56
import net.kyori.adventure.nbt.CompoundBinaryTag
7+
import net.kyori.adventure.nbt.TagStringIO
68

79
fun CompoundBinaryTag.toComponent(): Component {
8-
return NbtToComponentSerializer.serializeNbt(this)
10+
return ComponentSerializer.nbtToComponent(this)
11+
}
12+
13+
fun CompoundBinaryTag.contains(key: String): Boolean {
14+
return get(key) != null
15+
}
16+
17+
fun BinaryTag.toSNBT(): String {
18+
return TagStringIO.get().asString(this)
919
}

src/main/kotlin/io/github/dockyardmc/scroll/serializers/ComponentSerializer.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.github.dockyardmc.scroll.serializers
33
import io.github.dockyardmc.scroll.ClickEvent
44
import io.github.dockyardmc.scroll.Component
55
import io.github.dockyardmc.scroll.HoverEvent
6+
import io.github.dockyardmc.scroll.extensions.contains
67
import net.kyori.adventure.nbt.*
78

89
object ComponentSerializer {
@@ -57,11 +58,11 @@ object ComponentSerializer {
5758
}
5859

5960
fun componentToNbt(component: Component): CompoundBinaryTag {
60-
val compound = CompoundBinaryTag.empty()
61+
val compound = CompoundBinaryTag.builder()
6162

6263
if (component.color != null) compound.putString("color", component.color!!)
6364
if (component.shadowColor != null) {
64-
val list = ListBinaryTag.listBinaryTag(BinaryTagTypes.DOUBLE, component.shadowColor!!.map { color -> DoubleBinaryTag.doubleBinaryTag(color) })
65+
val list = ListBinaryTag.listBinaryTag(BinaryTagTypes.DOUBLE, component.shadowColor!!.map { color -> DoubleBinaryTag.doubleBinaryTag(color / 255.0) })
6566
compound.put("shadow_color", list)
6667
}
6768

@@ -96,7 +97,7 @@ object ComponentSerializer {
9697
}
9798

9899

99-
return compound
100+
return compound.build()
100101
}
101102

102103
}

src/main/kotlin/io/github/dockyardmc/scroll/serializers/NbtToComponentSerializer.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)