Skip to content

PacketSender#getConnectionHybrid 中反射获取 ServerPlayer#connection 时的版本兼容性问题 #680

@CalenXwX

Description

@CalenXwX

老师泥蠔!反馈一个小问题w

PacketSender#getConnectionHybrid用反射获取ServerPlayer(EntityPlayer)#connection

listOf("connection", "b", "c", "playerConnection")

Bukkit1.20.1的映射文件bukkit-8788cf22-members.csrg里

net/minecraft/server/level/EntityPlayer b LOGGER
net/minecraft/server/level/EntityPlayer c connection

Bukkit1.18.2的映射文件bukkit-732abad1-members.csrg里

net/minecraft/server/level/EntityPlayer b connection

TabooLib在CatServer1.20.1中运行时反射"b"会得到LOGGER 然后把LOGGER当成connection来发包
在CatServer1.18.2里没有这个问题

复现条件
1.在CatServer1.20.1(https://github.com/Luohuayu/CatServer/tree/1.20.1)安装TrMenu3.9.25(https://github.com/CoderKuo/TrMenu),TrMenu在运行时会自动下载TabooLib6.2.4
2.在游戏中空手点击另一名玩家
此时服务器会出现大量重复的报错 但不会崩溃

[23:25:53] [pool-23-thread-1/INFO] []: java.lang.NoSuchMethodException: Failed to find sendPacket method. Connection type: org.apache.logging.slf4j.Log4jLogger, Packet type: net.minecraft.network.protocol.game.PacketPlayOutCloseWindow, Server: Hybrid Server
[23:25:53] [pool-23-thread-1/INFO] []: 	at me.arasple.mc.trmenu.taboolib.module.nms.PacketSender.getSendPacketMethodHybrid(PacketSender.kt:146)
[23:25:53] [pool-23-thread-1/INFO] []: 	at me.arasple.mc.trmenu.taboolib.module.nms.PacketSender.sendPacket(PacketSender.kt:72)
[23:25:53] [pool-23-thread-1/INFO] []: 	at me.arasple.mc.trmenu.taboolib.module.nms.MinecraftServerUtilKt.sendPacketBlocking(MinecraftServerUtil.kt:209)
[23:25:53] [pool-23-thread-1/INFO] []: 	at me.arasple.mc.trmenu.taboolib.module.nms.MinecraftServerUtilKt.sendPacket$lambda$5(MinecraftServerUtil.kt:174)
[23:25:53] [pool-23-thread-1/INFO] []: 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[23:25:53] [pool-23-thread-1/INFO] []: 	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
[23:25:53] [pool-23-thread-1/INFO] []: 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
[23:25:53] [pool-23-thread-1/INFO] []: 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[23:25:53] [pool-23-thread-1/INFO] []: 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[23:25:53] [pool-23-thread-1/INFO] []: 	at java.base/java.lang.Thread.run(Thread.java:833)

或许可以考虑再加个版本判断然后用不同的名字来反射什么的xwx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions