Fix Player skulls for offline mode servers
Always use online mode for them in Profile API calls Adds new API to profile API to let you control online mode yourself Fixes #3594
Dieser Commit ist enthalten in:
Ursprung
ce270e1412
Commit
24b2f54b7b
@ -7,10 +7,10 @@ Provides basic elements of a PlayerProfile to be used by future API/events
|
|||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
|
diff --git a/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..476151d2a8757b77e677647fe95a0f7f1c873459
|
index 0000000000000000000000000000000000000000..2ef9a7bd55e2c9cf8cb20d5f77282676ae11181f
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
|
+++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
|
||||||
@@ -0,0 +1,145 @@
|
@@ -0,0 +1,177 @@
|
||||||
+package com.destroystokyo.paper.profile;
|
+package com.destroystokyo.paper.profile;
|
||||||
+
|
+
|
||||||
+import java.util.Collection;
|
+import java.util.Collection;
|
||||||
@ -128,6 +128,25 @@ index 0000000000000000000000000000000000000000..476151d2a8757b77e677647fe95a0f7f
|
|||||||
+ boolean completeFromCache();
|
+ boolean completeFromCache();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
+ * Like {@link #complete(boolean)} but will try only from cache, and not make network calls
|
||||||
|
+ * Does not account for textures.
|
||||||
|
+ *
|
||||||
|
+ * @param onlineMode Treat this as online mode or not
|
||||||
|
+ * @return If the profile is now complete (has UUID and Name)
|
||||||
|
+ */
|
||||||
|
+ boolean completeFromCache(boolean onlineMode);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Like {@link #complete(boolean)} but will try only from cache, and not make network calls
|
||||||
|
+ * Does not account for textures.
|
||||||
|
+ *
|
||||||
|
+ * @param lookupUUID If only name is supplied, should we do a UUID lookup
|
||||||
|
+ * @param onlineMode Treat this as online mode or not
|
||||||
|
+ * @return If the profile is now complete (has UUID and Name)
|
||||||
|
+ */
|
||||||
|
+ boolean completeFromCache(boolean lookupUUID, boolean onlineMode);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
+ * If this profile is not complete, then make the API call to complete it.
|
+ * If this profile is not complete, then make the API call to complete it.
|
||||||
+ * This is a blocking operation and should be done asynchronously.
|
+ * This is a blocking operation and should be done asynchronously.
|
||||||
+ *
|
+ *
|
||||||
@ -143,12 +162,25 @@ index 0000000000000000000000000000000000000000..476151d2a8757b77e677647fe95a0f7f
|
|||||||
+ * This is a blocking operation and should be done asynchronously.
|
+ * This is a blocking operation and should be done asynchronously.
|
||||||
+ *
|
+ *
|
||||||
+ * Optionally will also fill textures.
|
+ * Optionally will also fill textures.
|
||||||
|
+ *
|
||||||
|
+ * Online mode will be automatically determined
|
||||||
+ * @param textures controls if we should fill the profile with texture properties
|
+ * @param textures controls if we should fill the profile with texture properties
|
||||||
+ * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail)
|
+ * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail)
|
||||||
+ */
|
+ */
|
||||||
+ boolean complete(boolean textures);
|
+ boolean complete(boolean textures);
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
+ * If this profile is not complete, then make the API call to complete it.
|
||||||
|
+ * This is a blocking operation and should be done asynchronously.
|
||||||
|
+ *
|
||||||
|
+ * Optionally will also fill textures.
|
||||||
|
+ * @param textures controls if we should fill the profile with texture properties
|
||||||
|
+ * @param onlineMode Treat this server as online mode or not
|
||||||
|
+ * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail)
|
||||||
|
+ */
|
||||||
|
+ boolean complete(boolean textures, boolean onlineMode);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
+ * Whether or not this Profile has textures associated to it
|
+ * Whether or not this Profile has textures associated to it
|
||||||
+ * @return If has a textures property
|
+ * @return If has a textures property
|
||||||
+ */
|
+ */
|
||||||
|
@ -7,10 +7,10 @@ Establishes base extension of profile systems for future edits too
|
|||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..676cc44f544715ef375012fa04bdd2d79f79a3aa
|
index 0000000000000000000000000000000000000000..00b7630ccb2be7a78ab5471c8e8bdcd5a92209a0
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
||||||
@@ -0,0 +1,287 @@
|
@@ -0,0 +1,294 @@
|
||||||
+package com.destroystokyo.paper.profile;
|
+package com.destroystokyo.paper.profile;
|
||||||
+
|
+
|
||||||
+import com.destroystokyo.paper.PaperConfig;
|
+import com.destroystokyo.paper.PaperConfig;
|
||||||
@ -149,18 +149,22 @@ index 0000000000000000000000000000000000000000..676cc44f544715ef375012fa04bdd2d7
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public boolean completeFromCache() {
|
+ public boolean completeFromCache() {
|
||||||
+ return completeFromCache(false);
|
+ MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
+ return completeFromCache(false, server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean completeFromCache(boolean lookupName) {
|
+ public boolean completeFromCache(boolean onlineMode) {
|
||||||
|
+ return completeFromCache(false, onlineMode);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean completeFromCache(boolean lookupUUID, boolean onlineMode) {
|
||||||
+ MinecraftServer server = MinecraftServer.getServer();
|
+ MinecraftServer server = MinecraftServer.getServer();
|
||||||
+ String name = profile.getName();
|
+ String name = profile.getName();
|
||||||
+ UserCache userCache = server.getUserCache();
|
+ UserCache userCache = server.getUserCache();
|
||||||
+ if (profile.getId() == null) {
|
+ if (profile.getId() == null) {
|
||||||
+ final GameProfile profile;
|
+ final GameProfile profile;
|
||||||
+ boolean isOnlineMode = server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode);
|
+ if (onlineMode) {
|
||||||
+ if (isOnlineMode) {
|
+ profile = lookupUUID ? userCache.getProfile(name) : userCache.getProfileIfCached(name);
|
||||||
+ profile = lookupName ? userCache.getProfile(name) : userCache.getProfileIfCached(name);
|
|
||||||
+ } else {
|
+ } else {
|
||||||
+ // Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
+ // Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
||||||
+ profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name);
|
+ profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name);
|
||||||
@ -185,17 +189,20 @@ index 0000000000000000000000000000000000000000..676cc44f544715ef375012fa04bdd2d7
|
|||||||
+
|
+
|
||||||
+ public boolean complete(boolean textures) {
|
+ public boolean complete(boolean textures) {
|
||||||
+ MinecraftServer server = MinecraftServer.getServer();
|
+ MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
+ return complete(textures, server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode));
|
||||||
|
+ }
|
||||||
|
+ public boolean complete(boolean textures, boolean onlineMode) {
|
||||||
|
+ MinecraftServer server = MinecraftServer.getServer();
|
||||||
+
|
+
|
||||||
+ boolean isOnlineMode = server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode);
|
+ boolean isCompleteFromCache = this.completeFromCache(false, onlineMode);
|
||||||
+ boolean isCompleteFromCache = this.completeFromCache(true);
|
+ if (onlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
|
||||||
+ if (isOnlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
|
|
||||||
+ GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
|
+ GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
|
||||||
+ if (result != null) {
|
+ if (result != null) {
|
||||||
+ copyProfileProperties(result, this.profile, true);
|
+ copyProfileProperties(result, this.profile, true);
|
||||||
+ }
|
+ }
|
||||||
+ server.getUserCache().saveProfile(this.profile);
|
+ server.getUserCache().saveProfile(this.profile);
|
||||||
+ }
|
+ }
|
||||||
+ return profile.isComplete() && (!isOnlineMode || !textures || hasTextures());
|
+ return profile.isComplete() && (!onlineMode || !textures || hasTextures());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static void copyProfileProperties(GameProfile source, GameProfile target) {
|
+ private static void copyProfileProperties(GameProfile source, GameProfile target) {
|
||||||
@ -458,7 +465,7 @@ index ed32242bd169e9f28607942aa31aa48a5799b215..54f80cb8e1b771f2a493543e04f8bc83
|
|||||||
return this.minecraftSessionService;
|
return this.minecraftSessionService;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
||||||
index 177cceb77f8783fe93ba7e4342de9c589f155c1b..27613d2e7d2a0de43b1cd8a45cfcfd5553642561 100644
|
index 177cceb77f8783fe93ba7e4342de9c589f155c1b..83faa9dc5f74df4609cab34a66e4feed12990463 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
|
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java
|
||||||
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
+++ b/src/main/java/net/minecraft/server/TileEntitySkull.java
|
||||||
@@ -158,6 +158,7 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
|
@@ -158,6 +158,7 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa
|
||||||
@ -478,9 +485,9 @@ index 177cceb77f8783fe93ba7e4342de9c589f155c1b..27613d2e7d2a0de43b1cd8a45cfcfd55
|
|||||||
+ com.destroystokyo.paper.profile.CraftPlayerProfile paperProfile = new com.destroystokyo.paper.profile.CraftPlayerProfile(gameprofile);
|
+ com.destroystokyo.paper.profile.CraftPlayerProfile paperProfile = new com.destroystokyo.paper.profile.CraftPlayerProfile(gameprofile);
|
||||||
+ if (sync) {
|
+ if (sync) {
|
||||||
+ // might complete by cache, but if not, go ahead and do it now, avoid the code below
|
+ // might complete by cache, but if not, go ahead and do it now, avoid the code below
|
||||||
+ paperProfile.complete(true);
|
+ paperProfile.complete(true, true);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ paperProfile.completeFromCache();
|
+ paperProfile.completeFromCache(false, true);
|
||||||
+ }
|
+ }
|
||||||
+ GameProfile profile = paperProfile.getGameProfile();
|
+ GameProfile profile = paperProfile.getGameProfile();
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
@ -493,7 +500,7 @@ index 177cceb77f8783fe93ba7e4342de9c589f155c1b..27613d2e7d2a0de43b1cd8a45cfcfd55
|
|||||||
public GameProfile call() {
|
public GameProfile call() {
|
||||||
- final GameProfile profile = skinCache.getUnchecked(gameprofile.getName().toLowerCase(java.util.Locale.ROOT));
|
- final GameProfile profile = skinCache.getUnchecked(gameprofile.getName().toLowerCase(java.util.Locale.ROOT));
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ paperProfile.complete(true);
|
+ paperProfile.complete(true, true);
|
||||||
+ final GameProfile profile = paperProfile.getGameProfile();
|
+ final GameProfile profile = paperProfile.getGameProfile();
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
MinecraftServer.getServer().processQueue.add(new Runnable() {
|
MinecraftServer.getServer().processQueue.add(new Runnable() {
|
||||||
@ -583,7 +590,7 @@ index f01bd38d0b600a69224f610fd77a542ec6d1c322..95f4abddf57eb8c59cb5a5410b8d551d
|
|||||||
// Paper end
|
// Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||||
index 4fb27cc7ed062696239f75b6f85ddb0a31866568..35eda0a03cfec244103cfe4b998f9d2b9322fe69 100644
|
index 4fb27cc7ed062696239f75b6f85ddb0a31866568..c31011ff91f4ea8368e3afbc5ec07eff84e93fe2 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||||
@@ -71,6 +71,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
@@ -71,6 +71,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
@ -593,7 +600,7 @@ index 4fb27cc7ed062696239f75b6f85ddb0a31866568..35eda0a03cfec244103cfe4b998f9d2b
|
|||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ if (profile != null) {
|
+ if (profile != null) {
|
||||||
+ com.destroystokyo.paper.profile.CraftPlayerProfile paperProfile = new com.destroystokyo.paper.profile.CraftPlayerProfile(profile);
|
+ com.destroystokyo.paper.profile.CraftPlayerProfile paperProfile = new com.destroystokyo.paper.profile.CraftPlayerProfile(profile);
|
||||||
+ paperProfile.completeFromCache();
|
+ paperProfile.completeFromCache(false, true);
|
||||||
+ profile = paperProfile.getGameProfile();
|
+ profile = paperProfile.getGameProfile();
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren