Skip to content

Commit 3c028f4

Browse files
committed
[publish] 6.0.12 fix packet send
1 parent b6ed302 commit 3c028f4

File tree

2 files changed

+9
-5
lines changed
  • module
    • module-configuration/src/main/kotlin/taboolib/module/configuration/util
    • module-nms/src/main/kotlin/taboolib/module/nms

2 files changed

+9
-5
lines changed

module/module-configuration/src/main/kotlin/taboolib/module/configuration/util/Sections.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fun <V> ConfigurationSection.mapValue(transform: (Any) -> V): Map<String, V> {
1616
return getKeys(false).associateWith { transform(get(it)!!) }
1717
}
1818

19-
fun <V> ConfigurationSection.mapValue(node: String, transform: (ConfigurationSection) -> V): Map<String, V> {
20-
return getConfigurationSection(node)?.mapSection(transform) ?: emptyMap()
19+
fun <V> ConfigurationSection.mapValue(node: String, transform: (Any) -> V): Map<String, V> {
20+
return getConfigurationSection(node)?.mapValue(transform) ?: emptyMap()
2121
}
2222

2323
fun <V> ConfigurationSection.mapSection(transform: (ConfigurationSection) -> V): Map<String, V> {

module/module-nms/src/main/kotlin/taboolib/module/nms/PacketSender.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ object PacketSender {
3434
val connection = getConnection(player)
3535
if (sendPacketMethod == null) {
3636
val reflexClass = ReflexClass.of(connection.javaClass)
37-
// 1.19 更名为 send 方法
38-
sendPacketMethod = if (MinecraftVersion.isHigherOrEqual(MinecraftVersion.V1_19)) {
39-
reflexClass.getMethod("send", true, true, packet)
37+
// 1.18 更名为 send 方法
38+
sendPacketMethod = if (MinecraftVersion.isHigherOrEqual(MinecraftVersion.V1_18)) {
39+
try {
40+
reflexClass.getMethod("send", true, true, packet)
41+
} catch (_: NoSuchMethodException) {
42+
reflexClass.getMethod("sendPacket", true, true, packet)
43+
}
4044
} else {
4145
reflexClass.getMethod("sendPacket", true, true, packet)
4246
}

0 commit comments

Comments
 (0)