Fix profile requests being made on offline mode servers

Closes #1076
This commit is contained in:
Aikar 2018-04-08 12:28:04 -04:00
parent 72bd990d87
commit 0c446a7dd3

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Basic PlayerProfile API
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
index 00000000..8cc85be8
index 000000000..9ad5853de
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
@@ -0,0 +0,0 @@
@ -150,6 +150,9 @@ index 00000000..8cc85be8
+ }
+
+ public boolean completeFromCache(boolean lookupName) {
+ if (profile.isComplete()) {
+ return true;
+ }
+ MinecraftServer server = MinecraftServer.getServer();
+ String name = profile.getName();
+ UserCache userCache = server.getUserCache();
@ -181,13 +184,15 @@ index 00000000..8cc85be8
+ public boolean complete(boolean textures) {
+ MinecraftServer server = MinecraftServer.getServer();
+
+ if (!this.completeFromCache(true) || textures && !hasTextures()) {
+ boolean isOnlineMode = server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode);
+ boolean isCompleteFromCache = this.completeFromCache(true);
+ if (isOnlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
+ GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
+ if (result != null) {
+ this.profile = result;
+ }
+ }
+ return profile.isComplete() && (!textures || hasTextures());
+ return profile.isComplete() && (!isOnlineMode || !textures || hasTextures());
+ }
+
+ private static void copyProfileProperties(GameProfile source, GameProfile target) {
@ -287,7 +292,7 @@ index 00000000..8cc85be8
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 02940d69..4539b560 100644
index 02940d697..4539b5601 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -0,0 +0,0 @@
@ -312,7 +317,7 @@ index 02940d69..4539b560 100644
* Calculates distance between 2 entities
* @param e1
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e8bddc17..3b01ebd9 100644
index e8bddc171..3b01ebd96 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@ -324,7 +329,7 @@ index e8bddc17..3b01ebd9 100644
return this.W;
}
diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
index 7ce08eb8..6a750c25 100644
index 7ce08eb8b..6a750c25e 100644
--- a/src/main/java/net/minecraft/server/UserCache.java
+++ b/src/main/java/net/minecraft/server/UserCache.java
@@ -0,0 +0,0 @@ public class UserCache {
@ -360,7 +365,7 @@ index 7ce08eb8..6a750c25 100644
private UserCacheEntry(GameProfile gameprofile, Date date) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 77c16fe2..2dd7ed96 100644
index 77c16fe2c..2dd7ed96a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;