Prevent profile lookups when unnecessary (#10651)

This commit is contained in:
Bridge 2024-05-05 19:07:30 +02:00
parent 548fa24c1e
commit 254ed14dc9

View file

@ -248,9 +248,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return complete(textures, GlobalConfiguration.get().proxies.isProxyOnlineMode()); + return complete(textures, GlobalConfiguration.get().proxies.isProxyOnlineMode());
+ } + }
+ public boolean complete(boolean textures, boolean onlineMode) { + public boolean complete(boolean textures, boolean onlineMode) {
+ if (this.isComplete() && (!textures || hasTextures())) { // Don't do lookup if we already have everything
+ return true;
+ }
+
+ MinecraftServer server = MinecraftServer.getServer(); + MinecraftServer server = MinecraftServer.getServer();
+ boolean isCompleteFromCache = this.completeFromCache(true, onlineMode); + boolean isCompleteFromCache = this.completeFromCache(true, onlineMode);
+ if (onlineMode && (!isCompleteFromCache || textures && !hasTextures())) { + if (onlineMode && (!isCompleteFromCache || (textures && !hasTextures()))) {
+ ProfileResult result = server.getSessionService().fetchProfile(this.getId(), true); + ProfileResult result = server.getSessionService().fetchProfile(this.getId(), true);
+ if (result != null && result.profile() != null) { + if (result != null && result.profile() != null) {
+ copyProfileProperties(result.profile(), this.profile, true); + copyProfileProperties(result.profile(), this.profile, true);