-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
242 lines (211 loc) · 8.73 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
242 lines (211 loc) · 8.73 KB
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
import dex.plugins.outlet.v2.util.ReleaseType
import groovy.json.JsonSlurper
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import net.minecrell.pluginyml.paper.PaperPluginDescription
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
plugins {
id("idea")
kotlin("jvm") version "2.3.21"
kotlin("plugin.serialization") version "2.3.21"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21"
id("xyz.jpenilla.run-paper") version "2.3.0"
id("net.minecrell.plugin-yml.paper") version "0.6.0"
id("com.modrinth.minotaur") version "2.+"
id("io.github.dexman545.outlet") version "1.8.0"
id("com.gradleup.shadow") version "9.2.2"
}
group = properties["group"] as String
version = properties["version"] as String
description = properties["description"] as String
val gameVersion by properties
val projectName = properties["name"] as String
repositories {
mavenLocal()
mavenCentral()
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://dl.cloudsmith.io/public/matyrobbrt/javanbt/maven/")
}
dependencies {
paperweight.paperDevBundle("$gameVersion.build.+")
// Kotlin libraries
library(kotlin("stdlib"))
library("org.jetbrains.kotlinx:kotlinx-serialization-json:1.10.+")
library("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.+")
// MC Libraries
implementation("de.miraculixx:mc-commons:1.0.1")
implementation("de.miraculixx:kpaper-light:1.2.2")
implementation("dev.jorel:commandapi-paper-shade:11.2.0")
implementation("dev.jorel:commandapi-kotlin-paper:11.2.0")
implementation("io.github.matyrobbrt:javanbt:0.0.3")
// Internal APIs
implementation("de.miraculixx:mbridge:1.0.0")
implementation("de.miraculixx:challenge-api:1.5.0")
// External APIs
compileOnly("de.miraculixx:mweb:1.1.0")
compileOnly("de.miraculixx:timer-api:1.1.3")
// Paper Includes
paperLibrary("io.ktor:ktor-client-core-jvm:3.4.3")
paperLibrary("io.ktor:ktor-client-cio-jvm:3.4.3")
}
tasks {
assemble {
dependsOn(shadowJar)
}
compileJava {
options.encoding = "UTF-8"
options.release.set(25)
}
compileKotlin {
compilerOptions.jvmTarget.set(JvmTarget.JVM_25)
}
shadowJar {
dependencies {
include {
it.moduleGroup == "de.miraculixx" || it.moduleGroup == "dev.jorel"
}
}
relocate("dev.jorel.commandapi", "de.miraculixx.mchallenge.commandapi")
}
}
sourceSets {
main {
resources.srcDirs("$rootDir/data/")
}
}
paper {
main = "$group.${projectName.lowercase()}.${projectName}"
apiVersion = "1.21"
load = BukkitPluginDescription.PluginLoadOrder.STARTUP
// Plugin bootstrapper/loader
//bootstrapper = "$group.${projectName.lowercase()}.loader.${projectName}Bootstrap"
loader = "$group.${projectName.lowercase()}.loader.${projectName}Loader"
hasOpenClassloader = true
generateLibrariesJson = true
website = "https://mutils.net/ch/info"
authors = listOf("Miraculixx", "NoRisk")
serverDependencies {
register("MTimer") {
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
required = false
}
register("MWeb") {
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
required = false
}
}
}
modrinth {
//token.set(properties["modrinthToken"] as String)
projectId.set(properties["modrinthProjectId"] as? String ?: properties["name"] as String)
versionNumber.set(version as String)
versionType.set(properties["publishState"] as String)
uploadFile.set(tasks.jar)
versionName = "MChallenge - ${properties["version"]}"
outlet.mcVersionRange = properties["supportedVersions"] as String
outlet.allowedReleaseTypes = setOf(ReleaseType.RELEASE)
gameVersions.addAll(outlet.mcVersions())
loaders.addAll(buildList {
add("paper")
add("purpur")
})
dependencies {
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
// The type can either be `project` or `version`
required.project("mweb")
}
changelog = "- New Challenge -> Onestack (Stack limit)\n- New Challenge Setting -> Entity drop randomizer for items"
syncBodyFrom = rootProject.file(".github/assets/README-Modrinth.md").readText()
}
//
// Custom Tasks
//
fun get(key: String, map: Map<String, Any>): String? {
var route: Any? = map
key.split('.').forEach {
if (route is Map<*, *>) {
route = (route as Map<*, *>)[it]
} else {
return null
}
}
return route?.toString()
}
data class Challenge(
val key: String,
val version: String,
val item: String?,
val block: String?,
val head: String?,
val tags: List<String>,
val settings: List<String> = emptyList(),
val new: Boolean = false,
val preview: String? = null
)
@Suppress("UNCHECKED_CAST")
val craftReadme = task("craftReadme") {
group = "publishing"
doLast {
val challengeFile = File("data/challenges.json")
val challengeSlurper = JsonSlurper().parse(challengeFile) as List<Map<String, Any>>
val challengeList = challengeSlurper.map {
Challenge(
it["key"].toString(),
it["version"].toString(),
it["item"] as? String,
it["block"] as? String,
it["head"] as? String,
it["tags"] as List<String>,
(it["settings"] as? List<String>) ?: emptyList(),
it["new"] == true,
it["preview"] as? String
)
}.sortedByDescending { it.tags.contains("FREE") }
val languageFile = File("data/language/mchallenge/en.yml")
val yaml = Yaml(DumperOptions().apply { defaultFlowStyle = DumperOptions.FlowStyle.BLOCK })
val languageMap = yaml.load<Map<String, Any>>(languageFile.inputStream())
val challengeString = buildString {
challengeList.forEach { challenge ->
val name = get("items.ch.${challenge.key}.n", languageMap)
val iconUrl = when {
challenge.item != null -> "https://mutils.net/images/mc/grab/items/${challenge.item}.png"
challenge.block != null -> "https://mutils.net/images/mc/grab/rendered/${challenge.block}.png"
challenge.head != null -> "https://mc-heads.net/head/${challenge.head}"
else -> "https://mutils.net/images/mc/grab/items/barrier.png"
}
append("<details><summary><b>$name</b> ▪ <img src='$iconUrl' width='18'></summary>\n")
append(get("items.ch.${challenge.key}.l", languageMap)?.replace("<br>", " "))
append("\n\n---\n\n⚙\uFE0F **Settings**")
if (challenge.settings.isEmpty()) append("\n- `No settings`")
else {
challenge.settings.forEach { setting ->
val settingName = get("items.chS.${challenge.key}.$setting.n", languageMap)
val description = get("items.chS.${challenge.key}.$setting.l", languageMap)?.replace("<br>", " ")
append("\n- `$settingName`")
if (description != null) append(" - $description")
}
}
append("\n\n\uD83C\uDFF7\uFE0F **Tags**")
challenge.tags.forEach tags@{ tag ->
if (tag == "FREE") return@tags
val tagName = tag[0] + tag.substring(1).lowercase()
val description = get("tags.$tag.l", languageMap)?.replace("<br>", " ")
append("\n- `$tagName` - $description")
}
challenge.preview?.let { append("\n\n") }
if (!challenge.tags.contains("FREE")) append("<br>*Currently requires full access*")
append("\n</details>")
}
}
val githubRemover = Regex("<!-- github_exclude\\.start -->(.*?)<!-- github_exclude\\.end -->", RegexOption.DOT_MATCHES_ALL)
val sourceFile = File(".github/assets/README.md")
val readmeModrinth = File(".github/assets/README-Modrinth.md")
val readmeFile = File("README.md")
var readmeContent = sourceFile.readText()
readmeContent = readmeContent.replace("<!-- challenges -->", challengeString)
readmeContent = readmeContent.replace("<!-- challenge-count -->", (challengeList.size + 10).toString()) // Multi Challenges: Disabler 6, Mirror 4, Force Collect 3
readmeModrinth.writeText(readmeContent)
readmeFile.writeText(githubRemover.replace(readmeContent, ""))
}
}