Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
61 Zeilen
3.6 KiB
Diff
61 Zeilen
3.6 KiB
Diff
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
|
|
index 985e6fc43a0946943847e0c283426242ef594a26..d577384797bb381eb57437f57b726ea8e4feb80b 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
|
@@ -1,6 +1,7 @@
|
|
package com.destroystokyo.paper.profile;
|
|
|
|
import com.mojang.authlib.Environment;
|
|
+import com.mojang.authlib.GameProfile;
|
|
import com.mojang.authlib.yggdrasil.ProfileResult;
|
|
import com.mojang.authlib.yggdrasil.ServicesKeySet;
|
|
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
|
|
@@ -15,7 +16,21 @@ public class PaperMinecraftSessionService extends YggdrasilMinecraftSessionServi
|
|
super(servicesKeySet, proxy, environment);
|
|
}
|
|
|
|
- @Override
|
|
+ public @Nullable ProfileResult fetchProfile(GameProfile profile, final boolean requireSecure) {
|
|
+ CraftPlayerProfile playerProfile = (CraftPlayerProfile) CraftPlayerProfile.asBukkitMirror(profile);
|
|
+ new com.destroystokyo.paper.event.profile.PreFillProfileEvent(playerProfile).callEvent();
|
|
+ profile = playerProfile.getGameProfile();
|
|
+ if (profile.getProperties().containsKey("textures")) {
|
|
+ return new ProfileResult(profile, java.util.Collections.emptySet());
|
|
+ }
|
|
+ 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);
|
|
}
|
|
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 d0b3a836de9830a4da534bedd9f94a16a82ef9c6..6f52256bfb668aee7fd1628c1c0c7b3434b847a6 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
|
|
@@ -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 - FillProfileEvent
|
|
|
|
return profileresult != null ? Optional.ofNullable(profileresult.profile()) : optional;
|
|
} else {
|