Add Setters for ID/Name and add completeByCache for Profile API

This commit is contained in:
Aikar
2018-03-25 21:50:46 -04:00
parent 36f69d38bc
commit 31c3ae2bb4
2 changed files with 113 additions and 25 deletions

View File

@@ -7,7 +7,7 @@ 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..404fb468
index 00000000..e060c38a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java
@@ -0,0 +0,0 @@
@@ -32,11 +32,27 @@ index 00000000..404fb468
+ @Nullable String getName();
+
+ /**
+ * Sets this profiles Name
+ *
+ * @param name The new Name
+ * @return The previous Name
+ */
+ String setName(@Nullable String name);
+
+ /**
+ * @return The players unique identifier, if set
+ */
+ @Nullable UUID getId();
+
+ /**
+ * Sets this profiles UUID
+ *
+ * @param uuid The new UUID
+ * @return The previous UUID
+ */
+ UUID setId(@Nullable UUID uuid);
+
+ /**
+ * @return A Mutable set of this players properties, such as textures.
+ * Values specified here are subject to implementation details.
+ */
@@ -98,16 +114,24 @@ index 00000000..404fb468
+ void clearProperties();
+
+ /**
+ * @return Does this profile have Name, UUID and Textures filled in
+ * @return If the profile is now complete (has UUID and Name)
+ */
+ boolean isComplete();
+
+ /**
+ * Like {@link #complete(boolean)} but will try only from cache, and not make network calls
+ * Does not account for textures.
+ *
+ * @return If the profile is now complete (has UUID and Name)
+ */
+ boolean completeFromCache();
+
+ /**
+ * 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 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)
+ * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail)
+ */
+ default boolean complete() {
+ return complete(true);
@@ -118,7 +142,7 @@ index 00000000..404fb468
+ * 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)
+ * @return If the profile is now complete (has UUID and Name) (if you get rate limited, this operation may fail)
+ */
+ boolean complete(boolean textures);
+