Yatopia/patches/server/0004-Add-GameProfileLookupE...

65 lines
3.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Wed, 5 Aug 2020 14:25:50 -0500
Subject: [PATCH] Add GameProfileLookupEvent
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
index 3d9452892a4077e64f37424052a9e52d76dd7a6d..7e88d332b3f31e49935ce7d9f99d447c9427769e 100644
--- a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
@@ -187,13 +187,24 @@ public class CraftPlayerProfile implements PlayerProfile {
boolean isCompleteFromCache = this.completeFromCache(true, onlineMode);
if (onlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
- GameProfile result = server.getMinecraftSessionService().fillProfileProperties(profile, true);
- if (result != null) {
- copyProfileProperties(result, this.profile, true);
- }
- if (this.profile.isComplete()) {
- server.getUserCache().saveProfile(this.profile);
+ // Yatopia start
+ dev.tr7zw.yatopia.events.GameProfileLookupEvent event = new
+ dev.tr7zw.yatopia.events.GameProfileLookupEvent(
+ !org.bukkit.Bukkit.isPrimaryThread(), profile.getId(), profile.getName());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ GameProfile eventProfile = event.getGameProfile();
+ if (eventProfile != null) {
+ this.profile = eventProfile;
+ } else {
+ GameProfile result = server.getMinecraftSessionService().fillProfileProperties(profile, true);
+ if (result != null) {
+ copyProfileProperties(result, this.profile, true);
+ }
+ if (this.profile.isComplete()) {
+ server.getUserCache().saveProfile(this.profile);
+ }
}
+ // Yatopia end
}
return profile.isComplete() && (!onlineMode || !textures || hasTextures());
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java
index 4f7c014fa609a39cac651ccc6d3397d7edb77d8d..fe9238ecc0f3a4948f5867fcae4fe64c9142a98e 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntitySkull.java
@@ -87,7 +87,18 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
if ( property == null )
{
+ // Yatopia start
+ dev.tr7zw.yatopia.events.GameProfileLookupEvent event =
+ new dev.tr7zw.yatopia.events.GameProfileLookupEvent(
+ !org.bukkit.Bukkit.isPrimaryThread(), profile.getId(), profile.getName());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ GameProfile eventProfile = event.getGameProfile();
+ if (eventProfile != null) {
+ profile = eventProfile;
+ } else {
profile = TileEntitySkull.sessionService.fillProfileProperties( profile, true );
+ }
+ // Yatopia end
}
}