add back missing call to profile fill events
This commit is contained in:
parent
80bd01527f
commit
68e23db25d
3 changed files with 87 additions and 3 deletions
|
@ -45,3 +45,87 @@ index 985e6fc43a0946943847e0c283426242ef594a26..d577384797bb381eb57437f57b726ea8
|
||||||
public @Nullable ProfileResult fetchProfile(final UUID profileId, final boolean requireSecure) {
|
public @Nullable ProfileResult fetchProfile(final UUID profileId, final boolean requireSecure) {
|
||||||
return super.fetchProfile(profileId, 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 d8ed3404e8c3c61b2daff110ef32ef890a77a461..78863e72239a0f3535bc85758479da84d58c11c1 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
|
@@ -49,7 +49,7 @@ public record ResolvableProfile(Optional<String> name, Optional<UUID> 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 ebba6bc5b337d19e32be5a78294501ed8300f2bd..81d9a4e6bc1bc4f992ecb77b176daf89d645bbf2 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
|
||||||
|
@@ -41,7 +41,7 @@ public class SkullBlockEntity extends BlockEntity {
|
||||||
|
@Nullable
|
||||||
|
private static LoadingCache<String, CompletableFuture<Optional<GameProfile>>> profileCacheByName;
|
||||||
|
@Nullable
|
||||||
|
- private static LoadingCache<UUID, CompletableFuture<Optional<GameProfile>>> profileCacheById;
|
||||||
|
+ private static LoadingCache<com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile>, CompletableFuture<Optional<GameProfile>>> profileCacheById; // Paper - player profile events
|
||||||
|
public static final Executor CHECKED_MAIN_THREAD_EXECUTOR = runnable -> {
|
||||||
|
Executor executor = mainThreadExecutor;
|
||||||
|
if (executor != null) {
|
||||||
|
@@ -76,9 +76,9 @@ public class SkullBlockEntity extends BlockEntity {
|
||||||
|
profileCacheById = CacheBuilder.newBuilder()
|
||||||
|
.expireAfterAccess(Duration.ofMinutes(10L))
|
||||||
|
.maximumSize(256L)
|
||||||
|
- .build(new CacheLoader<UUID, CompletableFuture<Optional<GameProfile>>>() {
|
||||||
|
+ .build(new CacheLoader<>() { // Paper - player profile events
|
||||||
|
@Override
|
||||||
|
- public CompletableFuture<Optional<GameProfile>> load(UUID uUID) {
|
||||||
|
+ public CompletableFuture<Optional<GameProfile>> load(com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile> uUID) { // Paper - player profile events
|
||||||
|
return SkullBlockEntity.fetchProfileById(uUID, apiServices, booleanSupplier);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@@ -89,20 +89,26 @@ public class SkullBlockEntity extends BlockEntity {
|
||||||
|
.getAsync(name)
|
||||||
|
.thenCompose(
|
||||||
|
optional -> {
|
||||||
|
- LoadingCache<UUID, CompletableFuture<Optional<GameProfile>>> loadingCache = profileCacheById;
|
||||||
|
+ LoadingCache<com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile>, CompletableFuture<Optional<GameProfile>>> 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<Optional<GameProfile>> fetchProfileById(UUID uuid, Services apiServices, BooleanSupplier booleanSupplier) {
|
||||||
|
+ static CompletableFuture<Optional<GameProfile>> fetchProfileById(com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile> 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
|
||||||
|
@@ -210,9 +216,11 @@ public class SkullBlockEntity extends BlockEntity {
|
||||||
|
: CompletableFuture.completedFuture(Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static CompletableFuture<Optional<GameProfile>> fetchGameProfile(UUID uuid) {
|
||||||
|
- LoadingCache<UUID, CompletableFuture<Optional<GameProfile>>> loadingCache = profileCacheById;
|
||||||
|
- return loadingCache != null ? loadingCache.getUnchecked(uuid) : CompletableFuture.completedFuture(Optional.empty());
|
||||||
|
+ // Paper start - player profile events
|
||||||
|
+ public static CompletableFuture<Optional<GameProfile>> fetchGameProfile(UUID uuid, @Nullable String name) {
|
||||||
|
+ LoadingCache<com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile>, CompletableFuture<Optional<GameProfile>>> 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
|
||||||
|
|
|
@ -102,10 +102,10 @@ index 767994f493fb0a0e4bf097cd7cc178c10e79e937..c3503eaec5c5ece6e27a52fb703d06ec
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
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 ebba6bc5b337d19e32be5a78294501ed8300f2bd..adc87c2da5a4a4a89eb9708850376eaed49cf20a 100644
|
index 81d9a4e6bc1bc4f992ecb77b176daf89d645bbf2..40714cb145822b52cbc991a844486f87e46106d8 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
@@ -145,7 +145,7 @@ public class SkullBlockEntity extends BlockEntity {
|
@@ -151,7 +151,7 @@ public class SkullBlockEntity extends BlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbt.contains("custom_name", 8)) {
|
if (nbt.contains("custom_name", 8)) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ index df246d69591e1a5822a0109c99b0f67996da71fa..4e005b7b062e3231f564d284887ea1c2
|
||||||
return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
|
return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
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 d8ed3404e8c3c61b2daff110ef32ef890a77a461..f5f1156744b45da3873f68c080ba2a55cbaec506 100644
|
index 78863e72239a0f3535bc85758479da84d58c11c1..38bbe39a5cd96710b208d70ed78619057bb6e6fa 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
+++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
@@ -20,9 +20,10 @@ public record ResolvableProfile(Optional<String> name, Optional<UUID> id, Proper
|
@@ -20,9 +20,10 @@ public record ResolvableProfile(Optional<String> name, Optional<UUID> id, Proper
|
||||||
|
|
Loading…
Reference in a new issue