Skip to content

Commit

Permalink
1.21 supports.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Jun 15, 2024
1 parent e6ae37c commit 8210e7e
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 8 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/src/main/java/kr/toxicity/hud/api/nms/NMSVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum NMSVersion {
V1_20_R1(20,1, 15),
V1_20_R2(20,2, 18),
V1_20_R3(20,3, 22),
V1_20_R4(20,4, 32)
V1_20_R4(20,4, 32),
V1_21_R1(21,1, 34)
;
/**
* Main version.
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ val legacyNmsVersion = listOf(
"v1_20_R3",
)
val currentNmsVersion = listOf(
"v1_20_R4"
"v1_20_R4",
"v1_21_R1"
)

val allNmsVersion = ArrayList<String>().apply {
Expand Down
1 change: 1 addition & 0 deletions dist/src/main/kotlin/kr/toxicity/hud/BetterHudImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class BetterHudImpl: BetterHud() {
val pluginManager = Bukkit.getPluginManager()

nms = when (MinecraftVersion.current) {
MinecraftVersion.version1_21 -> kr.toxicity.hud.nms.v1_21_R1.NMSImpl()
MinecraftVersion.version1_20_5, MinecraftVersion.version1_20_6 -> kr.toxicity.hud.nms.v1_20_R4.NMSImpl()
MinecraftVersion.version1_20_3, MinecraftVersion.version1_20_4 -> kr.toxicity.hud.nms.v1_20_R3.NMSImpl()
MinecraftVersion.version1_20_2 -> kr.toxicity.hud.nms.v1_20_R2.NMSImpl()
Expand Down
2 changes: 1 addition & 1 deletion dist/src/main/kotlin/kr/toxicity/hud/hud/HudHeadElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class HudHeadElement(parent: HudImpl, private val head: HeadLayout, gui: GuiLoca
})
}
}
val comp = Component.text().content(char).font(parent.imageKey)
val comp = Component.text(char).font(parent.imageKey)
PlayerHeadManager.setHead(shaderGroup, comp)
comp
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kr.toxicity.hud.resource.GlobalResource
import kr.toxicity.hud.shader.ShaderGroup
import kr.toxicity.hud.util.*
import net.kyori.adventure.audience.Audience
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import net.kyori.adventure.text.format.TextColor
import org.bukkit.Bukkit
Expand All @@ -24,13 +25,13 @@ object PlayerHeadManager : BetterHudManager {
private val headCache = ConcurrentHashMap<String, CachedHead>()
private val headMap = HashMap<String, HudHead>()

private val headNameComponent = ConcurrentHashMap<ShaderGroup, TextComponent.Builder>()
private val headNameComponent = ConcurrentHashMap<ShaderGroup, Component>()


@Synchronized
fun getHead(group: ShaderGroup) = headNameComponent[group]
@Synchronized
fun setHead(group: ShaderGroup, component: TextComponent.Builder) {
fun setHead(group: ShaderGroup, component: Component) {
headNameComponent[group] = component
}

Expand Down
2 changes: 1 addition & 1 deletion dist/src/main/kotlin/kr/toxicity/hud/popup/PopupLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class PopupLayout(
})
})
}
val comp = Component.text().content(char).font(parent.imageKey)
val comp = Component.text(char).font(parent.imageKey)
PlayerHeadManager.setHead(shaderGroup, comp)
comp
}
Expand Down
5 changes: 3 additions & 2 deletions dist/src/main/kotlin/kr/toxicity/hud/renderer/HeadRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import kr.toxicity.hud.manager.PlayerHeadManager
import kr.toxicity.hud.manager.PlayerManager
import kr.toxicity.hud.placeholder.ConditionBuilder
import kr.toxicity.hud.util.*
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import org.bukkit.Bukkit
import java.util.UUID

class HeadRenderer(
private val components: List<TextComponent.Builder>,
private val components: List<Component>,
private val pixel: Int,
private val x: Int,
private val align: LayoutAlign,
Expand Down Expand Up @@ -49,7 +50,7 @@ class HeadRenderer(
var i = 0
targetPlayerHead.colors.forEachSync { next ->
val index = i++
comp += WidthComponent(components[index / 8].color(next), pixel)
comp += WidthComponent(Component.text().append(components[index / 8]).color(next), pixel)
comp += if (index < 63 && index % 8 == 7) nextPixel else NEGATIVE_ONE_SPACE_COMPONENT
}
comp.toPixelComponent(
Expand Down
3 changes: 3 additions & 0 deletions nms/v1_21_R1/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT")
}
Loading

0 comments on commit 8210e7e

Please sign in to comment.