Skip to content

Commit 94e8284

Browse files
authored
Merge branch 'master' into feature/optional-papi
2 parents a189aa8 + 961d861 commit 94e8284

Some content is hidden

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

41 files changed

+680
-566
lines changed

.github/renovate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"local>EternalCodeTeam/.github:renovate-config"
4+
]
5+
}

.github/workflows/gradle.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v6
1919
- name: Set up JDK 17
20-
uses: actions/setup-java@v4
20+
uses: actions/setup-java@v5
2121
with:
2222
java-version: '17'
2323
distribution: 'temurin'
2424
- name: Cache Gradle
25-
uses: actions/cache@v4.0.2
25+
uses: actions/cache@v5.0.3
2626
with:
2727
path: ~/.gradle/caches
2828
key: >-
@@ -32,11 +32,11 @@ jobs:
3232
- name: Make gradlew executable
3333
run: chmod +x gradlew
3434
- name: Build with Gradle
35-
uses: gradle/gradle-build-action@fe59895742b4f984530980e4f693943577526b61
35+
uses: gradle/gradle-build-action@093dfe9d598ec5a42246855d09b49dc76803c005
3636
with:
37-
arguments: shadowAll
37+
arguments: shadowChatFormatter
3838
- name: Upload a ChatFormatter Artifact
39-
uses: actions/upload-artifact@v4.3.1
39+
uses: actions/upload-artifact@v6.0.0
4040
with:
4141
name: 'Successfully build ChatFormatter'
4242
path: build/libs/ChatFormatter v*.jar

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
*.iws
55
.idea/
66
.gradle/
7-
out/
87
build/
9-
node_modules/
108
dist/
119
run/
10+
.kotlin
1211

1312
.DS_Store
1413
[Dd]esktop.ini

.whitesource

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

README.md

Lines changed: 87 additions & 63 deletions
Large diffs are not rendered by default.

build.gradle.kts

Lines changed: 92 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,132 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
12
import java.io.FileOutputStream
23
import java.io.IOException
34
import java.util.jar.JarEntry
45
import java.util.jar.JarFile
56
import java.util.jar.JarOutputStream
67

7-
plugins{
8+
plugins {
89
id("eternalcode.java")
9-
id("com.github.johnrengelman.shadow")
10-
id("xyz.jpenilla.run-paper") version "2.2.3"
10+
id("com.gradleup.shadow")
11+
id("xyz.jpenilla.run-paper") version "3.0.2"
1112
}
1213

13-
tasks.create("shadowAll") {
14-
group = "shadow"
14+
tasks.register<ShadowJar>("shadowChatFormatter") {
15+
this.group = "build"
1516

16-
val projects = listOf(
17+
val targetProjects = listOf(
1718
project(":chatformatter-core"),
1819
project(":chatformatter-paper-plugin")
1920
)
2021

21-
for (project in projects) {
22-
dependsOn(project.name + ":shadowJar")
22+
for (targetProject in targetProjects) {
23+
this.dependsOn("${targetProject.name}:shadowJar")
2324
}
2425

25-
doLast {
26-
merge("ChatFormatter v${project.version}.jar", projects)
26+
this.doLast {
27+
this@register.mergeJars(
28+
"ChatFormatter v${project.version}.jar",
29+
targetProjects
30+
)
2731
}
2832
}
2933

30-
fun merge(archiveFileName: String, projects: List<Project>) {
31-
val outputFile = File(project.layout.buildDirectory.asFile.get(), "libs/${archiveFileName}")
32-
val outputDir = outputFile.parentFile ?: throw RuntimeException("Could not get output directory")
34+
fun ShadowJar.mergeJars(archiveFileName: String, projects: List<Project>) {
35+
val outputFile = File(
36+
this.project.layout.buildDirectory.asFile.get(),
37+
"libs/$archiveFileName"
38+
)
39+
val outputDir = outputFile.parentFile
40+
?: throw IllegalStateException("Cannot find output directory")
3341

3442
if (!outputDir.exists() && !outputDir.mkdirs()) {
35-
throw RuntimeException("Could not create output directory")
43+
throw IllegalStateException("Failed to create directory: ${outputDir.absolutePath}")
3644
}
3745

38-
if (outputFile.exists()) {
39-
outputFile.delete()
46+
if (outputFile.exists() && !outputFile.delete()) {
47+
throw IllegalStateException("Cannot delete existing file: ${outputFile.absolutePath}")
4048
}
4149

4250
if (!outputFile.createNewFile()) {
43-
throw RuntimeException("Could not find output file to merge")
51+
throw IllegalStateException("Cannot create output file: ${outputFile.absolutePath}")
4452
}
4553

54+
mergeShadowJarsIntoOutput(outputFile, projects)
55+
}
56+
57+
private fun mergeShadowJarsIntoOutput(
58+
outputFile: File,
59+
projects: List<Project>
60+
) {
4661
JarOutputStream(FileOutputStream(outputFile)).use { outputJar ->
47-
for (project in projects) {
48-
val shadowJar = project.tasks.shadowJar.get()
49-
50-
for (file in shadowJar.outputs.files.files) {
51-
JarFile(file).use { jarFile ->
52-
for (entry in jarFile.entries()) {
53-
if (entry.isDirectory) {
54-
continue
55-
}
56-
57-
val bytes = jarFile.getInputStream(entry).readBytes()
58-
val newEntry = JarEntry(entry.name)
59-
60-
newEntry.setTime(System.currentTimeMillis())
61-
newEntry.setSize(bytes.size.toLong())
62-
63-
try {
64-
outputJar.putNextEntry(newEntry)
65-
outputJar.write(bytes)
66-
outputJar.closeEntry()
67-
}
68-
catch (exception: IOException) {
69-
if (exception.message?.contains("duplicate entry: ") == true) {
70-
continue
71-
}
72-
73-
exception.printStackTrace()
74-
}
75-
}
62+
val processedEntries = mutableSetOf<String>()
63+
64+
for (targetProject in projects) {
65+
val shadowJarTask = targetProject.tasks.named("shadowJar", ShadowJar::class.java).get()
66+
67+
for (jarFile in shadowJarTask.outputs.files.files) {
68+
processJarFile(jarFile, outputJar, processedEntries)
69+
}
70+
}
71+
}
72+
}
73+
74+
private fun processJarFile(
75+
jarFile: File,
76+
outputJar: JarOutputStream,
77+
processedEntries: MutableSet<String>
78+
) {
79+
JarFile(jarFile).use { sourceJar ->
80+
for (entry in sourceJar.entries()) {
81+
if (entry.isDirectory || processedEntries.contains(entry.name)) {
82+
continue
83+
}
84+
85+
try {
86+
copyJarEntry(sourceJar, entry, outputJar)
87+
processedEntries.add(entry.name)
88+
} catch (exception: IOException) {
89+
if (exception.message?.contains("duplicate entry:") != true) {
90+
throw exception
7691
}
7792
}
7893
}
7994
}
95+
}
8096

97+
private fun copyJarEntry(
98+
sourceJar: JarFile,
99+
entry: JarEntry,
100+
outputJar: JarOutputStream
101+
) {
102+
val entryBytes = sourceJar.getInputStream(entry).use { it.readBytes() }
103+
val newEntry = JarEntry(entry.name).apply {
104+
this.time = System.currentTimeMillis()
105+
this.size = entryBytes.size.toLong()
106+
}
107+
108+
outputJar.putNextEntry(newEntry)
109+
outputJar.write(entryBytes)
110+
outputJar.closeEntry()
81111
}
82112

83113
runPaper {
84-
disablePluginJarDetection()
114+
this.disablePluginJarDetection()
85115
}
86116

87117
tasks.runServer {
88-
minecraftVersion("1.20.1")
89-
dependsOn("shadowAll")
90-
pluginJars = files("/build/libs/ChatFormatter v${project.version}.jar")
91-
}
118+
minecraftVersion("1.21.10")
119+
dependsOn("shadowChatFormatter")
120+
pluginJars.from(layout.buildDirectory.file("libs/ChatFormatter v${project.version}.jar"))
121+
122+
javaLauncher.set(
123+
javaToolchains.launcherFor {
124+
this.languageVersion.set(JavaLanguageVersion.of(21))
125+
}
126+
)
127+
128+
downloadPlugins {
129+
this.modrinth("luckperms", "v5.5.0-bukkit")
130+
this.modrinth("VaultUnlocked", "2.16.0")
131+
}
132+
}

buildSrc/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88
}
99

1010
dependencies {
11-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23")
12-
implementation("com.github.johnrengelman:shadow:8.1.1")
11+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.3.10")
12+
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.3.1")
1313
implementation("net.minecrell:plugin-yml:0.6.0")
1414
}

buildSrc/src/main/kotlin/eternalcode.java.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = "com.eternalcode"
6-
version = "1.1.3"
6+
version = "1.3.5"
77

88
repositories {
99
mavenCentral()
@@ -13,6 +13,7 @@ repositories {
1313
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
1414
maven { url = uri("https://jitpack.io") }
1515
maven { url = uri("https://repo.eternalcode.pl/releases") }
16+
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
1617
}
1718

1819
java {

chatformatter-core/build.gradle.kts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id("eternalcode.java")
3-
id("com.github.johnrengelman.shadow")
3+
id("com.gradleup.shadow")
44
}
55

66
dependencies {
@@ -10,31 +10,40 @@ dependencies {
1010
testImplementation("org.spigotmc:spigot-api:$spigotApiVersion")
1111

1212
// Kyori Adventure & MiniMessage
13-
val adventureVersion = "4.3.2"
14-
val miniMessageVersion = "4.16.0"
15-
implementation("net.kyori:adventure-platform-bukkit:$adventureVersion")
13+
val adventureVersion = "4.4.1"
14+
val miniMessageVersion = "4.26.1"
15+
implementation("net.kyori:adventure-api:$miniMessageVersion")
1616
implementation("net.kyori:adventure-text-minimessage:$miniMessageVersion")
17+
implementation("net.kyori:adventure-platform-bukkit:$adventureVersion")
1718
testImplementation("net.kyori:adventure-platform-bukkit:$adventureVersion")
1819
testImplementation("net.kyori:adventure-text-minimessage:$miniMessageVersion")
1920

2021
// CDN Configs
21-
val cdnVersion = "1.14.4"
22+
val cdnVersion = "1.14.9"
2223
implementation("net.dzikoysk:cdn:$cdnVersion")
2324
testImplementation("net.dzikoysk:cdn:$cdnVersion")
2425

2526
// bStats
26-
implementation("org.bstats:bstats-bukkit:3.0.2")
27+
implementation("org.bstats:bstats-bukkit:3.1.0")
2728

2829
// PlaceholderAPI & Vault
29-
compileOnly("me.clip:placeholderapi:2.11.5")
30+
compileOnly("me.clip:placeholderapi:2.12.2")
3031
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
3132

3233
// GitCheck
3334
implementation("com.eternalcode:gitcheck:1.0.0")
3435

3536
// JUnit 5
36-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2")
37-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2")
37+
testImplementation(platform("org.junit:junit-bom:6.0.3"))
38+
testImplementation("org.junit.jupiter:junit-jupiter-api")
39+
testImplementation("org.junit.jupiter:junit-jupiter-params")
40+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
41+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
42+
43+
testImplementation("org.mockito:mockito-core:5.21.0")
44+
testImplementation("org.mockito:mockito-junit-jupiter:5.21.0")
45+
testImplementation("me.clip:placeholderapi:2.12.2")
46+
testImplementation("org.assertj:assertj-core:3.27.7")
3847
}
3948

4049
tasks {

chatformatter-core/src/main/java/com/eternalcode/formatter/ChatFormatterApiProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ public static ChatFormatterApi get() {
1919

2020
return chatFormatterAPI;
2121
}
22-
2322
}

0 commit comments

Comments
 (0)