Skip to content

Commit

Permalink
update: 添加调试命令用来获取当前版本结构
Browse files Browse the repository at this point in the history
  • Loading branch information
BingZi-233 committed Dec 23, 2024
1 parent 55f067b commit 02348d1
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=online.bingzi.bilibili.video
version=2.0.4-beta1
version=2.0.4-beta2
kotlin.incremental=true
kotlin.incremental.java=true
kotlin.incremental.useClasspathSnapshot=true
Expand Down
6 changes: 6 additions & 0 deletions project/core/src/main/resources/lang/zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ commandVersionSuccess: "&a&lVersion >>\n&a&l当前版本: {0} \n&a&l最新版本
commandVersionFailed: "&a&lVersion >>\n&a&l当前版本: {0} \n&c&l更新检查: 失败 \n&a&l开发者名单: {1}\n&a&l开源地址: https://github.com/BingZi-233/BilibiliVideo"
commandBuvid3Show: "&a&lBuvid3: {0}"
commandBuvid3Refresh: "&a&lBuvid3 >>\n&a&lOld: {0} \n&a&lNew: {1} "

# 新增的命令相关
packetPlayOutMapStructure: "&a&lPacketPlayOutMap 结构: \n{0}"
mapItemStructure: "&a&lMapItem 结构: \n{0}"
packetPlayOutMapError: "&c&l无法获取结构: {0}"
invalidType: "&c&l无效的类型: {0}"
1 change: 1 addition & 0 deletions project/runtime-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
// 引入 服务端 核心
compileOnly("ink.ptms.core:v12004:12004:mapped")
compileOnly("ink.ptms.core:v12004:12004:universal")
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
}

// 子模块
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,15 @@ object CommandMain {
*/
@CommandBody(permission = "BilibiliVideo.command.buvid3", permissionDefault = PermissionDefault.OP)
val buvid3 = CommandBuvid3.execute

/**
* MapInfo
* <p>
* 定义获取地图包数据结构的命令
*
* @since 2.0.4
*/
@CommandBody(permission = "BilibiliVideo.command.mapinfo", permissionDefault = PermissionDefault.OP)
val mapInfo = CommandMapInfo.execute
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package online.bingzi.bilibili.video.internal.command

import com.comphenix.protocol.utility.MinecraftReflection
import taboolib.common.platform.ProxyCommandSender
import taboolib.common.platform.command.subCommand
import taboolib.module.lang.sendInfo

/**
* Command map info
* <p>
* 命令·地图信息
*
* @constructor Create empty Command map info
*
* @since 2.0.4
*/
object CommandMapInfo {
/**
* 执行获取地图包数据结构的命令。
*
* @since 2.0.4
*/
val execute = subCommand {
dynamic(comment = "type") {
suggestion<ProxyCommandSender> { _, _ -> listOf("PacketPlayOutMap", "MapItemStructure") }
execute<ProxyCommandSender> { sender, context, _ ->
val type = context.argument(0)
try {
when (type) {
"PacketPlayOutMap" -> {
// 获取 PacketPlayOutMap 类
val packetPlayOutMapClass = MinecraftReflection.getMinecraftClass("PacketPlayOutMap")
// 获取类的字段信息
val fields = packetPlayOutMapClass.declaredFields.joinToString("\n") { it.toString() }
// 发送信息给命令发送者
sender.sendInfo("packetPlayOutMapStructure", fields)
}

"MapItemStructure" -> {
// 获取 MapItem 类
val mapItemClass = MinecraftReflection.getMinecraftClass("ItemMap")
// 获取类的字段信息
val fields = mapItemClass.declaredFields.joinToString("\n") { it.toString() }
// 发送信息给命令发送者
sender.sendInfo("mapItemStructure", fields)
}

else -> {
sender.sendInfo("invalidType", type)
}
}
} catch (e: Exception) {
sender.sendInfo("packetPlayOutMapError", e.message ?: "Unknown error")
}
}
}
}
}

0 comments on commit 02348d1

Please sign in to comment.