diff --git a/patches/server/Fill-Profile-Property-Events.patch b/patches/server/Fill-Profile-Property-Events.patch index 40f98b4d2f..17b4318791 100644 --- a/patches/server/Fill-Profile-Property-Events.patch +++ b/patches/server/Fill-Profile-Property-Events.patch @@ -45,3 +45,87 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public @Nullable ProfileResult fetchProfile(final UUID profileId, final boolean requireSecure) { return super.fetchProfile(profileId, requireSecure); } +diff --git a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java ++++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java +@@ -0,0 +0,0 @@ public record ResolvableProfile(Optional name, Optional id, Proper + if (this.isResolved()) { + return CompletableFuture.completedFuture(this); + } else { +- return this.id.isPresent() ? SkullBlockEntity.fetchGameProfile(this.id.get()).thenApply(optional -> { ++ return this.id.isPresent() ? SkullBlockEntity.fetchGameProfile(this.id.get(), this.name.orElse(null)).thenApply(optional -> { // Paper - player profile events + GameProfile gameProfile = optional.orElseGet(() -> new GameProfile(this.id.get(), this.name.orElse(""))); + return new ResolvableProfile(gameProfile); + }) : SkullBlockEntity.fetchGameProfile(this.name.orElseThrow()).thenApply(profile -> { +diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java +@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { + @Nullable + private static LoadingCache>> profileCacheByName; + @Nullable +- private static LoadingCache>> profileCacheById; ++ private static LoadingCache, CompletableFuture>> profileCacheById; // Paper - player profile events + public static final Executor CHECKED_MAIN_THREAD_EXECUTOR = runnable -> { + Executor executor = mainThreadExecutor; + if (executor != null) { +@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { + profileCacheById = CacheBuilder.newBuilder() + .expireAfterAccess(Duration.ofMinutes(10L)) + .maximumSize(256L) +- .build(new CacheLoader>>() { ++ .build(new CacheLoader<>() { // Paper - player profile events + @Override +- public CompletableFuture> load(UUID uUID) { ++ public CompletableFuture> load(com.mojang.datafixers.util.Pair uUID) { // Paper - player profile events + return SkullBlockEntity.fetchProfileById(uUID, apiServices, booleanSupplier); + } + }); +@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { + .getAsync(name) + .thenCompose( + optional -> { +- LoadingCache>> loadingCache = profileCacheById; ++ LoadingCache, CompletableFuture>> loadingCache = profileCacheById; // Paper - player profile events + return loadingCache != null && !optional.isEmpty() +- ? loadingCache.getUnchecked(optional.get().getId()).thenApply(optional2 -> optional2.or(() -> optional)) ++ ? loadingCache.getUnchecked(new com.mojang.datafixers.util.Pair<>(optional.get().getId(), optional.get())).thenApply(optional2 -> optional2.or(() -> optional)) // Paper - player profile events + : CompletableFuture.completedFuture(Optional.empty()); + } + ); + } + +- static CompletableFuture> fetchProfileById(UUID uuid, Services apiServices, BooleanSupplier booleanSupplier) { ++ static CompletableFuture> fetchProfileById(com.mojang.datafixers.util.Pair pair, Services apiServices, BooleanSupplier booleanSupplier) { // Paper + return CompletableFuture.supplyAsync(() -> { + if (booleanSupplier.getAsBoolean()) { + return Optional.empty(); + } else { +- ProfileResult profileResult = apiServices.sessionService().fetchProfile(uuid, true); ++ // Paper start - fill player profile events ++ if (apiServices.sessionService() instanceof com.destroystokyo.paper.profile.PaperMinecraftSessionService paperService) { ++ final GameProfile profile = pair.getSecond() != null ? pair.getSecond() : new com.mojang.authlib.GameProfile(pair.getFirst(), ""); ++ return Optional.ofNullable(paperService.fetchProfile(profile, true)).map(ProfileResult::profile); ++ } ++ ProfileResult profileResult = apiServices.sessionService().fetchProfile(pair.getFirst(), true); ++ // Paper end - fill player profile events + return Optional.ofNullable(profileResult).map(ProfileResult::profile); + } + }, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread +@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { + : CompletableFuture.completedFuture(Optional.empty()); + } + +- public static CompletableFuture> fetchGameProfile(UUID uuid) { +- LoadingCache>> loadingCache = profileCacheById; +- return loadingCache != null ? loadingCache.getUnchecked(uuid) : CompletableFuture.completedFuture(Optional.empty()); ++ // Paper start - player profile events ++ public static CompletableFuture> fetchGameProfile(UUID uuid, @Nullable String name) { ++ LoadingCache, CompletableFuture>> loadingCache = profileCacheById; ++ return loadingCache != null ? loadingCache.getUnchecked(new com.mojang.datafixers.util.Pair<>(uuid, name != null ? new com.mojang.authlib.GameProfile(uuid, name) : null)) : CompletableFuture.completedFuture(Optional.empty()); ++ // Paper end - player profile events + } + + @Override