fix package

This commit is contained in:
zimzaza4
2024-06-24 22:01:49 +08:00
parent e30a9b5f83
commit 427c4c3e89

View File

@@ -26,13 +26,15 @@ public class ReflectionUtils {
public static Method CLIENTBOUND_GET_CHANNEL_METHOD; public static Method CLIENTBOUND_GET_CHANNEL_METHOD;
public static boolean OLD_VERSION = false;
@SneakyThrows @SneakyThrows
public static void init() { public static void init() {
PlatformType type = GeyserImpl.getInstance().platformType(); PlatformType type = GeyserImpl.getInstance().platformType();
if (type == PlatformType.STANDALONE) { if (type == PlatformType.STANDALONE) {
prefix = ""; prefix = "";
} else { } else {
prefix = "org.geysermc.geyser.platform." + type.platformName().toLowerCase() + "."; prefix = "org.geysermc.geyser.platform." + type.platformName().toLowerCase() + ".shaded.";
} }
CLIENTBOUND_PAYLOAD_PACKET_CLASS = ClientboundCustomPayloadPacket.class; CLIENTBOUND_PAYLOAD_PACKET_CLASS = ClientboundCustomPayloadPacket.class;
SERVERBOUND_PAYLOAD_PACKET_CLASS = ServerboundCustomPayloadPacket.class; SERVERBOUND_PAYLOAD_PACKET_CLASS = ServerboundCustomPayloadPacket.class;
@@ -43,6 +45,7 @@ public class ReflectionUtils {
try { try {
SERVERBOUND_PAYLOAD_PACKET_CONSTRUCTOR = SERVERBOUND_PAYLOAD_PACKET_CLASS.getConstructor(KEY_CLASS, byte[].class); SERVERBOUND_PAYLOAD_PACKET_CONSTRUCTOR = SERVERBOUND_PAYLOAD_PACKET_CLASS.getConstructor(KEY_CLASS, byte[].class);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
OLD_VERSION = true;
SERVERBOUND_PAYLOAD_PACKET_CONSTRUCTOR = SERVERBOUND_PAYLOAD_PACKET_CLASS.getConstructor(String.class, byte[].class); SERVERBOUND_PAYLOAD_PACKET_CONSTRUCTOR = SERVERBOUND_PAYLOAD_PACKET_CLASS.getConstructor(String.class, byte[].class);
} }
KEY_BUILD_METHOD = KEY_CLASS.getMethod("key", String.class); KEY_BUILD_METHOD = KEY_CLASS.getMethod("key", String.class);
@@ -62,6 +65,7 @@ public class ReflectionUtils {
} }
@SneakyThrows @SneakyThrows
public static Object buildKey(String key) { public static Object buildKey(String key) {
if (OLD_VERSION) return key;
return KEY_BUILD_METHOD.invoke(null, key); return KEY_BUILD_METHOD.invoke(null, key);
} }