mirror of
https://github.com/jie65535/mirai-console-jcf-plugin.git
synced 2025-10-20 17:19:48 +08:00
Initial commit
This commit is contained in:
225
src/main/kotlin/me/jie65535/jcf/CurseClient.kt
Normal file
225
src/main/kotlin/me/jie65535/jcf/CurseClient.kt
Normal file
@@ -0,0 +1,225 @@
|
||||
package me.jie65535.jcf
|
||||
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.okhttp.*
|
||||
import io.ktor.client.features.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.http.*
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import me.jie65535.jcf.model.addon.*
|
||||
import me.jie65535.jcf.model.addon.file.*
|
||||
import me.jie65535.jcf.model.addon.request.*
|
||||
import me.jie65535.jcf.model.category.*
|
||||
import me.jie65535.jcf.model.fingerprint.*
|
||||
import me.jie65535.jcf.model.fingerprint.request.*
|
||||
import me.jie65535.jcf.model.game.*
|
||||
import me.jie65535.jcf.model.minecraft.*
|
||||
import me.jie65535.jcf.model.minecraft.modloader.*
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
class CurseClient {
|
||||
private val json = Json {
|
||||
isLenient = true
|
||||
ignoreUnknownKeys = true
|
||||
serializersModule
|
||||
}
|
||||
private val http = HttpClient(OkHttp) {
|
||||
install(HttpTimeout) {
|
||||
this.requestTimeoutMillis = 30_0000
|
||||
this.connectTimeoutMillis = 30_0000
|
||||
this.socketTimeoutMillis = 30_0000
|
||||
}
|
||||
defaultRequest {
|
||||
url.protocol = URLProtocol.HTTPS
|
||||
url.host = "addons-ecs.forgesvc.net"
|
||||
header("accept", "*/*")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGames(supportsAddons: Boolean = false): List<Game> {
|
||||
return json.decodeFromString(
|
||||
http.get("api/v2/game") {
|
||||
parameter("supportsAddons", supportsAddons.toString())
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getGame(gameId: Int): Game {
|
||||
return json.decodeFromString(http.get("api/v2/game/$gameId"))
|
||||
}
|
||||
|
||||
suspend fun getGameDatabaseTimestamp(): Date {
|
||||
return json.decodeFromString(http.get("api/v2/game/timestamp"))
|
||||
}
|
||||
|
||||
suspend fun getAddon(projectId: Int): Addon {
|
||||
return json.decodeFromString(http.get("api/v2/addon/$projectId"))
|
||||
}
|
||||
|
||||
suspend fun getAddons(projectIds: Collection<Int>): List<Addon> {
|
||||
return json.decodeFromString(
|
||||
http.post("api/v2/addon") {
|
||||
contentType(ContentType.Application.Json)
|
||||
body = projectIds
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getAddons(vararg projectIds: Int): List<Addon> = getAddons(projectIds.toList())
|
||||
|
||||
suspend fun getAddonDescription(projectId: Int): String {
|
||||
return json.decodeFromString(http.get("api/v2/addon/$projectId/description"))
|
||||
}
|
||||
|
||||
suspend fun getAddonFiles(projectId: Int): List<AddonFile> {
|
||||
return json.decodeFromString(http.get("api/v2/addon/$projectId/files"))
|
||||
}
|
||||
|
||||
suspend fun getAddonFiles(keys: Collection<Int>): Map<Int, List<AddonFile>> {
|
||||
return json.decodeFromString(
|
||||
http.post("api/v2/addon/files") {
|
||||
contentType(ContentType.Application.Json)
|
||||
body = keys
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getAddonFiles(vararg keys: Int): Map<Int, List<AddonFile>> = getAddonFiles(keys.toList())
|
||||
|
||||
suspend fun getAddonFileDownloadUrl(projectId: Int, fileId: Int): String {
|
||||
return json.decodeFromString(http.get("api/v2/addon/$projectId/file/$fileId/download-url"))
|
||||
}
|
||||
|
||||
suspend fun getAddonFile(projectId: Int, fileId: Int): AddonFile {
|
||||
return json.decodeFromString(http.get("api/v2/addon/$projectId/file/$fileId"))
|
||||
}
|
||||
|
||||
suspend fun searchAddons(
|
||||
gameId: Int,
|
||||
sectionId: Int = -1,
|
||||
categoryId: Int = -1,
|
||||
sort: AddonSortMethod = AddonSortMethod.FEATURED,
|
||||
sortDescending: Boolean = true,
|
||||
gameVersion: String? = null,
|
||||
index: Int = 0,
|
||||
pageSize: Int = 1000,
|
||||
searchFilter: String? = null
|
||||
): List<Addon> {
|
||||
return json.decodeFromString(
|
||||
http.get("api/v2/addon/search") {
|
||||
parameter("gameId", gameId)
|
||||
parameter("sectionId", sectionId)
|
||||
parameter("categoryId", categoryId)
|
||||
parameter("gameVersion", gameVersion)
|
||||
parameter("index", index)
|
||||
parameter("pageSize", pageSize)
|
||||
parameter("searchFilter", searchFilter)
|
||||
parameter("sort", sort)
|
||||
parameter("sortDescending", sortDescending)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getFeaturedAddons(
|
||||
gameId: Int,
|
||||
featuredCount: Int = 6,
|
||||
popularCount: Int = 14,
|
||||
updatedCount: Int = 14,
|
||||
excludedAddons: Collection<Int> = listOf()
|
||||
): Map<FeaturedAddonType, List<Addon>> {
|
||||
return json.decodeFromString(
|
||||
http.post("api/v2/addon/featured") {
|
||||
contentType(ContentType.Application.Json)
|
||||
body = FeaturedAddonsRequest(gameId, featuredCount, popularCount, updatedCount, excludedAddons)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getFeaturedAddons(
|
||||
gameId: Int,
|
||||
featuredCount: Int = 6,
|
||||
popularCount: Int = 14,
|
||||
updatedCount: Int = 14,
|
||||
vararg excludedAddons: Int
|
||||
): Map<FeaturedAddonType, List<Addon>> = getFeaturedAddons(gameId, featuredCount, popularCount, updatedCount, excludedAddons.toList())
|
||||
|
||||
suspend fun getCategory(categoryId: Int): Category {
|
||||
return json.decodeFromString(http.get("api/v2/category/$categoryId"))
|
||||
}
|
||||
|
||||
suspend fun getCategory(slug: String): List<Category> {
|
||||
return json.decodeFromString(
|
||||
http.get("api/v2/category") {
|
||||
parameter("slug", slug)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getCategorySection(sectionId: Int): List<Category> {
|
||||
return json.decodeFromString(http.get("api/v2/category/section/$sectionId"))
|
||||
}
|
||||
|
||||
suspend fun getCategories(): List<Category> {
|
||||
return json.decodeFromString(http.get("api/v2/category"))
|
||||
}
|
||||
|
||||
suspend fun getCategoryDatabaseTimestamp(): Date {
|
||||
return json.decodeFromString(http.get("api/v2/category/timestamp"))
|
||||
}
|
||||
|
||||
suspend fun getFingerprintMatches(fingerprints: Collection<Long>): FingerprintMatchResult {
|
||||
return json.decodeFromString(
|
||||
http.post("api/v2/fingerprint") {
|
||||
contentType(ContentType.Application.Json)
|
||||
body = fingerprints
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getFingerprintMatches(vararg fingerprints: Long): FingerprintMatchResult = getFingerprintMatches(fingerprints.toList())
|
||||
|
||||
suspend fun getFuzzyFingerprintMatches(gameId: Int, fingerprints: List<FolderFingerprint>): List<FuzzyFingerprintMatch> {
|
||||
return json.decodeFromString(
|
||||
http.post("api/v2/fingerprint/fuzzy") {
|
||||
contentType(ContentType.Application.Json)
|
||||
body = FuzzyMatchesRequest(gameId, fingerprints)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getModloader(key: String): ModloaderVersion {
|
||||
return json.decodeFromString(http.get("api/v2/minecraft/modloader/$key"))
|
||||
}
|
||||
|
||||
suspend fun getModloaders(): List<ModloaderIndex> {
|
||||
return json.decodeFromString(http.get("api/v2/minecraft/modloader"))
|
||||
}
|
||||
|
||||
suspend fun getModloaders(gameVersion: String): List<ModloaderIndex> {
|
||||
return json.decodeFromString(
|
||||
http.get("api/v2/minecraft/modloader") {
|
||||
parameter("version", gameVersion)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getModloadersDatabaseTimestamp(): Date {
|
||||
return json.decodeFromString(http.get("api/v2/minecraft/modloader/timestamp"))
|
||||
}
|
||||
|
||||
suspend fun getMinecraftVersions(): List<MinecraftVersion> {
|
||||
return json.decodeFromString(http.get("api/v2/minecraft/version"))
|
||||
}
|
||||
|
||||
suspend fun getMinecraftVersion(gameVersion: String): MinecraftVersion {
|
||||
return json.decodeFromString(http.get("api/v2/minecraft/version/$gameVersion"))
|
||||
}
|
||||
|
||||
suspend fun getMinecraftVersionsDatabaseTimestamp(): Date {
|
||||
return json.decodeFromString(http.get("api/v2/minecraft/version/timestamp"))
|
||||
}
|
||||
}
|
27
src/main/kotlin/me/jie65535/jcf/JCurseforge.kt
Normal file
27
src/main/kotlin/me/jie65535/jcf/JCurseforge.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package me.jie65535.jcf
|
||||
|
||||
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register
|
||||
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.unregister
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
|
||||
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
|
||||
import net.mamoe.mirai.utils.info
|
||||
|
||||
object JCurseforge : KotlinPlugin(
|
||||
JvmPluginDescription(
|
||||
id = "me.jie65535.jcf",
|
||||
name = "J Curseforge Util",
|
||||
version = "0.1.0",
|
||||
) {
|
||||
author("jie65535")
|
||||
info("""Curseforge Util""")
|
||||
}
|
||||
) {
|
||||
override fun onEnable() {
|
||||
logger.info { "Plugin loaded" }
|
||||
JcfCommand.register()
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
JcfCommand.unregister()
|
||||
}
|
||||
}
|
18
src/main/kotlin/me/jie65535/jcf/JcfCommand.kt
Normal file
18
src/main/kotlin/me/jie65535/jcf/JcfCommand.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
package me.jie65535.jcf
|
||||
|
||||
import net.mamoe.mirai.console.command.CommandSender
|
||||
import net.mamoe.mirai.console.command.CompositeCommand
|
||||
|
||||
object JcfCommand : CompositeCommand(
|
||||
JCurseforge, "jcf",
|
||||
description = "Curseforge Util"
|
||||
) {
|
||||
private val curse = CurseClient()
|
||||
|
||||
@SubCommand
|
||||
@Description("帮助")
|
||||
suspend fun CommandSender.help() {
|
||||
sendMessage(usage)
|
||||
}
|
||||
|
||||
}
|
52
src/main/kotlin/me/jie65535/jcf/model/addon/Addon.kt
Normal file
52
src/main/kotlin/me/jie65535/jcf/model/addon/Addon.kt
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.addon.file.AddonFile
|
||||
import me.jie65535.jcf.model.addon.file.AddonFileLatestForGameVersion
|
||||
import me.jie65535.jcf.model.category.CategorySection
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class Addon(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val authors: List<AddonAuthor>,
|
||||
val attachments: List<AddonAttachment>,
|
||||
val websiteUrl: String,
|
||||
val gameId: Int,
|
||||
val summary: String,
|
||||
val defaultFileId: Int,
|
||||
val downloadCount: Double,
|
||||
val latestFiles: List<AddonFile>,
|
||||
val categories: List<AddonCategory>,
|
||||
val status: AddonStatus,
|
||||
val primaryCategoryId: Int,
|
||||
val categorySection: CategorySection,
|
||||
val slug: String,
|
||||
val gameVersionLatestFiles: List<AddonFileLatestForGameVersion>,
|
||||
val isFeatured: Boolean,
|
||||
val popularityScore: Double,
|
||||
val gamePopularityRank: Int,
|
||||
val primaryLanguage: String,
|
||||
val gameSlug: String,
|
||||
val gameName: String,
|
||||
val portalName: String,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateModified: Date,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateCreated: Date,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateReleased: Date,
|
||||
val isAvailable: Boolean,
|
||||
@SerialName("isExperiemental")
|
||||
val isExperimental: Boolean
|
||||
)
|
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AddonAttachment(
|
||||
val id: Int,
|
||||
val projectId: Int,
|
||||
val description: String,
|
||||
val isDefault: Boolean,
|
||||
val thumbnailUrl: String,
|
||||
val title: String,
|
||||
val url: String,
|
||||
val status: AddonAttachmentStatus
|
||||
)
|
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
|
||||
@Serializable(with = AddonAttachmentStatus.Ser::class)
|
||||
enum class AddonAttachmentStatus {
|
||||
NORMAL,
|
||||
DELETED,
|
||||
UPLOADING,
|
||||
BANNED,
|
||||
PENDING_MODERATION;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonAttachmentStatus>("$MODEL_PACKAGE.addon.AttachmentStatus", values())
|
||||
}
|
22
src/main/kotlin/me/jie65535/jcf/model/addon/AddonAuthor.kt
Normal file
22
src/main/kotlin/me/jie65535/jcf/model/addon/AddonAuthor.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AddonAuthor(
|
||||
val name: String,
|
||||
val url: String,
|
||||
val projectId: Int,
|
||||
val id: Int,
|
||||
val projectTitleId: Int?,
|
||||
val projectTitleTitle: String?,
|
||||
val userId: Int,
|
||||
val twitchId: Int?
|
||||
)
|
23
src/main/kotlin/me/jie65535/jcf/model/addon/AddonCategory.kt
Normal file
23
src/main/kotlin/me/jie65535/jcf/model/addon/AddonCategory.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AddonCategory(
|
||||
val categoryId: Int,
|
||||
val name: String,
|
||||
val url: String,
|
||||
val avatarUrl: String?,
|
||||
val parentId: Int?,
|
||||
val rootId: Int?,
|
||||
val projectId: Int,
|
||||
val avatarId: Int?,
|
||||
val gameId: Int
|
||||
)
|
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonPackageType.Ser::class)
|
||||
enum class AddonPackageType {
|
||||
FOLDER,
|
||||
CTOC,
|
||||
SINGLE_FILE,
|
||||
CMOD2,
|
||||
MOD_PACK,
|
||||
MOD;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonPackageType>("$MODEL_PACKAGE.addon.AddonPackageType", values())
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.addon.file.AddonFile
|
||||
|
||||
@Serializable
|
||||
data class AddonRepositoryMatch(
|
||||
val id: Int,
|
||||
val latestFiles: List<AddonFile>
|
||||
)
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonRestrictFileAccess.Ser::class)
|
||||
enum class AddonRestrictFileAccess {
|
||||
NONE,
|
||||
ALPHA,
|
||||
ALPHA_AND_BETA;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonRestrictFileAccess>("$MODEL_PACKAGE.addon.AddonRestrictFileAccess", values())
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
|
||||
enum class AddonSortMethod {
|
||||
FEATURED,
|
||||
POPULARITY,
|
||||
LAST_UPDATED,
|
||||
NAME,
|
||||
AUTHOR,
|
||||
TOTAL_DOWNLOADS,
|
||||
CATEGORY,
|
||||
GAME_VERSION
|
||||
}
|
28
src/main/kotlin/me/jie65535/jcf/model/addon/AddonStatus.kt
Normal file
28
src/main/kotlin/me/jie65535/jcf/model/addon/AddonStatus.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonStatus.Ser::class)
|
||||
enum class AddonStatus {
|
||||
NEW,
|
||||
CHANGES_REQUIRED,
|
||||
UNDER_SOFT_REVIEW,
|
||||
APPROVED,
|
||||
REJECTED,
|
||||
CHANGES_MADE,
|
||||
INACTIVE,
|
||||
ABANDONED,
|
||||
DELETED,
|
||||
UNDER_REVIEW;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonStatus>("$MODEL_PACKAGE.addon.AddonStatus", values())
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class FeaturedAddonType {
|
||||
@SerialName("Featured")
|
||||
FEATURED,
|
||||
@SerialName("Popular")
|
||||
POPULAR,
|
||||
@SerialName("RecentlyUpdated")
|
||||
RECENTLY_UPDATED;
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class SortableGameVersion(
|
||||
val gameVersionPadded: String,
|
||||
val gameVersion: String,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val gameVersionReleaseDate: Date,
|
||||
val gameVersionName: String
|
||||
)
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.addon.AddonPackageType
|
||||
import me.jie65535.jcf.model.addon.AddonRestrictFileAccess
|
||||
import me.jie65535.jcf.model.addon.AddonStatus
|
||||
import me.jie65535.jcf.model.addon.SortableGameVersion
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class AddonFile(
|
||||
val id: Int,
|
||||
val displayName: String,
|
||||
val fileName: String,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val fileDate: Date,
|
||||
val fileLength: Long,
|
||||
val releaseType: AddonFileReleaseType,
|
||||
val fileStatus: AddonFileStatus,
|
||||
val downloadUrl: String,
|
||||
val isAlternate: Boolean,
|
||||
val alternateFileId: Int,
|
||||
val dependencies: List<AddonFileDependency>,
|
||||
val isAvailable: Boolean,
|
||||
val modules: List<AddonFileModule>,
|
||||
val packageFingerprint: Long,
|
||||
val gameVersion: List<String>,
|
||||
val sortableGameVersion: List<SortableGameVersion>? = null,
|
||||
val installMetadata: String?,
|
||||
val changelog: String? = null,
|
||||
val hasInstallScript: Boolean,
|
||||
val isCompatibleWithClient: Boolean? = null,
|
||||
val categorySectionPackageType: AddonPackageType? = null,
|
||||
val restrictProjectFileAccess: AddonRestrictFileAccess? = null,
|
||||
val projectStatus: AddonStatus? = null,
|
||||
val renderCacheId: Int? = null,
|
||||
val fileLegacyMappingId: Int? = null,
|
||||
val projectId: Int? = null,
|
||||
val parentProjectFileId: Int? = null,
|
||||
val parentFileLegacyMappingId: Int? = null,
|
||||
val fileTypeId: Int? = null,
|
||||
val exposeAsAlternative: Boolean? = null,
|
||||
val packageFingerprintId: Int? = null,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val gameVersionDateReleased: Date?,
|
||||
val gameVersionMappingId: Int? = null,
|
||||
val gameVersionId: Int? = null,
|
||||
val gameId: Int? = null,
|
||||
val isServerPack: Boolean = false,
|
||||
val serverPackFileId: Int?,
|
||||
val gameVersionFlavor: String?
|
||||
)
|
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AddonFileDependency(
|
||||
val id: Int? = null,
|
||||
val addonId: Int,
|
||||
val type: AddonFileRelationType,
|
||||
val fileId: Int? = null
|
||||
)
|
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonFileFingerprintType.Ser::class)
|
||||
enum class AddonFileFingerprintType {
|
||||
PACKAGE,
|
||||
MODULE,
|
||||
MAIN_MODULE,
|
||||
FILE,
|
||||
REFERRENCED_FILE;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonFileFingerprintType>("$MODEL_PACKAGE.addon.file.AddonFileFingerprintType", values())
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AddonFileLatestForGameVersion(
|
||||
val gameVersion: String,
|
||||
val projectFileId: Int,
|
||||
val projectFileName: String,
|
||||
val fileType: AddonFileReleaseType,
|
||||
val gameVersionFlavor: String?
|
||||
)
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AddonFileModule(
|
||||
@SerialName("foldername")
|
||||
val folderName: String,
|
||||
val fingerprint: Long,
|
||||
val type: AddonFileFingerprintType? = null
|
||||
)
|
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonFileRelationType.Ser::class)
|
||||
enum class AddonFileRelationType {
|
||||
EMBEDDED_LIBRARY,
|
||||
OPTIONAL_DEPENDENCY,
|
||||
REQUIRED_DEPENDENCY,
|
||||
TOOL,
|
||||
INCOMPATIBLE,
|
||||
INCLUDE;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonFileRelationType>("$MODEL_PACKAGE.addon.file.AddonFileRelationType", values())
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonFileReleaseType.Ser::class)
|
||||
enum class AddonFileReleaseType {
|
||||
RELEASE,
|
||||
BETA,
|
||||
ALPHA;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonFileReleaseType>("$MODEL_PACKAGE.addon.file.AddonFileReleaseType", values())
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.addon.file
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = AddonFileStatus.Ser::class)
|
||||
enum class AddonFileStatus {
|
||||
PROCESSING,
|
||||
CHANGES_REQUIRED,
|
||||
UNDER_REVIEW,
|
||||
APPROVED,
|
||||
REJECTED,
|
||||
MALWARE_DETECTED,
|
||||
DELETED,
|
||||
ARCHIVED,
|
||||
TESTING,
|
||||
RELEASED,
|
||||
READY_FOR_REVIEW,
|
||||
DEPRECATED,
|
||||
BAKING,
|
||||
AWAITING_FOR_PUBLISHING,
|
||||
FAILED_PUBLISHING;
|
||||
|
||||
internal object Ser : EnumIntSerializer<AddonFileStatus>("$MODEL_PACKAGE.addon.file.AddonFileStatus", values())
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package me.jie65535.jcf.model.addon.request
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FeaturedAddonsRequest(
|
||||
val gameId: Int,
|
||||
val featuredCount: Int,
|
||||
val popularCount: Int,
|
||||
val updatedCount: Int,
|
||||
val excludedAddons: Collection<Int>
|
||||
)
|
25
src/main/kotlin/me/jie65535/jcf/model/category/Category.kt
Normal file
25
src/main/kotlin/me/jie65535/jcf/model/category/Category.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.category
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class Category(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val slug: String,
|
||||
val avatarUrl: String?,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateModified: Date,
|
||||
val parentGameCategoryId: Int?,
|
||||
val rootGameCategoryId: Int?,
|
||||
val gameId: Int
|
||||
)
|
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.category
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.addon.AddonPackageType
|
||||
|
||||
@Serializable
|
||||
data class CategorySection(
|
||||
val extraIncludePattern: String?,
|
||||
val gameCategoryId: Int,
|
||||
val gameId: Int,
|
||||
val id: Int,
|
||||
val initialInclusionPattern: String,
|
||||
val name: String,
|
||||
val packageType: AddonPackageType,
|
||||
val path: String
|
||||
)
|
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.fingerprint
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.addon.file.AddonFile
|
||||
|
||||
@Serializable
|
||||
data class FingerprintMatch(
|
||||
val id: Int,
|
||||
val file: AddonFile,
|
||||
val latestFiles: List<AddonFile>
|
||||
)
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.fingerprint
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FingerprintMatchResult(
|
||||
val isCacheBuilt: Boolean,
|
||||
val exactMatches: List<FingerprintMatch>,
|
||||
val exactFingerprints: List<Long>,
|
||||
val partialMatches: List<FingerprintMatch>,
|
||||
val partialMatchFingerprints: Map<String, List<Long>>,
|
||||
val installedFingerprints: List<Long>,
|
||||
val unmatchedFingerprints: List<Long>
|
||||
)
|
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.fingerprint
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FolderFingerprint(
|
||||
@SerialName("foldername")
|
||||
val folderName: String,
|
||||
val fingerprints: List<Long>
|
||||
)
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.fingerprint
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.addon.file.AddonFile
|
||||
|
||||
@Serializable
|
||||
data class FuzzyFingerprintMatch(
|
||||
val id: Int,
|
||||
val file: AddonFile,
|
||||
val latestFiles: List<AddonFile>,
|
||||
val fingerprints: List<Long>
|
||||
)
|
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.fingerprint.request
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.fingerprint.FolderFingerprint
|
||||
|
||||
@Serializable
|
||||
data class FuzzyMatchesRequest(
|
||||
val gameId: Int,
|
||||
val fingerprints: List<FolderFingerprint>
|
||||
)
|
41
src/main/kotlin/me/jie65535/jcf/model/game/Game.kt
Normal file
41
src/main/kotlin/me/jie65535/jcf/model/game/Game.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.category.CategorySection
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class Game(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val slug: String,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateModified: Date,
|
||||
val gameFiles: List<GameFile>,
|
||||
val gameDetectionHints: List<GameDetectionHint>,
|
||||
val fileParsingRules: List<GameFileParsingRule>,
|
||||
val categorySections: List<CategorySection>,
|
||||
val maxFreeStorage: Long,
|
||||
val maxPremiumStorage: Long,
|
||||
val maxFileSize: Long,
|
||||
val addonSettingsFolderFilter: String?,
|
||||
val addonSettingsStartingFolder: String?,
|
||||
val addonSettingsFileFilter: String?,
|
||||
val addonSettingsFileRemovalFilter: String?,
|
||||
val supportsAddons: Boolean,
|
||||
val supportsPartnerAddons: Boolean,
|
||||
@Serializable(with = SupportedClientConfiguration.Ser::class)
|
||||
val supportedClientConfiguration: Set<SupportedClientConfiguration>,
|
||||
val supportsNotifications: Boolean,
|
||||
val profilerAddonId: Int,
|
||||
val twitchGameId: Int,
|
||||
val clientGameSettingsId: Int
|
||||
)
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class GameDetectionHint(
|
||||
val id: Int,
|
||||
val hintType: GameDetectionHintType,
|
||||
val hintPath: String,
|
||||
val hintKey: String?,
|
||||
@Serializable(with = GameDetectionHintOption.Ser::class)
|
||||
val hintOptions: Set<GameDetectionHintOption>,
|
||||
val gameId: Int
|
||||
)
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import me.jie65535.jcf.util.internal.FlagSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
enum class GameDetectionHintOption {
|
||||
NONE,
|
||||
INCLUDE_SUB_FOLDERS,
|
||||
FOLDER_ONLY;
|
||||
|
||||
internal object Ser : FlagSerializer<GameDetectionHintOption>("$MODEL_PACKAGE.game.GameDetectionHintOption", NONE to 0x1, INCLUDE_SUB_FOLDERS to 0x2, FOLDER_ONLY to 0x4)
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = GameDetectionHintType.Ser::class)
|
||||
enum class GameDetectionHintType {
|
||||
REGISTRY,
|
||||
FILE_PATH;
|
||||
|
||||
internal object Ser : EnumIntSerializer<GameDetectionHintType>("$MODEL_PACKAGE.game.GameDetectionHintType", values())
|
||||
}
|
20
src/main/kotlin/me/jie65535/jcf/model/game/GameFile.kt
Normal file
20
src/main/kotlin/me/jie65535/jcf/model/game/GameFile.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class GameFile(
|
||||
val id: Int,
|
||||
val gameId: Int,
|
||||
val isRequired: Boolean,
|
||||
val fileName: String,
|
||||
val fileType: GameFileType,
|
||||
val platformType: GamePlatformType
|
||||
)
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class GameFileParsingRule(
|
||||
val commentStripPattern: String,
|
||||
val fileExtension: String,
|
||||
val inclusionPattern: String,
|
||||
val gameId: Int,
|
||||
val id: Int
|
||||
)
|
22
src/main/kotlin/me/jie65535/jcf/model/game/GameFileType.kt
Normal file
22
src/main/kotlin/me/jie65535/jcf/model/game/GameFileType.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = GameFileType.Ser::class)
|
||||
enum class GameFileType {
|
||||
GENERIC,
|
||||
GAME,
|
||||
LAUNCHER,
|
||||
PROFILER_LOCK_CHECK;
|
||||
|
||||
internal object Ser : EnumIntSerializer<GameFileType>("$MODEL_PACKAGE.game.GameFileType", values())
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = GamePlatformType.Ser::class)
|
||||
enum class GamePlatformType {
|
||||
GENERIC,
|
||||
WINDOWS_32,
|
||||
WINDOWS_64,
|
||||
WINDOWS,
|
||||
OSX;
|
||||
|
||||
internal object Ser : EnumIntSerializer<GamePlatformType>("$MODEL_PACKAGE.game.GamePlatformType", values())
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.game
|
||||
|
||||
import me.jie65535.jcf.util.internal.FlagSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
enum class SupportedClientConfiguration {
|
||||
DEBUG,
|
||||
BETA,
|
||||
RELEASE;
|
||||
|
||||
internal object Ser : FlagSerializer<SupportedClientConfiguration>("$MODEL_PACKAGE.game.SupportedClientConfiguration", DEBUG to 0x1, BETA to 0x2, RELEASE to 0x4)
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class MinecraftVersion(
|
||||
val id: Int,
|
||||
val gameVersionId: Int,
|
||||
val versionString: String,
|
||||
val jarDownloadUrl: String,
|
||||
val jsonDownloadUrl: String,
|
||||
val approved: Boolean,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateModified: Date,
|
||||
val gameVersionTypeId: Int,
|
||||
val gameVersionStatus: MinecraftVersionStatus,
|
||||
val gameVersionTypeStatus: MinecraftVersionTypeStatus
|
||||
)
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = MinecraftVersionStatus.Ser::class)
|
||||
enum class MinecraftVersionStatus {
|
||||
APPROVED,
|
||||
DELETED,
|
||||
NEW;
|
||||
|
||||
internal object Ser : EnumIntSerializer<MinecraftVersionStatus>("$MODEL_PACKAGE.game.MinecraftVersionStatus", values())
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = MinecraftVersionTypeStatus.Ser::class)
|
||||
enum class MinecraftVersionTypeStatus {
|
||||
NORMAL,
|
||||
DELETED;
|
||||
|
||||
internal object Ser : EnumIntSerializer<MinecraftVersionTypeStatus>("$MODEL_PACKAGE.game.MinecraftVersionTypeStatus", values())
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft.modloader
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class ModloaderIndex(
|
||||
val name: String,
|
||||
val gameVersion: String,
|
||||
val latest: Boolean,
|
||||
val recommended: Boolean,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateModified: Date
|
||||
)
|
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft.modloader
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = ModloaderInstallMethod.Ser::class)
|
||||
enum class ModloaderInstallMethod {
|
||||
ANY,
|
||||
FORGE,
|
||||
CAULDRON,
|
||||
LITE_LOADER;
|
||||
|
||||
internal object Ser : EnumIntSerializer<ModloaderInstallMethod>("$MODEL_PACKAGE.game.ModloaderInstallMethod", values())
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft.modloader
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.util.internal.EnumIntSerializer
|
||||
import me.jie65535.jcf.util.internal.MODEL_PACKAGE
|
||||
|
||||
@Serializable(with = ModloaderType.Ser::class)
|
||||
enum class ModloaderType {
|
||||
ANY,
|
||||
FORGE,
|
||||
CAULDRON,
|
||||
LITE_LOADER;
|
||||
|
||||
internal object Ser : EnumIntSerializer<ModloaderType>("$MODEL_PACKAGE.game.ModloaderType", values(), 0)
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.model.minecraft.modloader
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import me.jie65535.jcf.model.minecraft.MinecraftVersionStatus
|
||||
import me.jie65535.jcf.model.minecraft.MinecraftVersionTypeStatus
|
||||
import me.jie65535.jcf.util.Date
|
||||
import me.jie65535.jcf.util.internal.DateSerializer
|
||||
|
||||
@Serializable
|
||||
data class ModloaderVersion(
|
||||
val id: Int,
|
||||
val gameVersionId: Int,
|
||||
val minecraftGameVersionId: Int,
|
||||
val forgeVersion: String,
|
||||
val name: String,
|
||||
val type: ModloaderType,
|
||||
val downloadUrl: String,
|
||||
@SerialName("filename")
|
||||
val fileName: String,
|
||||
val installMethod: ModloaderInstallMethod,
|
||||
val latest: Boolean,
|
||||
val recommended: Boolean,
|
||||
val approved: Boolean,
|
||||
@Serializable(with = DateSerializer::class)
|
||||
val dateModified: Date,
|
||||
val mavenVersionString: String,
|
||||
val versionJson: String,
|
||||
val librariesInstallLocation: String,
|
||||
val minecraftVersion: String,
|
||||
val additionalFilesJson: String,
|
||||
val modLoaderGameVersionId: Int,
|
||||
val modLoaderGameVersionTypeId: Int,
|
||||
val modLoaderGameVersionStatus: MinecraftVersionStatus,
|
||||
val modLoaderGameVersionTypeStatus: MinecraftVersionTypeStatus,
|
||||
val mcGameVersionId: Int,
|
||||
val mcGameVersionTypeId: Int,
|
||||
val mcGameVersionStatus: MinecraftVersionStatus,
|
||||
val mcGameVersionTypeStatus: MinecraftVersionTypeStatus,
|
||||
val installProfileJson: String
|
||||
)
|
5
src/main/kotlin/me/jie65535/jcf/util/Date.kt
Normal file
5
src/main/kotlin/me/jie65535/jcf/util/Date.kt
Normal file
@@ -0,0 +1,5 @@
|
||||
package me.jie65535.jcf.util
|
||||
|
||||
import java.time.OffsetDateTime
|
||||
|
||||
typealias Date = OffsetDateTime
|
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.util.internal
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
import me.jie65535.jcf.util.Date
|
||||
import java.time.OffsetDateTime
|
||||
|
||||
internal object DateSerializer : KSerializer<Date> {
|
||||
override val descriptor = PrimitiveSerialDescriptor("Date", PrimitiveKind.STRING)
|
||||
|
||||
override fun deserialize(decoder: Decoder): Date {
|
||||
return OffsetDateTime.parse(decoder.decodeString())
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Date) {
|
||||
encoder.encodeString(value.toString())
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.util.internal
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
|
||||
internal open class EnumIntSerializer<T>(private val serialName: String, private val values: Array<T>, private val startFrom: Int = 1) : KSerializer<T> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(serialName, PrimitiveKind.INT)
|
||||
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
val value = decoder.decodeInt()
|
||||
return values[value - startFrom] ?: throw NoSuchElementException("Can't find $serialName with key $value")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: T) {
|
||||
encoder.encodeInt(values.indexOf(value) + startFrom)
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright © 2020, PearX Team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package me.jie65535.jcf.util.internal
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
|
||||
internal open class FlagSerializer<T : Enum<T>>(serialName: String, private val map: Map<T, Int>) : KSerializer<Set<T>> {
|
||||
constructor(serialName: String, vararg pairs: Pair<T, Int>) : this(serialName, mapOf(*pairs))
|
||||
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(serialName, PrimitiveKind.INT)
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Set<T>) {
|
||||
var bits = 0
|
||||
for(flag in value) {
|
||||
bits = bits or (map[flag] ?: error(""))
|
||||
}
|
||||
encoder.encodeInt(bits)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Set<T> {
|
||||
val set = mutableSetOf<T>()
|
||||
val bits = decoder.decodeInt()
|
||||
for((flag, shift) in map) {
|
||||
if(bits and shift == shift)
|
||||
set += flag
|
||||
}
|
||||
return set
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
package me.jie65535.jcf.util.internal
|
||||
|
||||
internal const val MODEL_PACKAGE = "me.jie65535.jcf.model"
|
@@ -0,0 +1 @@
|
||||
me.jie65535.jcf.JCurseforge
|
Reference in New Issue
Block a user