Skip to content

Commit 6abf656

Browse files
committed
Add 'color-overrides' in image, text, head, layout
1 parent 5134215 commit 6abf656

File tree

56 files changed

+759
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+759
-560
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Welcome to BetterHud!
1515

1616
</div>
1717

18-
### Multi-platform server-side HUD implementation of Minecraft.
18+
### Multiplatform server-side HUD implementation of Minecraft
1919
This project implements a server-side HUD.
2020

2121
- Supports auto-generating resource pack.
22-
- Supports display image(include png sequence), display, head.
22+
- Supports display image(include png sequence), text, head.
2323
- Supports animation.
2424

2525
### Platform

api/build.gradle.kts

+46-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
import com.vanniktech.maven.publish.JavaLibrary
2+
import com.vanniktech.maven.publish.JavadocJar
3+
import com.vanniktech.maven.publish.SonatypeHost
4+
15
plugins {
2-
`maven-publish`
6+
id("com.vanniktech.maven.publish") version "0.30.0"
7+
signing
38
}
49

510
subprojects {
6-
apply(plugin = "maven-publish")
11+
12+
val publishName = "${rootProject.name}-${project.name}"
13+
14+
apply(plugin = "com.vanniktech.maven.publish")
15+
apply(plugin = "signing")
716

817
dependencies {
918
compileOnly("org.projectlombok:lombok:1.18.34")
@@ -13,25 +22,46 @@ subprojects {
1322
testAnnotationProcessor("org.projectlombok:lombok:1.18.34")
1423
}
1524

16-
val sourcesJar by tasks.creating(Jar::class.java) {
17-
from(sourceSets.main.get().allJava)
18-
archiveClassifier = "sources"
25+
java {
26+
withSourcesJar()
27+
withJavadocJar()
1928
}
20-
val javadocJar by tasks.creating(Jar::class.java) {
21-
dependsOn(tasks.javadoc)
22-
archiveClassifier = "javadoc"
23-
from(tasks.javadoc.get().destinationDir)
29+
30+
signing {
31+
useGpgCmd()
2432
}
2533

26-
publishing {
27-
publications {
28-
create<MavenPublication>("maven") {
29-
from(components["java"])
30-
afterEvaluate {
31-
artifact(javadocJar)
32-
artifact(sourcesJar)
34+
mavenPublishing {
35+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
36+
signAllPublications()
37+
coordinates("io.github.toxicity188", publishName, project.version as String)
38+
configure(JavaLibrary(
39+
javadocJar = JavadocJar.None(),
40+
sourcesJar = true,
41+
))
42+
pom {
43+
name = publishName
44+
description = "A multi-platform server-side implementation of HUD in Minecraft, supporting Bukkit(with Folia), Velocity, and Fabric."
45+
inceptionYear = "2024"
46+
url = "https://github.com/toxicity188/BetterHud/"
47+
licenses {
48+
license {
49+
name = "MIT License"
50+
url = "https://mit-license.org/"
3351
}
3452
}
53+
developers {
54+
developer {
55+
id = "toxicity188"
56+
name = "toxicity188"
57+
url = "https://github.com/toxicity188/"
58+
}
59+
}
60+
scm {
61+
url = "https://github.com/toxicity188/BetterHud/"
62+
connection = "scm:git:git://github.com/toxicity188/BetterHud.git"
63+
developerConnection = "scm:git:ssh://[email protected]/toxicity188/BetterHud.git"
64+
}
3565
}
3666
}
3767
}

api/bukkit-api/src/main/java/kr/toxicity/hud/api/bukkit/nms/NMS.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kr.toxicity.hud.api.bukkit.nms;
22

33
import kr.toxicity.command.BetterCommandSource;
4-
import kr.toxicity.command.CommandModule;
4+
import kr.toxicity.command.impl.CommandModule;
55
import kr.toxicity.hud.api.volatilecode.VolatileCodeHandler;
66
import org.bukkit.entity.Player;
77
import org.jetbrains.annotations.NotNull;

build.gradle.kts

+12-17
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val platform = "4.3.4"
3131
val targetJavaVersion = 21
3232
val velocity = "3.4.0"
3333
val bStats = "3.1.0"
34-
val betterCommand = "1.3"
34+
val betterCommand = "1.4"
3535

3636
val supportedMinecraftVersions = listOf(
3737
//1.17
@@ -86,6 +86,7 @@ allprojects {
8686

8787
dependencies {
8888
testImplementation("org.jetbrains.kotlin:kotlin-test")
89+
implementation("io.github.toxicity188:BetterCommand:$betterCommand")
8990
}
9091

9192
tasks {
@@ -130,9 +131,6 @@ subprojects {
130131
displayName = project.name
131132
}
132133
}
133-
dependencies {
134-
compileOnly("com.github.toxicity188:BetterCommand:$betterCommand")
135-
}
136134
}
137135

138136
val legacyNmsVersion = listOf(
@@ -300,12 +298,11 @@ dependencies {
300298
implementation(it)
301299
}
302300
implementation(dist)
303-
implementation("com.github.toxicity188:BetterCommand:$betterCommand")
304301
implementation("org.bstats:bstats-bukkit:$bStats")
305302
implementation("org.bstats:bstats-velocity:$bStats")
306303
}
307304

308-
val sourceJar by tasks.creating(Jar::class.java) {
305+
val sourcesJar by tasks.creating(Jar::class.java) {
309306
dependsOn(tasks.classes)
310307
fun getProjectSource(project: Project): Array<File> {
311308
return if (project.subprojects.isEmpty()) project.sourceSets.main.get().allSource.srcDirs.toTypedArray() else ArrayList<File>().apply {
@@ -314,13 +311,13 @@ val sourceJar by tasks.creating(Jar::class.java) {
314311
}
315312
}.toTypedArray()
316313
}
317-
archiveClassifier = "source"
314+
archiveClassifier = "sources"
318315
from(*getProjectSource(project))
319316
duplicatesStrategy = DuplicatesStrategy.INCLUDE
320317
}
321-
val dokkaJar by tasks.creating(Jar::class.java) {
318+
val javadocJar by tasks.creating(Jar::class.java) {
322319
dependsOn(tasks.dokkaGenerate)
323-
archiveClassifier = "dokka"
320+
archiveClassifier = "javadoc"
324321
from(layout.buildDirectory.dir("dokka/html").orNull?.asFile)
325322
}
326323
val fabricJar by tasks.creating(Jar::class.java) {
@@ -391,7 +388,8 @@ fun Jar.relocateAll() {
391388
"kotlin",
392389
"net.objecthunter.exp4j",
393390
"org.bstats",
394-
"me.lucko.jarrelocator"
391+
"me.lucko.jarrelocator",
392+
"kr.toxicity.command.impl"
395393
).map {
396394
Relocation(it, "${project.group}.shaded.$it")
397395
}
@@ -420,10 +418,7 @@ tasks {
420418
pluginJars(fileTree("plugins"))
421419
}
422420
build {
423-
finalizedBy(sourceJar, dokkaJar, pluginJar, velocityJar, fabricJar)
424-
}
425-
logLinkDokkaGeneratePublicationHtml {
426-
enabled = false
421+
finalizedBy(sourcesJar, javadocJar, pluginJar, velocityJar, fabricJar)
427422
}
428423
shadowJar {
429424
archiveClassifier = ""
@@ -435,7 +430,7 @@ tasks {
435430

436431
bukkitBootstrap.modrinthPublish(
437432
pluginJar,
438-
listOf(sourceJar, dokkaJar),
433+
listOf(sourcesJar, javadocJar),
439434
listOf("bukkit", "spigot", "paper", "purpur", "folia"),
440435
supportedMinecraftVersions,
441436
listOf(),
@@ -444,15 +439,15 @@ bukkitBootstrap.modrinthPublish(
444439

445440
velocityBootstrap.modrinthPublish(
446441
velocityJar,
447-
listOf(sourceJar, dokkaJar),
442+
listOf(sourcesJar, javadocJar),
448443
listOf("velocity"),
449444
supportedMinecraftVersions,
450445
listOf(),
451446
listOf()
452447
)
453448
fabricBootstrap.modrinthPublish(
454449
fabricJar,
455-
listOf(sourceJar, dokkaJar),
450+
listOf(sourcesJar, javadocJar),
456451
listOf("fabric", "quilt"),
457452
listOf(minecraft),
458453
listOf("fabric-api"),

changelog/1.10.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,43 @@ children_full:
3939
setting:
4040
children: * #wild card(*) defines all available image.
4141
follow: "skript_variable:your_value" #If you want to show image depend on some placeholder, set 'follow' section.
42-
```
42+
```
43+
- Now we're using maven central to publish API
44+
```kotlin
45+
dependencies {
46+
compileOnly("io.github.toxicity188:BetterHud-standard-api:VERSION") //Standard API
47+
compileOnly("io.github.toxicity188:BetterHud-bukkit-api:VERSION") //Platform API
48+
}
49+
```
50+
- Add 'color-overrides' in image, text, head, layout
51+
```yaml
52+
test_layout:
53+
heads:
54+
1:
55+
name: test_head
56+
align: center
57+
texts:
58+
1:
59+
name: test_text
60+
pattern: |
61+
Text1
62+
Text2
63+
line: 3
64+
align: center
65+
line-align: center
66+
scale: 0.5
67+
y: 48
68+
properties:
69+
- wave
70+
color-overrides:
71+
1:
72+
color: "#FF8080"
73+
conditions:
74+
1:
75+
first: health_percentage
76+
second: 0.33
77+
operation: "<"
78+
```
79+
## Fix
80+
- Fix placeholder comma.
81+
- Fix Folia adaption

dist/src/main/kotlin/kr/toxicity/hud/BetterHudImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ class BetterHudImpl(val bootstrap: BetterHudBootstrap) : BetterHud {
7171
private val reloadEndTask = ArrayList<(ReloadState) -> Unit>()
7272

7373
override fun addReloadStartTask(runnable: Runnable) {
74-
reloadStartTask.add {
74+
reloadStartTask += {
7575
runnable.run()
7676
}
7777
}
7878

7979
override fun addReloadEndTask(runnable: Consumer<ReloadState>) {
80-
reloadEndTask.add {
80+
reloadEndTask += {
8181
runnable.accept(it)
8282
}
8383
}

dist/src/main/kotlin/kr/toxicity/hud/compass/type/CircleCompass.kt

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import kr.toxicity.hud.api.update.UpdateEvent
88
import kr.toxicity.hud.api.yaml.YamlObject
99
import kr.toxicity.hud.compass.CompassImpl
1010
import kr.toxicity.hud.equation.TEquation
11-
import kr.toxicity.hud.hud.HudImpl
1211
import kr.toxicity.hud.location.PixelLocation
1312
import kr.toxicity.hud.manager.ConfigManagerImpl
1413
import kr.toxicity.hud.pack.PackGenerator
@@ -96,14 +95,14 @@ class CircleCompass(
9695
val newHeight = (image.height.toDouble() * scale * scaleMultiplier).roundToInt()
9796
val div = newHeight.toDouble() / image.height.toDouble()
9897
array?.let { array ->
99-
HudImpl.createBit(shader, pixel.y + y + (maxHeight - newHeight) / 2) { bit ->
100-
array.add(jsonObjectOf(
98+
createAscent(shader, pixel.y + y + (maxHeight - newHeight) / 2) { bit ->
99+
array += jsonObjectOf(
101100
"type" to "bitmap",
102101
"file" to "$NAME_SPACE_ENCODED:$nameEncoded.png",
103102
"ascent" to bit,
104103
"height" to newHeight,
105104
"chars" to jsonArrayOf(char)
106-
))
105+
)
107106
}
108107
}
109108
resourceRef?.let {
@@ -254,14 +253,14 @@ class CircleCompass(
254253
if (!BOOTSTRAP.useLegacyFont()) {
255254
val max = images.max + 2 * space + length
256255
val center = CURRENT_CENTER_SPACE_CODEPOINT
257-
it.add(buildJsonObject {
256+
it += buildJsonObject {
258257
addProperty("type", "space")
259258
add("advances", buildJsonObject {
260259
for (i in -max..max) {
261260
addProperty((center + i).parseChar(), i)
262261
}
263262
})
264-
})
263+
}
265264
}
266265
PackGenerator.addTask(resource.font + "$encode.json") {
267266
jsonObjectOf("providers" to it).toByteArray()

dist/src/main/kotlin/kr/toxicity/hud/dependency/DependencyInjector.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import kr.toxicity.hud.api.BetterHudDependency
44
import kr.toxicity.hud.api.BetterHudLogger
55
import kr.toxicity.hud.util.subFile
66
import kr.toxicity.hud.util.subFolder
7-
import kr.toxicity.hud.util.toYaml
87
import me.lucko.jarrelocator.JarRelocator
98
import me.lucko.jarrelocator.Relocation
109
import java.io.File
@@ -95,8 +94,8 @@ class DependencyInjector(version: String, dataFolder: File, private val logger:
9594
}
9695

9796
fun addURL(url: URL) {
98-
unopenedURLs.add(url)
99-
pathURLs.add(url)
97+
unopenedURLs += url
98+
pathURLs += url
10099
}
101100
}
102101

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package kr.toxicity.hud.element
2+
3+
import kr.toxicity.hud.api.yaml.YamlObject
4+
import kr.toxicity.hud.configuration.HudConfiguration
5+
import kr.toxicity.hud.placeholder.ConditionSource
6+
7+
class HeadElement(
8+
override val path: String,
9+
val name: String,
10+
yaml: YamlObject
11+
) : HudConfiguration, HudElement, ConditionSource by ConditionSource.Impl(yaml) {
12+
val pixel = yaml.getAsInt("pixel", 1).coerceAtLeast(1)
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package kr.toxicity.hud.element
2+
3+
import kr.toxicity.hud.placeholder.ConditionSource
4+
5+
interface HudElement : ConditionSource

dist/src/main/kotlin/kr/toxicity/hud/image/HudImage.kt dist/src/main/kotlin/kr/toxicity/hud/element/ImageElement.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
package kr.toxicity.hud.image
1+
package kr.toxicity.hud.element
22

33
import kr.toxicity.hud.api.yaml.YamlArray
44
import kr.toxicity.hud.api.yaml.YamlElement
55
import kr.toxicity.hud.api.yaml.YamlObject
66
import kr.toxicity.hud.configuration.HudConfiguration
7+
import kr.toxicity.hud.image.NamedLoadedImage
78
import kr.toxicity.hud.image.enums.ImageType
89
import kr.toxicity.hud.manager.ImageManager
910
import kr.toxicity.hud.manager.ListenerManagerImpl
1011
import kr.toxicity.hud.manager.PlaceholderManagerImpl
1112
import kr.toxicity.hud.placeholder.Conditions
13+
import kr.toxicity.hud.placeholder.ConditionSource
1214
import kr.toxicity.hud.util.ifNull
13-
import kr.toxicity.hud.util.toConditions
1415

15-
class HudImage(
16+
class ImageElement(
1617
override val path: String,
1718
val name: String,
1819
val image: List<NamedLoadedImage>,
1920
val type: ImageType,
2021
setting: YamlObject
21-
) : HudConfiguration {
22-
val conditions = setting.toConditions()
22+
) : HudConfiguration, HudElement, ConditionSource by ConditionSource.Impl(setting) {
2323
val listener = setting["listener"]?.asObject()?.let {
2424
ListenerManagerImpl.getListener(it)
2525
}

0 commit comments

Comments
 (0)