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

Commit 81426f9

Browse files
authored
Merge pull request #2 from DockyardMC/rewrite/2.0
Fix color resetting font
2 parents 07fe317 + 39cbe02 commit 81426f9

39 files changed

+911
-648
lines changed

.profileconfig.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"jfrConfig": {
3+
"settings": "profile"
4+
},
5+
"asyncProfilerConfig": {
6+
"jfrsync": true,
7+
"alloc": true,
8+
"event": "wall",
9+
"misc": ""
10+
},
11+
"file": "$PROJECT_DIR/profile.jfr",
12+
"conversionConfig": {
13+
"nonProjectPackagePrefixes": [
14+
"java.",
15+
"javax.",
16+
"kotlin.",
17+
"jdk.",
18+
"com.google.",
19+
"org.apache.",
20+
"org.spring.",
21+
"sun.",
22+
"scala."
23+
],
24+
"enableMarkers": true,
25+
"initialVisibleThreads": 10,
26+
"initialSelectedThreads": 10,
27+
"includeGCThreads": false,
28+
"includeInitialSystemProperty": false,
29+
"includeInitialEnvironmentVariables": false,
30+
"includeSystemProcesses": false,
31+
"ignoredEvents": [
32+
"jdk.ActiveSetting",
33+
"jdk.ActiveRecording",
34+
"jdk.BooleanFlag",
35+
"jdk.IntFlag",
36+
"jdk.DoubleFlag",
37+
"jdk.LongFlag",
38+
"jdk.NativeLibrary",
39+
"jdk.StringFlag",
40+
"jdk.UnsignedIntFlag",
41+
"jdk.UnsignedLongFlag",
42+
"jdk.InitialSystemProperty",
43+
"jdk.InitialEnvironmentVariable",
44+
"jdk.SystemProcess",
45+
"jdk.ModuleExport",
46+
"jdk.ModuleRequire"
47+
],
48+
"minRequiredItemsPerThread": 3
49+
},
50+
"additionalGradleTargets": [
51+
{
52+
"targetPrefix": "quarkus",
53+
"optionForVmArgs": "-Djvm.args",
54+
"description": "Example quarkus config, adding profiling arguments via -Djvm.args option to the Gradle task run"
55+
}
56+
],
57+
"additionalMavenTargets": [
58+
{
59+
"targetPrefix": "quarkus:",
60+
"optionForVmArgs": "-Djvm.args",
61+
"description": "Example quarkus config, adding profiling arguments via -Djvm.args option to the Maven goal run"
62+
}
63+
]
64+
}

.run/Run Tests.run.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Run Tests" type="JUnit" factoryName="JUnit">
33
<module name="Scroll.test" />
4+
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
5+
<option name="ALTERNATIVE_JRE_PATH" value="corretto-21" />
46
<option name="PACKAGE_NAME" value="" />
57
<option name="MAIN_CLASS_NAME" value="" />
68
<option name="METHOD_NAME" value="" />

