mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 21:06:31 +00:00
修复1.20.1
This commit is contained in:
@@ -1164,9 +1164,19 @@ public class PacketConsumers {
|
||||
try {
|
||||
BukkitServerPlayer player = (BukkitServerPlayer) user;
|
||||
String name = (String) Reflections.field$ServerboundHelloPacket$name.get(packet);
|
||||
UUID uuid = (UUID) Reflections.field$ServerboundHelloPacket$uuid.get(packet);
|
||||
player.setName(name);
|
||||
player.setUUID(uuid);
|
||||
if (VersionHelper.isVersionNewerThan1_20_2()) {
|
||||
UUID uuid = (UUID) Reflections.field$ServerboundHelloPacket$uuid.get(packet);
|
||||
player.setUUID(uuid);
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Optional<UUID> uuid = (Optional<UUID>) Reflections.field$ServerboundHelloPacket$uuid.get(packet);
|
||||
if (uuid.isPresent()) {
|
||||
player.setUUID(uuid.get());
|
||||
} else {
|
||||
player.setUUID(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CraftEngine.instance().logger().warn("Failed to handle ServerboundHelloPacket", e);
|
||||
}
|
||||
|
||||
@@ -6452,8 +6452,12 @@ public class Reflections {
|
||||
);
|
||||
|
||||
public static final Field field$ServerboundHelloPacket$uuid = requireNonNull(
|
||||
VersionHelper.isVersionNewerThan1_20_2() ?
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$ServerboundHelloPacket, UUID.class, 0
|
||||
) :
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$ServerboundHelloPacket, Optional.class, 0
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user