Properly create profiles with custom name/uuid (#7558)

This commit is contained in:
Bjarne Koll
2022-03-19 14:39:38 +01:00
parent c80c018a4e
commit 6b895464b0
4 changed files with 38 additions and 13 deletions

View File

@@ -660,10 +660,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Override
+ public com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) {
+ Player player = uuid != null ? Bukkit.getPlayer(uuid) : (name != null ? Bukkit.getPlayerExact(name) : null);
+ if (player != null) {
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile((CraftPlayer)player);
+ if (player == null) return new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name);
+
+ if (Objects.equals(uuid, player.getUniqueId()) && Objects.equals(name, player.getName())) {
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile((CraftPlayer) player);
+ }
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name);
+
+ final com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(uuid, name);
+ profile.getProperties().putAll(((CraftPlayer)player).getHandle().getGameProfile().getProperties());
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(profile);
+ }
// Paper end
}