Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .profileconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"jfrConfig": {
"settings": "profile"
},
"asyncProfilerConfig": {
"jfrsync": true,
"alloc": true,
"event": "wall",
"misc": ""
},
"file": "$PROJECT_DIR/profile.jfr",
"conversionConfig": {
"nonProjectPackagePrefixes": [
"java.",
"javax.",
"kotlin.",
"jdk.",
"com.google.",
"org.apache.",
"org.spring.",
"sun.",
"scala."
],
"enableMarkers": true,
"initialVisibleThreads": 10,
"initialSelectedThreads": 10,
"includeGCThreads": false,
"includeInitialSystemProperty": false,
"includeInitialEnvironmentVariables": false,
"includeSystemProcesses": false,
"ignoredEvents": [
"jdk.ActiveSetting",
"jdk.ActiveRecording",
"jdk.BooleanFlag",
"jdk.IntFlag",
"jdk.DoubleFlag",
"jdk.LongFlag",
"jdk.NativeLibrary",
"jdk.StringFlag",
"jdk.UnsignedIntFlag",
"jdk.UnsignedLongFlag",
"jdk.InitialSystemProperty",
"jdk.InitialEnvironmentVariable",
"jdk.SystemProcess",
"jdk.ModuleExport",
"jdk.ModuleRequire"
],
"minRequiredItemsPerThread": 3
},
"additionalGradleTargets": [
{
"targetPrefix": "quarkus",
"optionForVmArgs": "-Djvm.args",
"description": "Example quarkus config, adding profiling arguments via -Djvm.args option to the Gradle task run"
}
],
"additionalMavenTargets": [
{
"targetPrefix": "quarkus:",
"optionForVmArgs": "-Djvm.args",
"description": "Example quarkus config, adding profiling arguments via -Djvm.args option to the Maven goal run"
}
]
}
2 changes: 2 additions & 0 deletions .run/Run Tests.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="JUnit" factoryName="JUnit">
<module name="Scroll.test" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="corretto-21" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
Expand Down
81 changes: 75 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse

plugins {
`maven-publish`
kotlin("jvm") version "1.9.22"
Expand All @@ -6,7 +11,7 @@ plugins {
}

group = "io.github.dockyardmc"
version = "1.9"
version = "2.1"

repositories {
mavenCentral()
Expand All @@ -25,29 +30,38 @@ tasks.withType<Test> {
useJUnitPlatform()
val javaToolchains = project.extensions.getByType<JavaToolchainService>()
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
})
}

tasks {
compileKotlin {
kotlinOptions.jvmTarget = "17"
kotlinOptions.jvmTarget = "21"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "17"
kotlinOptions.jvmTarget = "21"
}
compileJava {
targetCompatibility = "17"
targetCompatibility = "21"
}
compileTestJava {
targetCompatibility = "17"
targetCompatibility = "21"
}
}

application {
mainClass.set("MainKt")
}

sourceSets["main"].resources.srcDir("${buildDir}/generated/resources/")

sourceSets["main"].java.srcDir("src/main/kotlin")

java {
withSourcesJar()
withJavadocJar()
}

publishing {
repositories {
maven {
Expand All @@ -58,6 +72,7 @@ publishing {
}
}
}

publications {
register<MavenPublication>("maven") {
groupId = "io.github.dockyardmc"
Expand All @@ -66,4 +81,58 @@ publishing {
from(components["java"])
}
}
}

tasks.publish {
finalizedBy("sendPublishWebhook")
}

task("sendPublishWebhook") {
group = "publishing"
description = "Sends a webhook message after publishing to Maven."

doLast {
sendWebhookToDiscord(System.getenv("DISCORD_DOCKYARD_WEBHOOK"))
}
}

fun sendWebhookToDiscord(webhookUrl: String) {
val httpClient = HttpClient.newHttpClient()

val requestBody = embed()
val request = HttpRequest.newBuilder()
.uri(URI(webhookUrl))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build()

httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())

.thenRun { println("Webhook sent successfully!") }
.exceptionally { throwable ->
throwable.printStackTrace()
null
}
}


