mirror of
https://github.com/jie65535/mirai-console-jms-plugin.git
synced 2025-12-15 19:07:33 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| adef471210 | |||
| feb2d309e0 | |||
| 8c143bb4d4 | |||
|
|
9b281361ce | ||
| 1902e922a3 | |||
| 5113868a79 | |||
| d45d1caf56 |
@@ -1,15 +1,22 @@
|
|||||||
plugins {
|
plugins {
|
||||||
val kotlinVersion = "1.5.30"
|
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.9.2"
|
id("net.mamoe.mirai-console") version "2.16.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "top.jie65535"
|
group = "top.jie65535.mirai"
|
||||||
version = "0.1.0"
|
version = "1.1.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://maven.aliyun.com/repository/public")
|
maven("https://maven.aliyun.com/repository/public")
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
|
||||||
|
val ktorVersion = "2.3.8"
|
||||||
|
implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
|
||||||
|
implementation("io.ktor:ktor-client-okhttp-jvm:$ktorVersion")
|
||||||
|
}
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||||
|
|||||||
@@ -76,8 +76,17 @@ object JMSCommand : CompositeCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun CommandSender.sendImage(data: ByteArray) {
|
private suspend fun CommandSender.sendImage(data: ByteArray) {
|
||||||
|
try {
|
||||||
|
if (data.isEmpty()) {
|
||||||
|
subject?.sendMessage("未查询到数据")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
data.toExternalResource().use {
|
data.toExternalResource().use {
|
||||||
subject?.sendImage(it)
|
subject?.sendImage(it)
|
||||||
}
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
subject?.sendMessage(String(data))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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.0",
|
version = "1.1.0",
|
||||||
) {
|
) {
|
||||||
author("jie65535")
|
author("jie65535")
|
||||||
info("MC皮肤查询插件")
|
info("MC皮肤查询插件")
|
||||||
@@ -19,7 +19,7 @@ object JMinecraftSkin : KotlinPlugin(
|
|||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
JMSPluginData.reload()
|
JMSPluginData.reload()
|
||||||
JMSCommand.register()
|
JMSCommand.register()
|
||||||
logger.info { "Plugin loaded" }
|
logger.info { "Plugin loaded. https://github.com/jie65535/mirai-console-jcf-plugin" }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisable() {
|
override fun onDisable() {
|
||||||
|
|||||||
@@ -11,25 +11,25 @@ object MinecraftSkinService {
|
|||||||
* 获取头像
|
* 获取头像
|
||||||
*/
|
*/
|
||||||
fun getAvatars(uuid: String)
|
fun getAvatars(uuid: String)
|
||||||
= HttpUtil.get("https://crafatar.com/avatars/$uuid")
|
= HttpUtil.get("https://crafatar.com/avatars/$uuid?overlay")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取玩家头模型渲染图
|
* 获取玩家头模型渲染图
|
||||||
*/
|
*/
|
||||||
fun getHeadRenders(uuid: String)
|
fun getHeadRenders(uuid: String)
|
||||||
= HttpUtil.get("https://crafatar.com/renders/head/$uuid")
|
= HttpUtil.get("https://crafatar.com/renders/head/$uuid?overlay")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取玩家皮肤模型渲染图
|
* 获取玩家皮肤模型渲染图
|
||||||
*/
|
*/
|
||||||
fun getBodyRenders(uuid: String)
|
fun getBodyRenders(uuid: String)
|
||||||
= HttpUtil.get("https://crafatar.com/renders/body/$uuid")
|
= HttpUtil.get("https://crafatar.com/renders/body/$uuid?overlay")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取玩家皮肤源文件
|
* 获取玩家皮肤源文件
|
||||||
*/
|
*/
|
||||||
fun getSkins(uuid: String)
|
fun getSkins(uuid: String)
|
||||||
= HttpUtil.get("https://crafatar.com/skin/$uuid")
|
= HttpUtil.get("https://crafatar.com/skins/$uuid")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取玩家皮肤源文件
|
* 获取玩家皮肤源文件
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
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.Json
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonNull
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import net.mamoe.mirai.console.util.cast
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minecraft UUID Service
|
* Minecraft UUID Service
|
||||||
@@ -18,20 +16,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["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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user