2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Tue, 2 Jan 2018 00:31:26 -0500
|
|
|
|
Subject: [PATCH] Fill Profile Property Events
|
|
|
|
|
|
|
|
Allows plugins to populate profile properties from local sources to avoid calls out to Mojang API
|
|
|
|
to fill in textures for example.
|
|
|
|
|
|
|
|
If Mojang API does need to be hit, event fire so you can get the results.
|
|
|
|
|
|
|
|
This is useful for implementing a ProfileCache for Player Skulls
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
2023-09-22 04:31:59 +02:00
|
|
|
index ea906c9942be4c37b0daf866c759771af0b1e0ed..48fcfe223f807ccb903804adfead4b97beb2475d 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
2023-09-22 04:31:59 +02:00
|
|
|
@@ -24,7 +24,21 @@ public class PaperMinecraftSessionService extends YggdrasilMinecraftSessionServi
|
|
|
|
return super.getTextures(profile, requireSecure);
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2023-09-22 04:31:59 +02:00
|
|
|
- @Override
|
|
|
|
+ public @Nullable ProfileResult fetchProfile(GameProfile profile, final boolean requireSecure) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ CraftPlayerProfile playerProfile = (CraftPlayerProfile) CraftPlayerProfile.asBukkitMirror(profile);
|
2023-09-22 04:31:59 +02:00
|
|
|
+ new com.destroystokyo.paper.event.profile.PreFillProfileEvent(playerProfile).callEvent();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ profile = playerProfile.getGameProfile();
|
2023-09-22 04:31:59 +02:00
|
|
|
+ if (profile.getProperties().containsKey("textures")) {
|
|
|
|
+ return new ProfileResult(profile, java.util.Collections.emptySet());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2023-09-22 04:31:59 +02:00
|
|
|
+ ProfileResult result = super.fetchProfile(profile.getId(), requireSecure);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ new com.destroystokyo.paper.event.profile.FillProfileEvent(CraftPlayerProfile.asBukkitMirror(result.profile())).callEvent();
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override @io.papermc.paper.annotation.DoNotUse @Deprecated
|
|
|
|
public @Nullable ProfileResult fetchProfile(final UUID profileId, final boolean requireSecure) {
|
|
|
|
return super.fetchProfile(profileId, requireSecure);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2023-09-22 04:31:59 +02:00
|
|
|
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
|
2023-12-05 23:12:48 +01:00
|
|
|
index 92b770d10f34596ce52392a0db1ccd825108730b..4430520d32024d897c93c1d9f8652ccb2c202c01 100644
|
2023-09-22 04:31:59 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
2023-12-05 23:12:48 +01:00
|
|
|
@@ -74,7 +74,7 @@ public class SkullBlockEntity extends BlockEntity {
|
|
|
|
return apiServices.profileCache().getAsync(name).thenApplyAsync((optional) -> {
|
|
|
|
if (optional.isPresent() && !booleansupplier.getAsBoolean()) {
|
|
|
|
UUID uuid = ((GameProfile) optional.get()).getId();
|
|
|
|
- ProfileResult profileresult = apiServices.sessionService().fetchProfile(uuid, true);
|
|
|
|
+ ProfileResult profileresult = apiServices.sessionService() instanceof com.destroystokyo.paper.profile.PaperMinecraftSessionService paperMinecraftSessionService ? paperMinecraftSessionService.fetchProfile(optional.get(), true) : apiServices.sessionService().fetchProfile(uuid, true); // Paper
|
2023-09-22 04:31:59 +02:00
|
|
|
|
2023-12-05 23:12:48 +01:00
|
|
|
return profileresult != null ? Optional.ofNullable(profileresult.profile()) : optional;
|
2023-09-22 04:31:59 +02:00
|
|
|
} else {
|