fun embed(): String {
val target = if(version.toString().endsWith("-SNAPSHOT")) "https://mvn.devos.one/snapshots" else "https://mvn.devos.one/releases"
val color = if(version.toString().endsWith("-SNAPSHOT")) 16742912 else 65290
val title = if(version.toString().endsWith("-SNAPSHOT")) "Snapshot Published to Maven" else "Published to Maven"
return """
{
"content": null,
"embeds": [
{
"title": "$title",
"description": "`io.github.dockyardmc:scroll:$version` was successfully published to maven **$target**!",
"color": $color
}
],
"username": "Mavenboo",
"avatar_url": "https://ae01.alicdn.com/kf/Sa4eadafccb024c72a386eff7dfac2c61n.jpg",
"attachments": []
}
""".trimIndent()
}
16 changes: 16 additions & 0 deletions src/main/kotlin/io/github/dockyardmc/scroll/ClickAction.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.dockyardmc.scroll

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
enum class ClickAction {
@SerialName("open_url")
OPEN_URL,
@SerialName("run_command")
RUN_COMMAND,
@SerialName("suggest_command")
SUGGEST_COMMAND,
@SerialName("copy_to_clipboard")
COPY_TO_CLIPBOARD
}
9 changes: 9 additions & 0 deletions src/main/kotlin/io/github/dockyardmc/scroll/ClickEvent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.dockyardmc.scroll

import kotlinx.serialization.Serializable

@Serializable
class ClickEvent(
val action: ClickAction,
val value: String? = null
)
84 changes: 84 additions & 0 deletions src/main/kotlin/io/github/dockyardmc/scroll/Component.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package io.github.dockyardmc.scroll

import io.github.dockyardmc.scroll.serializers.ComponentToJsonSerializer
import io.github.dockyardmc.scroll.serializers.ComponentToNbtSerializer
import kotlinx.serialization.Serializable
import org.jglrxavpok.hephaistos.nbt.NBTCompound

@Serializable
open class Component(
open var extra: MutableList<Component>? = null,
open var keybind: String? = null,
open var text: String? = null,
open var translate: String? = null,
open var color: String? = null,
open var bold: Boolean? = null,
open var italic: Boolean? = null,
open var underlined: Boolean? = null,
open var strikethrough: Boolean? = null,
open var obfuscated: Boolean? = null,
open var font: String? = null,
open var insertion: String? = null,
open var hoverEvent: HoverEvent? = null,
open var clickEvent: ClickEvent? = null
) {
companion object {
fun compound(components: MutableList<Component>): Component {
return Component(
text = "",
extra = components
)
}
}

override fun toString(): String {
return this.stripStyling()
}

fun toNBT(): NBTCompound {
return ComponentToNbtSerializer.serializeComponent(this)
}

fun toJson(): String {
return ComponentToJsonSerializer.serialize(this)
}

fun stripStyling(): String {
return buildString {
getAllComponents().forEach {
append(it.text)
}
}
}

fun getAllComponents(): MutableList<Component> {
val recursiveComponentList = mutableListOf<Component>()
getComponentRecursive(this, recursiveComponentList)
return recursiveComponentList
}

private fun getComponentRecursive(component: Component, componentList: MutableList<Component>) {
component.extra?.forEach {
componentList.add(it)
getComponentRecursive(it, componentList)
}
}

fun resetFormatting(includingFont: Boolean = true) {
this.color = null
this.strikethrough = null
this.underlined = null
this.font = null
this.italic = null
this.bold = null
if(includingFont) {
this.font = null
this.hoverEvent = null
this.obfuscated = null
this.insertion = null
this.keybind = null
this.translate = null
this.clickEvent = null
}
}
}
50 changes: 0 additions & 50 deletions src/main/kotlin/io/github/dockyardmc/scroll/ComponentColorTags.kt

This file was deleted.

Loading
Loading