build.gradle.kts

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import java.net.URI
2+
import java.net.http.HttpClient
3+
import java.net.http.HttpRequest
4+
import java.net.http.HttpResponse
5+
16
plugins {
27
`maven-publish`
38
kotlin("jvm") version "1.9.22"
@@ -6,7 +11,7 @@ plugins {
611
}
712

813
group = "io.github.dockyardmc"
9-
version = "1.9"
14+
version = "2.1"
1015

1116
repositories {
1217
mavenCentral()
@@ -25,29 +30,38 @@ tasks.withType<Test> {
2530
useJUnitPlatform()
2631
val javaToolchains = project.extensions.getByType<JavaToolchainService>()
2732
javaLauncher.set(javaToolchains.launcherFor {
28-
languageVersion.set(JavaLanguageVersion.of(17))
33+
languageVersion.set(JavaLanguageVersion.of(21))
2934
})
3035
}
3136

3237
tasks {
3338
compileKotlin {
34-
kotlinOptions.jvmTarget = "17"
39+
kotlinOptions.jvmTarget = "21"
3540
}
3641
compileTestKotlin {
37-
kotlinOptions.jvmTarget = "17"
42+
kotlinOptions.jvmTarget = "21"
3843
}
3944
compileJava {
40-
targetCompatibility = "17"
45+
targetCompatibility = "21"
4146
}
4247
compileTestJava {
43-
targetCompatibility = "17"
48+
targetCompatibility = "21"
4449
}
4550
}
4651

4752
application {
4853
mainClass.set("MainKt")
4954
}
5055

56+
sourceSets["main"].resources.srcDir("${buildDir}/generated/resources/")
57+
58+
sourceSets["main"].java.srcDir("src/main/kotlin")
59+
60+
java {
61+
withSourcesJar()
62+
withJavadocJar()
63+
}
64+
5165
publishing {
5266
repositories {
5367
maven {
@@ -58,6 +72,7 @@ publishing {
5872
}
5973
}
6074
}
75+
6176
publications {
6277
register<MavenPublication>("maven") {
6378
groupId = "io.github.dockyardmc"
@@ -66,4 +81,58 @@ publishing {
6681
from(components["java"])
6782
}
6883
}
84+
}
85+
86+
tasks.publish {
87+
finalizedBy("sendPublishWebhook")
88+
}
89+
90+
task("sendPublishWebhook") {
91+
group = "publishing"
92+
description = "Sends a webhook message after publishing to Maven."
93+
94+
doLast {
95+
sendWebhookToDiscord(System.getenv("DISCORD_DOCKYARD_WEBHOOK"))
96+
}
97+
}
98+
99+
fun sendWebhookToDiscord(webhookUrl: String) {
100+
val httpClient = HttpClient.newHttpClient()
101+
102+
val requestBody = embed()
103+
val request = HttpRequest.newBuilder()
104+
.uri(URI(webhookUrl))
105+
.header("Content-Type", "application/json")
106+
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
107+
.build()
108+
109+
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())
110+
111+
.thenRun { println("Webhook sent successfully!") }
112+
.exceptionally { throwable ->
113+
throwable.printStackTrace()
114+
null
115+
}
116+
}
117+
118+
119+
fun embed(): String {
120+
val target = if(version.toString().endsWith("-SNAPSHOT")) "https://mvn.devos.one/snapshots" else "https://mvn.devos.one/releases"
121+
val color = if(version.toString().endsWith("-SNAPSHOT")) 16742912 else 65290
122+
val title = if(version.toString().endsWith("-SNAPSHOT")) "Snapshot Published to Maven" else "Published to Maven"
123+
return """
124+
{
125+
"content": null,
126+
"embeds": [
127+
{
128+
"title": "$title",
129+
"description": "`io.github.dockyardmc:scroll:$version` was successfully published to maven **$target**!",
130+
"color": $color
131+
}
132+
],
133+
"username": "Mavenboo",
134+
"avatar_url": "https://ae01.alicdn.com/kf/Sa4eadafccb024c72a386eff7dfac2c61n.jpg",
135+
"attachments": []
136+
}
137+
""".trimIndent()
69138
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.github.dockyardmc.scroll
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
enum class ClickAction {
8+
@SerialName("open_url")
9+
OPEN_URL,
10+
@SerialName("run_command")
11+
RUN_COMMAND,
12+
@SerialName("suggest_command")
13+
SUGGEST_COMMAND,
14+
@SerialName("copy_to_clipboard")
15+
COPY_TO_CLIPBOARD
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.dockyardmc.scroll
2+
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
class ClickEvent(
7+
val action: ClickAction,
8+
val value: String? = null
9+
)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package io.github.dockyardmc.scroll
2+
3+
import io.github.dockyardmc.scroll.serializers.ComponentToJsonSerializer
4+
import io.github.dockyardmc.scroll.serializers.ComponentToNbtSerializer
5+
import kotlinx.serialization.Serializable
6+
import org.jglrxavpok.hephaistos.nbt.NBTCompound
7+
8+
@Serializable
9+
open class Component(
10+
open var extra: MutableList<Component>? = null,
11+
open var keybind: String? = null,
12+
open var text: String? = null,
13+
open var translate: String? = null,
14+
open var color: String? = null,
15+
open var bold: Boolean? = null,
16+
open var italic: Boolean? = null,
17+
open var underlined: Boolean? = null,
18+
open var strikethrough: Boolean? = null,
19+
open var obfuscated: Boolean? = null,
20+
open var font: String? = null,
21+
open var insertion: String? = null,
22+
open var hoverEvent: HoverEvent? = null,
23+
open var clickEvent: ClickEvent? = null
24+
) {
25+
companion object {
26+
fun compound(components: MutableList<Component>): Component {
27+
return Component(
28+
text = "",
29+
extra = components
30+
)
31+
}
32+
}
33+
34+
override fun toString(): String {
35+
return this.stripStyling()
36+
}
37+
38+
fun toNBT(): NBTCompound {
39+
return ComponentToNbtSerializer.serializeComponent(this)
40+
}
41+
42+
fun toJson(): String {
43+
return ComponentToJsonSerializer.serialize(this)
44+
}
45+
46+
fun stripStyling(): String {
47+
return buildString {
48+
getAllComponents().forEach {
49+
append(it.text)
50+
}
51+
}
52+
}
53+
54+
fun getAllComponents(): MutableList<Component> {
55+
val recursiveComponentList = mutableListOf<Component>()
56+
getComponentRecursive(this, recursiveComponentList)
57+
return recursiveComponentList
58+
}
59+
60+
private fun getComponentRecursive(component: Component, componentList: MutableList<Component>) {
61+
component.extra?.forEach {
62+
componentList.add(it)
63+
getComponentRecursive(it, componentList)
64+
}
65+
}
66+
67+
fun resetFormatting(includingFont: Boolean = true) {
68+
this.color = null
69+
this.strikethrough = null
70+
this.underlined = null
71+
this.font = null
72+
this.italic = null
73+
this.bold = null
74+
if(includingFont) {
75+
this.font = null
76+
this.hoverEvent = null
77+
this.obfuscated = null
78+
this.insertion = null
79+
this.keybind = null
80+
this.translate = null
81+
this.clickEvent = null
82+
}
83+
}
84+
}

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

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

0 commit comments

Comments
 (0)