Skip to content

Commit 765b66d

Browse files
committed
record modify
1 parent dec6e10 commit 765b66d

27 files changed

+567
-683
lines changed

build.gradle.kts

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
plugins {
22
kotlin("jvm") version "2.2.0"
3+
kotlin("plugin.serialization") version "2.2.0"
4+
5+
id("love.forte.plugin.suspend-transform") version "2.2.0-0.13.1"
36
id("com.google.devtools.ksp") version "2.2.0-2.0.2"
47
id("org.jetbrains.dokka") version "2.0.0"
58
id("com.vanniktech.maven.publish") version "0.33.0"
@@ -14,6 +17,8 @@ kotlin {
1417
compilerOptions {
1518
freeCompilerArgs.add("-Xjvm-default=all")
1619
}
20+
21+
explicitApi()
1722
}
1823

1924
dokka {
@@ -24,6 +29,13 @@ dokka {
2429
}
2530
}
2631

32+
suspendTransformPlugin {
33+
transformers {
34+
addJvmBlocking()
35+
addJvmAsync()
36+
}
37+
}
38+
2739
repositories {
2840
mavenCentral()
2941
mavenLocal()
@@ -32,15 +44,13 @@ repositories {
3244
dependencies {
3345
// kotlinx
3446
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
47+
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
3548

36-
// retrofit
37-
api("com.squareup.retrofit2:retrofit:3.0.0")
38-
api("com.squareup.retrofit2:converter-moshi:3.0.0")
39-
40-
// moshi
41-
api("com.squareup.moshi:moshi:1.15.2")
42-
api("com.squareup.moshi:moshi-kotlin:1.15.2")
43-
ksp("com.squareup.moshi:moshi-kotlin-codegen:1.15.2")
49+
// ktor
50+
api("io.ktor:ktor-client-core:3.3.0")
51+
api("io.ktor:ktor-client-content-negotiation:3.3.0")
52+
api("io.ktor:ktor-serialization-kotlinx-json:3.3.0")
53+
testImplementation("io.ktor:ktor-client-cio:3.3.0")
4454

4555
// DNSJava
4656
api("dnsjava:dnsjava:3.6.3")
@@ -58,30 +68,30 @@ configure<com.vanniktech.maven.publish.MavenPublishBaseExtension> {
5868
coordinates("tech.aliorpse", "mcutils", version.toString())
5969

6070
pom {
61-
name.set("mcutils")
62-
description.set("Kotlin library for Minecraft operations")
63-
url.set("https://github.com/Aliorpse/kotlin-mcutils/")
64-
inceptionYear.set("2025")
71+
name = "mcutils"
72+
description = "Kotlin library for Minecraft operations"
73+
url = "https://github.com/Aliorpse/kotlin-mcutils/"
74+
inceptionYear = "2025"
6575

6676
licenses {
6777
license {
68-
name.set("MIT")
69-
url.set("https://opensource.org/licenses/MIT")
78+
name = "MIT"
79+
url = "https://opensource.org/licenses/MIT"
7080
}
7181
}
7282

7383
developers {
7484
developer {
75-
id.set("aliorpse")
76-
name.set("Aliorpse")
77-
url.set("https://github.com/Aliorpse/")
85+
id = "aliorpse"
86+
name = "Aliorpse"
87+
url = "https://github.com/Aliorpse/"
7888
}
7989
}
8090

8191
scm {
82-
url.set("https://github.com/Aliorpse/kotlin-mcutils/")
83-
connection.set("scm:git:git://github.com/Aliorpse/kotlin-mcutils.git")
84-
developerConnection.set("scm:git:ssh://git@github.com/Aliorpse/kotlin-mcutils.git")
92+
url = "https://github.com/Aliorpse/kotlin-mcutils/"
93+
connection = "scm:git:git://github.com/Aliorpse/kotlin-mcutils.git"
94+
developerConnection = "scm:git:ssh://git@github.com/Aliorpse/kotlin-mcutils.git"
8595
}
8696
}
8797
}
Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,78 @@
11
@file:Suppress("unused")
22
package tech.aliorpse.mcutils.model.modrinth
33

4-
import com.squareup.moshi.Json
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
56

67
/**
78
* Project types.
89
*/
9-
enum class ProjectType(val value: String) {
10-
@Json(name = "mod") MOD("mod"),
11-
@Json(name = "modpack") MODPACK("modpack"),
12-
@Json(name = "resourcepack") RESOURCEPACK("resourcepack"),
13-
@Json(name = "shader") SHADER("shader")
10+
@Serializable
11+
public enum class ProjectType(public val value: String) {
12+
@SerialName("mod") MOD("mod"),
13+
@SerialName("modpack") MODPACK("modpack"),
14+
@SerialName("resourcepack") RESOURCEPACK("resourcepack"),
15+
@SerialName("shader") SHADER("shader")
1416
}
1517

1618
/**
1719
* Client/server side support.
1820
*/
19-
enum class SideSupport(val value: String) {
20-
@Json(name = "required") REQUIRED("required"),
21-
@Json(name = "optional") OPTIONAL("optional"),
22-
@Json(name = "unsupported") UNSUPPORTED("unsupported"),
23-
@Json(name = "unknown") UNKNOWN("unknown")
21+
@Serializable
22+
public enum class SideSupport(public val value: String) {
23+
@SerialName("required") REQUIRED("required"),
24+
@SerialName("optional") OPTIONAL("optional"),
25+
@SerialName("unsupported") UNSUPPORTED("unsupported"),
26+
@SerialName("unknown") UNKNOWN("unknown")
2427
}
2528

2629
/**
2730
* Index/sorting methods in search.
2831
*/
29-
enum class IndexMethod(val value: String) {
30-
@Json(name = "relevance") RELEVANCE("relevance"),
31-
@Json(name = "downloads") DOWNLOADS("downloads"),
32-
@Json(name = "follows") FOLLOWS("follows"),
33-
@Json(name = "newest") NEWEST("newest"),
34-
@Json(name = "updated") UPDATED("updated")
32+
@Serializable
33+
public enum class IndexMethod(public val value: String) {
34+
@SerialName("relevance") RELEVANCE("relevance"),
35+
@SerialName("downloads") DOWNLOADS("downloads"),
36+
@SerialName("follows") FOLLOWS("follows"),
37+
@SerialName("newest") NEWEST("newest"),
38+
@SerialName("updated") UPDATED("updated")
3539
}
3640

3741
/**
3842
* Status of a project.
3943
*/
40-
enum class ProjectStatus(val value: String) {
41-
@Json(name = "approved") APPROVED("approved"),
42-
@Json(name = "archived") ARCHIVED("archived"),
43-
@Json(name = "rejected") REJECTED("rejected"),
44-
@Json(name = "draft") DRAFT("draft"),
45-
@Json(name = "unlisted") UNLISTED("unlisted"),
46-
@Json(name = "processing") PROCESSING("processing"),
47-
@Json(name = "withheld") WITHHELD("withheld"),
48-
@Json(name = "scheduled") SCHEDULED("scheduled"),
49-
@Json(name = "private") PRIVATE("private"),
50-
@Json(name = "unknown") UNKNOWN("unknown")
44+
@Serializable
45+
public enum class ProjectStatus(public val value: String) {
46+
@SerialName("approved") APPROVED("approved"),
47+
@SerialName("archived") ARCHIVED("archived"),
48+
@SerialName("rejected") REJECTED("rejected"),
49+
@SerialName("draft") DRAFT("draft"),
50+
@SerialName("unlisted") UNLISTED("unlisted"),
51+
@SerialName("processing") PROCESSING("processing"),
52+
@SerialName("withheld") WITHHELD("withheld"),
53+
@SerialName("scheduled") SCHEDULED("scheduled"),
54+
@SerialName("private") PRIVATE("private"),
55+
@SerialName("unknown") UNKNOWN("unknown")
5156
}
5257

5358
/**
5459
* Requested status for review or release scheduling.
5560
*/
56-
enum class RequestedStatus(val value: String) {
57-
@Json(name = "approved") APPROVED("approved"),
58-
@Json(name = "archived") ARCHIVED("archived"),
59-
@Json(name = "unlisted") UNLISTED("unlisted"),
60-
@Json(name = "private") PRIVATE("private"),
61-
@Json(name = "draft") DRAFT("draft")
61+
@Serializable
62+
public enum class RequestedStatus(public val value: String) {
63+
@SerialName("approved") APPROVED("approved"),
64+
@SerialName("archived") ARCHIVED("archived"),
65+
@SerialName("unlisted") UNLISTED("unlisted"),
66+
@SerialName("private") PRIVATE("private"),
67+
@SerialName("draft") DRAFT("draft")
6268
}
6369

6470
/**
6571
* Monetization status.
6672
*/
67-
enum class MonetizationStatus(val value: String) {
68-
@Json(name = "monetized") MONETIZED("monetized"),
69-
@Json(name = "demonetized") DEMONETIZED("demonetized"),
70-
@Json(name = "force-demonetized") FORCE_DEMONETIZED("force-demonetized")
73+
@Serializable
74+
public enum class MonetizationStatus(public val value: String) {
75+
@SerialName("monetized") MONETIZED("monetized"),
76+
@SerialName("demonetized") DEMONETIZED("demonetized"),
77+
@SerialName("force-demonetized") FORCE_DEMONETIZED("force-demonetized")
7178
}
Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,72 @@
11
package tech.aliorpse.mcutils.model.modrinth.project
22

3-
import com.squareup.moshi.Json
4-
import com.squareup.moshi.JsonClass
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
55
import tech.aliorpse.mcutils.model.modrinth.MonetizationStatus
66
import tech.aliorpse.mcutils.model.modrinth.ProjectStatus
77
import tech.aliorpse.mcutils.model.modrinth.ProjectType
88
import tech.aliorpse.mcutils.model.modrinth.RequestedStatus
99
import tech.aliorpse.mcutils.model.modrinth.SideSupport
1010

11-
@JsonClass(generateAdapter = true)
12-
data class ModrinthProject(
11+
@Serializable
12+
public data class ModrinthProject(
1313
val slug: String,
1414
val title: String,
1515
val description: String,
1616
val categories: List<String>,
17-
@field:Json(name = "client_side") val clientSide: SideSupport,
18-
@field:Json(name = "server_side") val serverSide: SideSupport,
19-
@field:Json(name = "project_type") val projectType: ProjectType,
17+
@SerialName("client_side") val clientSide: SideSupport,
18+
@SerialName("server_side") val serverSide: SideSupport,
19+
@SerialName("project_type") val projectType: ProjectType,
2020
val downloads: Int,
21-
@field:Json(name = "icon_url") val iconUrl: String?,
22-
val color: Int?,
23-
@field:Json(name = "thread_id") val threadId: String?,
24-
@field:Json(name = "monetization_status") val monetizationStatus: MonetizationStatus?,
25-
@field:Json(name = "id") val projectId: String,
21+
@SerialName("icon_url") val iconUrl: String? = null,
22+
val color: Int? = null,
23+
@SerialName("thread_id") val threadId: String? = null,
24+
@SerialName("monetization_status") val monetizationStatus: MonetizationStatus? = null,
25+
@SerialName("id") val projectId: String,
2626
val team: String,
27-
val body: String?,
27+
val body: String? = null,
2828
val status: ProjectStatus,
29-
@field:Json(name = "requested_status") val requestedStatus: RequestedStatus?,
30-
@field:Json(name = "additional_categories") val additionalCategories: List<String>?,
31-
@field:Json(name = "issues_url") val issuesUrl: String?,
32-
@field:Json(name = "source_url") val sourceUrl: String?,
33-
@field:Json(name = "wiki_url") val wikiUrl: String?,
34-
@field:Json(name = "discord_url") val discordUrl: String?,
35-
@field:Json(name = "donation_urls") val donationUrls: List<DonationUrl>?,
36-
@field:Json(name = "body_url") val bodyUrl: String?,
37-
@field:Json(name = "moderator_message") val moderatorMessage: String?,
29+
@SerialName("requested_status") val requestedStatus: RequestedStatus? = null,
30+
@SerialName("additional_categories") val additionalCategories: List<String>? = null,
31+
@SerialName("issues_url") val issuesUrl: String? = null,
32+
@SerialName("source_url") val sourceUrl: String? = null,
33+
@SerialName("wiki_url") val wikiUrl: String? = null,
34+
@SerialName("discord_url") val discordUrl: String? = null,
35+
@SerialName("donation_urls") val donationUrls: List<DonationUrl>? = null,
36+
@SerialName("body_url") val bodyUrl: String? = null,
37+
@SerialName("moderator_message") val moderatorMessage: String? = null,
3838
val published: String,
3939
val updated: String,
40-
val approved: String?,
41-
val queued: String?,
42-
@field:Json(name = "followers") val followers: Int,
40+
val approved: String? = null,
41+
val queued: String? = null,
42+
val followers: Int,
4343
val license: ProjectLicense,
4444
val versions: List<String>,
45-
@field:Json(name = "game_versions") val gameVersions: List<String>,
45+
@SerialName("game_versions") val gameVersions: List<String>,
4646
val loaders: List<String>,
47-
val gallery: List<GalleryItem>?,
48-
@field:Json(name = "featured_gallery") val featuredGallery: String?
47+
val gallery: List<GalleryItem>? = null,
48+
@SerialName("featured_gallery") val featuredGallery: String? = null
4949
)
5050

51-
@JsonClass(generateAdapter = true)
52-
data class DonationUrl(
53-
val id: String?,
54-
val platform: String?,
51+
@Serializable
52+
public data class DonationUrl(
53+
val id: String? = null,
54+
val platform: String? = null,
5555
val url: String
5656
)
5757

58-
@JsonClass(generateAdapter = true)
59-
data class GalleryItem(
58+
@Serializable
59+
public data class GalleryItem(
6060
val url: String,
6161
val featured: Boolean,
62-
val title: String?,
63-
val description: String?,
62+
val title: String? = null,
63+
val description: String? = null,
6464
val created: String
6565
)
6666

67-
@JsonClass(generateAdapter = true)
68-
data class ProjectLicense(
67+
@Serializable
68+
public data class ProjectLicense(
6969
val id: String,
70-
val name: String?,
71-
val url: String?
70+
val name: String? = null,
71+
val url: String? = null
7272
)
73-

src/main/kotlin/tech/aliorpse/mcutils/model/modrinth/search/ModrinthSearchConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import tech.aliorpse.mcutils.model.modrinth.IndexMethod
44
import tech.aliorpse.mcutils.model.modrinth.ProjectType
55
import tech.aliorpse.mcutils.model.modrinth.SideSupport
66

7-
data class ModrinthSearchConfig(
7+
public data class ModrinthSearchConfig(
88
var categories: List<String>? = null,
99
var versions: List<String>? = null,
1010
var type: ProjectType? = null,
@@ -23,7 +23,7 @@ data class ModrinthSearchConfig(
2323
if (value != null) add(listOf("$key:$value"))
2424
}
2525

26-
fun buildFacets(): List<List<String>> {
26+
public fun buildFacets(): List<List<String>> {
2727
val result = mutableListOf<List<String>>()
2828

2929
categories?.let { result += it.map { c -> "categories:$c" } }
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package tech.aliorpse.mcutils.model.modrinth.search
22

3-
import com.squareup.moshi.Json
4-
import com.squareup.moshi.JsonClass
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
55

6-
@JsonClass(generateAdapter = true)
7-
data class ModrinthSearchResponse(
6+
@Serializable
7+
public data class ModrinthSearchResponse(
88
val hits: List<ModrinthSearchResult>,
9-
@field:Json(name = "offset") val offset: Int,
10-
@field:Json(name = "limit") val limit: Int,
11-
@field:Json(name = "total_hits") val totalHits: Int
9+
val offset: Int,
10+
val limit: Int,
11+
@SerialName("total_hits") val totalHits: Int
1212
)

0 commit comments

Comments
 (0)