Fix Profile Textures and expand PlayerProfile .complete() API

I mistakenly thought .complete() also checked for textures, which was not the case

So the logic was not working as desired.

Also some undesired logic paths lead to textures of the logging in player being dropped, forcing
us to always load the textures immediately again on login, leading to rate limits.

Everythings now good

the .complete() api now will default specify to also complete textures, but you may
pass false to it to skip loading textures.
This commit is contained in:
Aikar 2018-03-22 21:40:57 -04:00
parent b29f5c05c1
commit b8a672dd94
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
3 changed files with 175 additions and 104 deletions

View file

@ -1,4 +1,4 @@
From 0952cf855ca2b8bf45741e73250656ad452532c8 Mon Sep 17 00:00:00 2001
From 15f696b679672e955cf4f3186130eb9afa2e0df6 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 15 Jan 2018 21:46:46 -0500
Subject: [PATCH] Basic PlayerProfile API
@ -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
new file mode 100644
index 00000000..0f44f98f
index 00000000..404fb468
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
@@ -0,0 +1,97 @@
@@ -0,0 +1,125 @@
+package com.destroystokyo.paper.profile;
+
+import com.mojang.authlib.GameProfile;
@ -43,6 +43,13 @@ index 00000000..0f44f98f
+ @Nonnull Set<ProfileProperty> getProperties();
+
+ /**
+ * Check if the Profile has the specified property
+ * @param property Property name to check
+ * @return If the property is set
+ */
+ boolean hasProperty(String property);
+
+ /**
+ * Sets a property. If the property already exists, the previous one will be replaced
+ * @param property Property to set.
+ */
@ -98,9 +105,30 @@ index 00000000..0f44f98f
+ /**
+ * If this profile is not complete, then make the API call to complete it.
+ * This is a blocking operation and should be done asynchronously.
+ * @return if the profile is now complete
+ *
+ * This will also complete textures. If you do not want to load textures, use {{@link #complete(boolean)}}
+ * @return if the profile is now complete (if you get rate limited, this operation may fail)
+ */
+ boolean complete();
+ default boolean complete() {
+ return complete(true);
+ }
+
+ /**
+ * 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.
+ * @return if the profile is now complete (if you get rate limited, this operation may fail)
+ */
+ boolean complete(boolean textures);
+
+ /**
+ * Whether or not this Profile has textures associated to it
+ * @return If has a textures property
+ */
+ default boolean hasTextures() {
+ return hasProperty("textures");
+ }
+
+ /**
+ * @deprecated Will be removed in 1.13