mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 20:09:13 +00:00
Merge pull request #65 from jhqwqmc/dev
fix(network): 适配 Paper1.21.4-222 版本更改
This commit is contained in:
@@ -906,9 +906,14 @@ public class PacketConsumers {
|
|||||||
Object id = Reflections.method$CustomPacketPayload$Type$id.invoke(type);
|
Object id = Reflections.method$CustomPacketPayload$Type$id.invoke(type);
|
||||||
String channel = id.toString();
|
String channel = id.toString();
|
||||||
if (!channel.equals(NetworkManager.MOD_CHANNEL)) return;
|
if (!channel.equals(NetworkManager.MOD_CHANNEL)) return;
|
||||||
ByteBuf buf = (ByteBuf) Reflections.method$DiscardedPayload$data.invoke(payload);
|
byte[] data;
|
||||||
byte[] data = new byte[buf.readableBytes()];
|
if (Reflections.method$DiscardedPayload$data != null) {
|
||||||
buf.readBytes(data);
|
ByteBuf buf = (ByteBuf) Reflections.method$DiscardedPayload$data.invoke(payload);
|
||||||
|
data = new byte[buf.readableBytes()];
|
||||||
|
buf.readBytes(data);
|
||||||
|
} else {
|
||||||
|
data = (byte[]) Reflections.method$DiscardedPayload$dataByteArray.invoke(payload);
|
||||||
|
}
|
||||||
String decodeData = new String(data, StandardCharsets.UTF_8);
|
String decodeData = new String(data, StandardCharsets.UTF_8);
|
||||||
if (!decodeData.endsWith("init")) return;
|
if (!decodeData.endsWith("init")) return;
|
||||||
int firstColon = decodeData.indexOf(':');
|
int firstColon = decodeData.indexOf(':');
|
||||||
|
|||||||
@@ -5668,11 +5668,20 @@ public class Reflections {
|
|||||||
.map(it -> ReflectionUtils.getMethod(it, clazz$ResourceLocation))
|
.map(it -> ReflectionUtils.getMethod(it, clazz$ResourceLocation))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
// 1.20.5+
|
// 1.20.5~1.21.4#221
|
||||||
public static final Method method$DiscardedPayload$data = Optional.ofNullable(clazz$DiscardedPayload)
|
public static final Method method$DiscardedPayload$data = Optional.ofNullable(clazz$DiscardedPayload)
|
||||||
.map(it -> ReflectionUtils.getMethod(it, ByteBuf.class))
|
.map(it -> ReflectionUtils.getMethod(it, ByteBuf.class))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
|
// 1.21.4#222+
|
||||||
|
// 我tm服了这个 sb paper 你 tmd 乱改签名干什么有病啊
|
||||||
|
public static final Method method$DiscardedPayload$dataByteArray = Optional.ofNullable(method$DiscardedPayload$data)
|
||||||
|
.map(m -> (Method) null)
|
||||||
|
.orElseGet(() -> Optional.ofNullable(clazz$DiscardedPayload)
|
||||||
|
.map(clazz -> ReflectionUtils.getMethod(clazz, byte[].class))
|
||||||
|
.orElse(null)
|
||||||
|
);
|
||||||
|
|
||||||
public static final Class<?> clazz$ClientboundDisconnectPacket = requireNonNull(
|
public static final Class<?> clazz$ClientboundDisconnectPacket = requireNonNull(
|
||||||
ReflectionUtils.getClazz(
|
ReflectionUtils.getClazz(
|
||||||
BukkitReflectionUtils.assembleMCClass("network.protocol.common.ClientboundDisconnectPacket"),
|
BukkitReflectionUtils.assembleMCClass("network.protocol.common.ClientboundDisconnectPacket"),
|
||||||
|
|||||||
Reference in New Issue
Block a user