-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbuild.gradle.kts
283 lines (254 loc) · 11.9 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.jetbrains.kotlin.jvm") version ("1.9.25")
id("com.gradleup.shadow") version ("8.3.6")
}
group = "com.github.shynixn"
version = "7.18.0"
repositories {
mavenLocal()
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://shynixn.github.io/m2/repository/releases")
maven(System.getenv("SHYNIXN_MCUTILS_REPOSITORY_2025")) // All MCUTILS libraries are private and not OpenSource.
}
dependencies {
// Compile Only
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
// Library dependencies with legacy compatibility, we can use more up-to-date version in the plugin.yml
implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.22.0")
implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.22.0")
implementation("com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.22.0")
implementation("com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.22.0")
implementation("com.github.shynixn:fasterxml:1.2.0")
implementation("com.zaxxer:HikariCP:4.0.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
// Custom dependencies
implementation("com.github.shynixn.shyscoreboard:shyscoreboard:1.5.0")
implementation("com.github.shynixn.mcutils:common:2025.22")
implementation("com.github.shynixn.mcutils:packet:2025.17")
implementation("com.github.shynixn.mcutils:database:2025.7")
implementation("com.github.shynixn.mcutils:sign:2025.4")
implementation("com.github.shynixn.mcutils:worldguard:2025.4")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
/**
* Include all but exclude debugging classes.
*/
tasks.withType<ShadowJar> {
dependsOn("jar")
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}-shadowjar.${archiveExtension.get()}")
exclude("DebugProbesKt.bin")
exclude("module-info.class")
}
/**
* Create all plugin jar files.
*/
tasks.register("pluginJars") {
dependsOn("pluginJarLatest")
dependsOn("pluginJarPremium")
dependsOn("pluginJarLegacy")
}
/**
* Relocate Plugin Jar.
*/
tasks.register("relocatePluginJar", ShadowJar::class.java) {
dependsOn("shadowJar")
from(zipTree(File("./build/libs/" + (tasks.getByName("shadowJar") as Jar).archiveFileName.get())))
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}-relocate.${archiveExtension.get()}")
relocate("com.github.shynixn.mcutils", "com.github.shynixn.blockball.lib.com.github.shynixn.mcutils")
relocate("com.github.shynixn.shyscoreboard", "com.github.shynixn.blockball.lib.com.github.shynixn.shyscoreboard")
}
/**
* Create latest plugin jar file.
*/
tasks.register("pluginJarLatest", ShadowJar::class.java) {
dependsOn("relocatePluginJar")
from(zipTree(File("./build/libs/" + (tasks.getByName("relocatePluginJar") as Jar).archiveFileName.get())))
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}-latest.${archiveExtension.get()}")
// destinationDirectory.set(File("C:\\temp\\plugins"))
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_8_R3/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_9_R2/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_17_R1/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_18_R1/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_18_R2/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_19_R1/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_19_R2/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_19_R3/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_20_R1/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_20_R2/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_20_R3/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_20_R4/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_21_R1/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_21_R2/**")
exclude("com/github/shynixn/blockball/lib/com/github/shynixn/mcutils/packet/nms/v1_21_R3/**")
exclude("com/github/shynixn/mcutils/**")
exclude("com/github/shynixn/mccoroutine/**")
exclude("com/github/shynixn/shyscoreboard/**")
exclude("com/github/shynixn/fasterxml/**")
exclude("org/**")
exclude("kotlin/**")
exclude("kotlinx/**")
exclude("javax/**")
exclude("com/zaxxer/**")
exclude("templates/**")
exclude("plugin-legacy.yml")
}
/**
* Create premium plugin jar file.
*/
tasks.register("pluginJarPremium", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class.java) {
dependsOn("relocatePluginJar")
from(zipTree(File("./build/libs/" + (tasks.getByName("relocatePluginJar") as Jar).archiveFileName.get())))
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}-premium.${archiveExtension.get()}")
// destinationDirectory.set(File("C:\\temp\\plugins"))
exclude("com/github/shynixn/mcutils/**")
exclude("com/github/shynixn/mccoroutine/**")
exclude("com/github/shynixn/shyscoreboard/**")
exclude("com/github/shynixn/fasterxml/**")
exclude("org/**")
exclude("kotlin/**")
exclude("kotlinx/**")
exclude("javax/**")
exclude("com/zaxxer/**")
exclude("templates/**")
exclude("plugin-legacy.yml")
}
/**
* Relocate legacy plugin jar file.
*/
tasks.register("relocateLegacyPluginJar", ShadowJar::class.java) {
dependsOn("shadowJar")
from(zipTree(File("./build/libs/" + (tasks.getByName("shadowJar") as Jar).archiveFileName.get())))
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}-legacy-relocate.${archiveExtension.get()}")
relocate("kotlin", "com.github.shynixn.blockball.lib.kotlin")
relocate("kotlinx", "com.github.shynixn.blockball.lib.kotlinx")
relocate("org.intellij", "com.github.shynixn.blockball.lib.org.intelli")
relocate("org.jetbrains", "com.github.shynixn.blockball.lib.org.jetbrains")
relocate("javax.inject", "com.github.shynixn.blockball.lib.javax.inject")
relocate("javax.annotation", "com.github.shynixn.blockball.lib.javax.annotation")
relocate("org.slf4j", "com.github.shynixn.blockball.lib.org.slf4j")
relocate("com.github.shynixn.mccoroutine", "com.github.shynixn.blockball.lib.com.github.shynixn.mccoroutine")
relocate("com.google", "com.github.shynixn.blockball.lib.com.google")
relocate("com.zaxxer", "com.github.shynixn.blockball.lib.com.zaxxer")
relocate("org.apache", "com.github.shynixn.blockball.lib.org.apache")
relocate("com.github.shynixn.mcutils", "com.github.shynixn.blockball.lib.com.github.shynixn.mcutils")
relocate("com.github.shynixn.mccoroutine", "com.github.shynixn.blockball.lib.com.github.shynixn.mccoroutine")
relocate("com.github.shynixn.shyscoreboard", "com.github.shynixn.blockball.lib.com.github.shynixn.shyscoreboard")
relocate("com.github.shynixn.fasterxml", "com.github.shynixn.blockball.lib.com.github.shynixn.fasterxml")
exclude("plugin.yml")
rename("plugin-legacy.yml", "plugin.yml")
}
/**
* Create legacy plugin jar file.
*/
tasks.register("pluginJarLegacy", ShadowJar::class.java) {
dependsOn("relocateLegacyPluginJar")
from(zipTree(File("./build/libs/" + (tasks.getByName("relocateLegacyPluginJar") as Jar).archiveFileName.get())))
archiveFileName.set("${archiveBaseName.get()}-${archiveVersion.get()}-legacy.${archiveExtension.get()}")
// destinationDirectory.set(File("C:\\temp\\plugins"))
exclude("com/github/shynixn/mcutils/**")
exclude("com/github/shynixn/mccoroutine/**")
exclude("com/github/shynixn/shyscoreboard/**")
exclude("com/github/shynixn/fasterxml/**")
exclude("org/**")
exclude("kotlin/**")
exclude("kotlinx/**")
exclude("javax/**")
exclude("com/zaxxer/**")
exclude("templates/**")
exclude("plugin-legacy.yml")
}
tasks.register("languageFile") {
val kotlinSrcFolder = project.sourceSets.toList()[0].allJava.srcDirs.first { e -> e.endsWith("java") }
val contractFile = kotlinSrcFolder.resolve("com/github/shynixn/blockball/contract/BlockBallLanguage.kt")
val resourceFile = kotlinSrcFolder.parentFile.resolve("resources").resolve("lang").resolve("en_us.yml")
val lines = resourceFile.readLines()
val contractContents = ArrayList<String>()
val ignoredKeys = listOf(
"shyScoreboardPlayerNotFoundMessage",
"shyScoreboardNoPermissionCommand",
"shyScoreboardReloadCommandHint",
"shyScoreboardReloadMessage",
"shyScoreboardCommonErrorMessage",
"shyScoreboardCommandSenderHasToBePlayer",
"shyScoreboardCommandUsage",
"shyScoreboardCommandDescription",
"shyScoreboardAddCommandHint",
"shyScoreboardSetCommandHint",
"shyScoreboardRemoveCommandHint",
"shyScoreboardNotFoundMessage",
"shyScoreboardNoPermissionToScoreboardCommand",
"shyScoreboardAddedMessage",
"shyScoreboardRemovedMessage",
"shyScoreboardUpdateCommandHint",
"shyScoreboardUpdatedMessage",
"shyScoreboardBooleanNotFoundMessage"
)
contractContents.add("package com.github.shynixn.blockball.contract")
contractContents.add("")
contractContents.add("import com.github.shynixn.shyscoreboard.contract.ShyScoreboardLanguage")
contractContents.add("import com.github.shynixn.mcutils.common.language.LanguageItem")
contractContents.add("import com.github.shynixn.mcutils.common.language.LanguageProvider")
contractContents.add("")
contractContents.add("interface BlockBallLanguage : LanguageProvider, ShyScoreboardLanguage {")
for (key in lines) {
if (key.toCharArray()[0].isLetter()) {
if (ignoredKeys.contains(key.substring(0, key.length - 1))) {
continue
}
}
}
contractContents.removeLast()
contractContents.add("}")
contractFile.printWriter().use { out ->
for (line in contractContents) {
out.println(line)
}
}
val implFile = kotlinSrcFolder.resolve("com/github/shynixn/blockball/BlockBallLanguageImpl.kt")
val implContents = ArrayList<String>()
implContents.add("package com.github.shynixn.blockball")
implContents.add("")
implContents.add("import com.github.shynixn.mcutils.common.language.LanguageItem")
implContents.add("import com.github.shynixn.blockball.contract.BlockBallLanguage")
implContents.add("")
implContents.add("class BlockBallLanguageImpl : BlockBallLanguage {")
implContents.add(
" override val names: List<String>\n" +
" get() = listOf(\"en_us\")"
)
for (i in lines.indices) {
val key = lines[i]
if (key.toCharArray()[0].isLetter()) {
var text: String
var j = i
while (true) {
if (lines[j].contains("text:")) {
text = lines[j]
break
}
j++
}
implContents.add(" override var ${key.replace(":", "")} = LanguageItem(${text.replace(" text: ", "")})")
implContents.add("")
}
}
implContents.removeLast()
implContents.add("}")
implFile.printWriter().use { out ->
for (line in implContents) {
out.println(line)
}
}
}
tasks.register("printVersion") {
println(version)
}