mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 12:29:15 +00:00
fix(auth): 修复获取不可信uuid
This commit is contained in:
@@ -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;
|
||||
@@ -2405,6 +2406,11 @@ public class PacketConsumers {
|
||||
CoreReflections.methodHandle$ServerCommonPacketListenerImpl$closedSetter.invokeExact(packetListener, false);
|
||||
}
|
||||
|
||||
// 重新获取已验证的uuid
|
||||
GameProfile gameProfile = (GameProfile) CoreReflections.methodHandle$ServerConfigurationPacketListenerImpl$gameProfileGetter.invokeExact(packetListener);
|
||||
user.setName(gameProfile.getName());
|
||||
user.setUUID(gameProfile.getId());
|
||||
|
||||
ResourcePackHost host = CraftEngine.instance().packManager().resourcePackHost();
|
||||
host.requestResourcePackDownloadLink(user.uuid()).thenAccept(dataList -> {
|
||||
if (dataList.isEmpty()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.craftengine.bukkit.plugin.reflection.minecraft;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -3764,4 +3765,24 @@ public final class CoreReflections {
|
||||
clazz$Level, clazz$BlockPos, clazz$BlockState, clazz$Player
|
||||
)
|
||||
);
|
||||
|
||||
public static final Field field$ServerConfigurationPacketListenerImpl$gameProfile = Optional.ofNullable(clazz$ServerConfigurationPacketListenerImpl)
|
||||
.map(it -> ReflectionUtils.getDeclaredField(it, GameProfile.class, 0))
|
||||
.orElse(null);
|
||||
|
||||
public static final MethodHandle methodHandle$ServerConfigurationPacketListenerImpl$gameProfileGetter;
|
||||
|
||||
static {
|
||||
try {
|
||||
if (VersionHelper.isOrAbove1_20_2()) {
|
||||
methodHandle$ServerConfigurationPacketListenerImpl$gameProfileGetter =
|
||||
ReflectionUtils.unreflectGetter(field$ServerConfigurationPacketListenerImpl$gameProfile)
|
||||
.asType(MethodType.methodType(GameProfile.class, Object.class));
|
||||
} else {
|
||||
methodHandle$ServerConfigurationPacketListenerImpl$gameProfileGetter = null;
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new ReflectionInitException("Failed to initialize reflection", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user