3 Commits

Author SHA1 Message Date
sbbtd
0fcc1c0d54 fix: UUID API 2024-02-22 15:05:22 +08:00
adef471210 Fix UUID API
Update version to v1.1.0
2024-02-22 09:17:07 +08:00
feb2d309e0 Update version to v1.0.0
Update dependencies
Fix null UUID error
2023-09-03 01:13:52 +08:00
4 changed files with 15 additions and 16 deletions

View File

@@ -1,22 +1,22 @@
plugins { plugins {
val kotlinVersion = "1.7.10" val kotlinVersion = "1.8.10"
kotlin("jvm") version kotlinVersion kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion kotlin("plugin.serialization") version kotlinVersion
id("net.mamoe.mirai-console") version "2.13.2" id("net.mamoe.mirai-console") version "2.16.0"
} }
group = "top.jie65535" group = "top.jie65535.mirai"
version = "0.1.2" version = "1.1.1"
repositories { repositories {
maven("https://maven.aliyun.com/repository/public") maven("https://maven.aliyun.com/repository/public")
mavenCentral() mavenCentral()
} }
val ktorVersion = "2.2.2"
dependencies { dependencies {
val ktorVersion = "2.3.8"
implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion") implementation("io.ktor:ktor-client-okhttp-jvm:$ktorVersion")
} }

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -9,7 +9,7 @@ object JMinecraftSkin : KotlinPlugin(
JvmPluginDescription( JvmPluginDescription(
id = "top.jie65535.mirai-console-jms-plugin", id = "top.jie65535.mirai-console-jms-plugin",
name = "J Minecraft Skin", name = "J Minecraft Skin",
version = "0.1.2", version = "1.1.1",
) { ) {
author("jie65535") author("jie65535")
info("MC皮肤查询插件") info("MC皮肤查询插件")

View File

@@ -1,10 +1,7 @@
package top.jie65535 package top.jie65535
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.decodeFromString import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.*
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonPrimitive
/** /**
* Minecraft UUID Service * Minecraft UUID Service
@@ -16,20 +13,22 @@ object MinecraftUuidService {
/** /**
* 根据游戏角色名获取UUID * 根据游戏角色名获取UUID
*/ */
@OptIn(ExperimentalSerializationApi::class)
fun getUuid(username: String) : String { fun getUuid(username: String) : String {
var uuid = JMSPluginData.idMap[username] var uuid = JMSPluginData.idMap[username]
if (uuid != null) { if (uuid != null) {
return uuid return uuid
} }
val retJson = HttpUtil.get("https://tenapi.cn/mc/?uid=$username").decodeToString() val retJson = HttpUtil.get("https://tenapi.cn/v2/mc/?uid=$username").decodeToString()
val response = Json.decodeFromString<JsonObject>(retJson) val response = Json.decodeFromString<JsonObject>(retJson)
if (response["code"]!!.jsonPrimitive.content == "200") { if (response["code"]!!.jsonPrimitive.content == "200") {
uuid = response["id"]!!.jsonPrimitive.content val elem = response["data"]!!.jsonObject["id"]!!.jsonPrimitive
if (elem == JsonNull) throw Exception("Player UUID Not Found!")
uuid = elem.content
} else { } else {
throw Exception(response["msg"]!!.jsonPrimitive.content) throw Exception(response["msg"]!!.jsonPrimitive.content)
} }
JMSPluginData.idMap[username] = uuid JMSPluginData.idMap[username] = uuid
return uuid return uuid
} }