2020-07-17 18:05:50 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-02-26 22:22:46 +01:00
|
|
|
From: tr7zw <tr7zw@live.de>
|
|
|
|
Date: Wed, 26 Feb 2020 22:22:02 +0100
|
|
|
|
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
|
2020-08-03 18:48:42 +02:00
|
|
|
index 8a18dfcda3c785e9c8bd134f88515e077dbef7dc..f0ccfce3bc7a2308a479fecd6d751bcaa88a0861 100644
|
2020-02-26 22:22:46 +01:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
2020-06-23 22:09:40 +02:00
|
|
|
@@ -5,9 +5,13 @@ import com.google.common.base.Charsets;
|
2020-02-26 22:22:46 +01:00
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
import com.mojang.authlib.properties.Property;
|
|
|
|
import com.mojang.authlib.properties.PropertyMap;
|
|
|
|
+
|
2020-08-03 18:48:42 +02:00
|
|
|
+import dev.tr7zw.yatopia.events.GameProfileLookupEvent;
|
2020-02-26 22:22:46 +01:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.server.UserCache;
|
2020-06-23 22:09:40 +02:00
|
|
|
import org.apache.commons.lang3.Validate;
|
2020-02-26 22:22:46 +01:00
|
|
|
+
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
import org.spigotmc.SpigotConfig;
|
|
|
|
|
2020-08-03 18:48:42 +02:00
|
|
|
@@ -185,13 +189,21 @@ public class CraftPlayerProfile implements PlayerProfile {
|
2020-06-24 17:21:23 +02:00
|
|
|
|
2020-06-27 15:45:01 +02:00
|
|
|
boolean isCompleteFromCache = this.completeFromCache(true, onlineMode);
|
2020-06-24 17:21:23 +02:00
|
|
|
if (onlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
|
2020-02-26 22:22:46 +01:00
|
|
|
- GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
|
|
|
|
- if (result != null) {
|
2020-06-21 00:40:04 +02:00
|
|
|
- copyProfileProperties(result, this.profile, true);
|
2020-02-26 22:22:46 +01:00
|
|
|
- }
|
2020-06-27 15:45:01 +02:00
|
|
|
- if (this.profile.isComplete()) {
|
|
|
|
- server.getUserCache().saveProfile(this.profile);
|
|
|
|
- }
|
2020-08-03 18:48:42 +02:00
|
|
|
+ // Yatopia 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);
|
|
|
|
+ }
|
2020-06-27 15:45:01 +02:00
|
|
|
+ if (this.profile.isComplete()) {
|
|
|
|
+ server.getUserCache().saveProfile(this.profile);
|
|
|
|
+ }
|
2020-08-03 18:48:42 +02:00
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
2020-02-26 22:22:46 +01:00
|
|
|
}
|
2020-06-24 17:21:23 +02:00
|
|
|
return profile.isComplete() && (!onlineMode || !textures || hasTextures());
|
2020-02-26 22:22:46 +01:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
2020-08-03 18:48:42 +02:00
|
|
|
index 579a81e521fdfabfa0318d06c6760a8ab7a88c1e..ceb1f18a49ebc8fbac270d9f221fa44f9baea216 100644
|
2020-02-26 22:22:46 +01:00
|
|
|
--- 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;
|
|
|
|
+
|
2020-08-03 18:48:42 +02:00
|
|
|
+import dev.tr7zw.yatopia.events.GameProfileLookupEvent;
|
2020-02-26 22:22:46 +01:00
|
|
|
+
|
|
|
|
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;
|
2020-06-27 15:45:01 +02:00
|
|
|
@@ -77,7 +82,15 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
|
2020-02-26 22:22:46 +01:00
|
|
|
|
|
|
|
if ( property == null )
|
|
|
|
{
|
|
|
|
- profile = TileEntitySkull.sessionService.fillProfileProperties( profile, true );
|
2020-08-03 18:48:42 +02:00
|
|
|
+ // Yatopia 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 );
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
2020-02-26 22:22:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|