Skip to content

Commit 3301c71

Browse files
committed
[2.3.17] Support Head
1 parent 3ddd784 commit 3301c71

21 files changed

Lines changed: 92 additions & 27 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.gradle
22
.idea
3+
.kotlin
34
build

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ subprojects {
3636
)
3737
install(JavaScript)
3838
install(Bukkit, BungeeCord, Velocity)
39+
modules.remove("minecraft-chat")
3940
disableOnSkippedVersion = false
4041
// disableOnUnsupportedVersion = false
4142
}
@@ -62,7 +63,7 @@ subprojects {
6263
compileOnly(kotlin("stdlib"))
6364
compileOnly("com.google.code.gson:gson:2.8.5")
6465
compileOnly("com.google.guava:guava:21.0")
65-
compileOnly("net.kyori:adventure-api:4.24.0")
66+
compileOnly("net.kyori:adventure-api:4.26.1")
6667
}
6768

6869
// 编译配置

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=me.arasple.mc.trchat
2-
version=2.3.16
2+
version=2.3.17
33
kotlin.incremental=true
44
kotlin.incremental.java=true
55
kotlin.caching.enabled=true

plugin/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ taboolib {
2525
// }
2626
}
2727
relocate("com.eatthepath.uuid.", "${rootProject.group}.library.uuid.")
28-
// relocate("net.md_5.bungee", "net.md_5.bungee121")
2928
// relocate("com.electronwill.nightconfig", "com.electronwill.nightconfig_3_6_7")
3029
}
3130

3231
dependencies {
3332
taboo("com.eatthepath:fast-uuid:0.2.0")
34-
// taboo("net.md-5:bungeecord-chat:1.21-R0.3") { isTransitive = false }
3533
}
3634

3735
tasks {

project/common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies {
2-
// compileOnly(project(":project:module-chat"))
2+
compileOnly(project(":project:module-chat"))
33
compileOnly("com.eatthepath:fast-uuid:0.2.0")
44
}
55

project/module-adventure/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
dependencies {
22
compileOnly(project(":project:common"))
3-
// compileOnly(project(":project:module-chat"))
3+
compileOnly(project(":project:module-chat"))
44
compileOnly("net.kyori:adventure-platform-bukkit:4.4.1")
5-
compileOnly("net.kyori:adventure-text-serializer-plain:4.24.0")
5+
compileOnly("net.kyori:adventure-text-serializer-plain:4.26.1")
66
// paper native
77
compileOnly(fileTree(rootDir.resolve("libs")))
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
dependencies {
22
compileOnly("com.google.code.gson:gson:2.8.7")
3-
compileOnly("net.md-5:bungeecord-api:1.21-R0.3")
3+
compileOnly("net.md-5:bungeecord-api:1.21-R0.4")
44
compileOnly("net.kyori:adventure-platform-bukkit:4.4.1")
5-
compileOnly("net.kyori:adventure-text-serializer-plain:4.24.0")
5+
compileOnly("net.kyori:adventure-text-serializer-plain:4.26.1")
66
}
77

88
taboolib { subproject = true }

project/module-chat/src/main/kotlin/taboolib/module/chat/ComponentText.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package taboolib.module.chat
22

33
import java.awt.Color
4+
import java.util.*
45

56
/**
67
* TabooLib
@@ -45,6 +46,9 @@ interface ComponentText : Source {
4546
/** 添加选择器文本块 */
4647
fun appendSelector(selector: String): ComponentText
4748

49+
/** 添加玩家头像文本块 */
50+
fun appendHead(name: String? = null, id: UUID? = null, hat: Boolean = true, texture: String? = null): ComponentText
51+
4852
/** 显示文本 */
4953
fun hoverText(text: String): ComponentText
5054

project/module-chat/src/main/kotlin/taboolib/module/chat/impl/AdventureComponent.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.event.ClickEvent
99
import net.kyori.adventure.text.event.HoverEvent
1010
import net.kyori.adventure.text.format.TextColor
1111
import net.kyori.adventure.text.format.TextDecoration
12+
import net.kyori.adventure.text.`object`.ObjectContents
1213
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
1314
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
1415
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer
@@ -114,6 +115,19 @@ class AdventureComponent() : ComponentText {
114115
return this
115116
}
116117

118+
override fun appendHead(name: String?, id: UUID?, hat: Boolean, texture: String?): ComponentText {
119+
flush()
120+
latest += Component.`object`(ObjectContents.playerHead().also {
121+
it.name(name)
122+
it.id(id)
123+
it.hat(hat)
124+
if (texture != null) {
125+
it.texture(Key.key(texture))
126+
}
127+
}.build())
128+
return this
129+
}
130+
117131
override fun hoverText(text: String): ComponentText {
118132
return hoverText(ComponentText.of(text))
119133
}

project/module-chat/src/main/kotlin/taboolib/module/chat/impl/DefaultComponent.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import net.md_5.bungee.api.chat.*
66
import net.md_5.bungee.api.chat.hover.content.Entity
77
import net.md_5.bungee.api.chat.hover.content.Item
88
import net.md_5.bungee.api.chat.hover.content.Text
9+
import net.md_5.bungee.api.chat.objects.PlayerObject
10+
import net.md_5.bungee.api.chat.player.Profile
911
import net.md_5.bungee.chat.ComponentSerializer
1012
import taboolib.common.UnsupportedVersionException
1113
import taboolib.common.platform.ProxyCommandSender
1214
import taboolib.common.platform.ProxyPlayer
1315
import taboolib.common.platform.function.onlinePlayers
1416
import taboolib.module.chat.*
1517
import java.awt.Color
18+
import java.util.*
1619

1720
/**
1821
* TabooLib
@@ -125,6 +128,12 @@ class DefaultComponent() : ComponentText {
125128
return this
126129
}
127130

131+
override fun appendHead(name: String?, id: UUID?, hat: Boolean, texture: String?): ComponentText {
132+
flush()
133+
latest += ObjectComponent(PlayerObject(Profile(name, id, null), hat))
134+
return this
135+
}
136+
128137
override fun hoverText(text: String): ComponentText {
129138
return hoverText(ComponentText.of(text))
130139
}

0 commit comments

Comments
 (0)