mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-23 11:06:51 +01:00
97 lines
4.2 KiB
Diff
97 lines
4.2 KiB
Diff
From 4f0a395b13722946811e1453770f69bf6d70641e Mon Sep 17 00:00:00 2001
|
|
From: tr7zw <tr7zw@live.de>
|
|
Date: Wed, 26 Feb 2020 22:22:02 +0100
|
|
Subject: [PATCH] Add GameProfileLookupEvent
|
|
|
|
---
|
|
.../paper/profile/CraftPlayerProfile.java | 26 ++++++++++++++-----
|
|
.../net/minecraft/server/TileEntitySkull.java | 15 ++++++++++-
|
|
2 files changed, 33 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
|
index d73de9eb8..8b9c017bd 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
|
@@ -5,9 +5,13 @@ import com.google.common.base.Charsets;
|
|
import com.mojang.authlib.GameProfile;
|
|
import com.mojang.authlib.properties.Property;
|
|
import com.mojang.authlib.properties.PropertyMap;
|
|
+
|
|
+import de.tr7zw.yapfa.events.GameProfileLookupEvent;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.UserCache;
|
|
import org.apache.commons.lang3.Validate;
|
|
+
|
|
+import org.bukkit.Bukkit;
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
import org.spigotmc.SpigotConfig;
|
|
|
|
@@ -183,13 +187,21 @@ public class CraftPlayerProfile implements PlayerProfile {
|
|
|
|
boolean isCompleteFromCache = this.completeFromCache(true, onlineMode);
|
|
if (onlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
|
|
- GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
|
|
- if (result != null) {
|
|
- copyProfileProperties(result, this.profile, true);
|
|
- }
|
|
- if (this.profile.isComplete()) {
|
|
- server.getUserCache().saveProfile(this.profile);
|
|
- }
|
|
+ // YAPFA start
|
|
+ GameProfileLookupEvent event = new GameProfileLookupEvent(!Bukkit.isPrimaryThread(), profile.getId(), profile.getName());
|
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
|
+ if (event.getGameProfile() != null) {
|
|
+ this.profile = event.getGameProfile();
|
|
+ } else {
|
|
+ GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
|
|
+ if (result != null) {
|
|
+ copyProfileProperties(result, this.profile, true);
|
|
+ }
|
|
+ if (this.profile.isComplete()) {
|
|
+ server.getUserCache().saveProfile(this.profile);
|
|
+ }
|
|
+ }
|
|
+ // YAPFA end
|
|
}
|
|
return profile.isComplete() && (!onlineMode || !textures || hasTextures());
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
|
index fb7aa15c2..7d7ab2fc0 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
|
@@ -4,9 +4,14 @@ import com.google.common.collect.Iterables;
|
|
import com.mojang.authlib.GameProfile;
|
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
import com.mojang.authlib.properties.Property;
|
|
+
|
|
+import de.tr7zw.yapfa.events.GameProfileLookupEvent;
|
|
+
|
|
import java.util.UUID;
|
|
import javax.annotation.Nullable;
|
|
|
|
+import org.bukkit.Bukkit;
|
|
+
|
|
// Spigot start
|
|
import com.google.common.base.Predicate;
|
|
import com.google.common.cache.LoadingCache;
|
|
@@ -77,7 +82,15 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
|
|
|
|
if ( property == null )
|
|
{
|
|
- profile = TileEntitySkull.sessionService.fillProfileProperties( profile, true );
|
|
+ // YAPFA start
|
|
+ GameProfileLookupEvent event = new GameProfileLookupEvent(!Bukkit.isPrimaryThread(), profile.getId(), profile.getName());
|
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
|
+ if (event.getGameProfile() != null) {
|
|
+ profile = event.getGameProfile();
|
|
+ } else {
|
|
+ profile = TileEntitySkull.sessionService.fillProfileProperties( profile, true );
|
|
+ }
|
|
+ // YAPFA end
|
|
}
|
|
}
|
|
|
|
--
|
|
2.25.1.windows.1
|
|
|