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:
Aikar
2018-01-02 00:31:26 -05:00
parent cad0c129c8
commit 4f248b1b5b
3 changed files with 91 additions and 3 deletions

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/component/ResolvableProfile.java
+++ b/net/minecraft/world/item/component/ResolvableProfile.java
@@ -49,7 +49,7 @@
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 -> {