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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user