9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 04:19:27 +00:00

Merge pull request #272 from jhqwqmc/fix-untrust-uuid

fix(auth): 修复获取不可信uuid
This commit is contained in:
XiaoMoMi
2025-07-08 19:22:50 +08:00
committed by GitHub
6 changed files with 25 additions and 1 deletions

View File

@@ -156,6 +156,7 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
registerNMSPacketConsumer(PacketConsumers.ROTATE_HEAD, NetworkReflections.clazz$ClientboundRotateHeadPacket);
registerNMSPacketConsumer(PacketConsumers.SET_ENTITY_MOTION, NetworkReflections.clazz$ClientboundSetEntityMotionPacket);
registerNMSPacketConsumer(PacketConsumers.FINISH_CONFIGURATION, NetworkReflections.clazz$ClientboundFinishConfigurationPacket);
registerNMSPacketConsumer(PacketConsumers.LOGIN_FINISHED, NetworkReflections.clazz$ClientboundLoginFinishedPacket);
registerS2CByteBufPacketConsumer(PacketConsumers.LEVEL_CHUNK_WITH_LIGHT, this.packetIds.clientboundLevelChunkWithLightPacket());
registerS2CByteBufPacketConsumer(PacketConsumers.SECTION_BLOCK_UPDATE, this.packetIds.clientboundSectionBlocksUpdatePacket());
registerS2CByteBufPacketConsumer(PacketConsumers.BLOCK_UPDATE, this.packetIds.clientboundBlockUpdatePacket());

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.bukkit.plugin.network;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Either;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -2436,4 +2437,14 @@ public class PacketConsumers {
CraftEngine.instance().logger().warn("Failed to handle ClientboundFinishConfigurationPacket", e);
}
};
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> LOGIN_FINISHED = (user, event, packet) -> {
try {
GameProfile gameProfile = FastNMS.INSTANCE.field$ClientboundLoginFinishedPacket$gameProfile(packet);
user.setName(gameProfile.getName());
user.setUUID(gameProfile.getId());
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to handle ClientboundLoginFinishedPacket", e);
}
};
}

View File

@@ -1554,4 +1554,11 @@ public final class NetworkReflections {
throw new ReflectionInitException("Failed to initialize ServerCommonPacketListener$handleResourcePackResponse", e);
}
}
public static final Class<?> clazz$ClientboundLoginFinishedPacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.login.PacketLoginOutSuccess",
List.of("network.protocol.login.ClientboundLoginFinishedPacket", "network.protocol.login.ClientboundGameProfilePacket")
)
);
}