-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55f067b
commit 02348d1
Showing
5 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...me-bukkit/src/main/kotlin/online/bingzi/bilibili/video/internal/command/CommandMapInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} | ||
} | ||
} | ||
} |