diff --git a/patches/api/0058-Basic-PlayerProfile-API.patch b/patches/api/0058-Basic-PlayerProfile-API.patch index 806e90fd49..577a6d381e 100644 --- a/patches/api/0058-Basic-PlayerProfile-API.patch +++ b/patches/api/0058-Basic-PlayerProfile-API.patch @@ -7,16 +7,17 @@ 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 0000000000000000000000000000000000000000..d4766e2116c2202d84080637a2832bef0ab3f718 +index 0000000000000000000000000000000000000000..b76f13a0266806544bde13952476d4867caaf25b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java -@@ -0,0 +1,199 @@ +@@ -0,0 +1,231 @@ +package com.destroystokyo.paper.profile; + +import java.util.Collection; +import java.util.Set; +import java.util.UUID; + ++import java.util.concurrent.CompletableFuture; +import org.bukkit.profile.PlayerTextures; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @@ -203,8 +204,39 @@ index 0000000000000000000000000000000000000000..d4766e2116c2202d84080637a2832bef + boolean complete(boolean textures, boolean onlineMode); + + /** -+ * Whether or not this Profile has textures associated to it -+ * @return If has a textures property ++ * Produces an updated player profile based on this profile. ++ *
++ * This tries to produce a completed profile by filling in missing ++ * properties (name, unique id, textures, etc.), and updates existing ++ * properties (e.g. name, textures, etc.) to their official and up-to-date ++ * values. This operation does not alter the current profile, but produces a ++ * new updated {@link PlayerProfile}. ++ *
++ * If no player exists for the unique id or name of this profile, this ++ * operation yields a profile that is equal to the current profile, which ++ * might not be complete. ++ *
++ * This is an asynchronous operation: Updating the profile can result in an ++ * outgoing connection in another thread in order to fetch the latest ++ * profile properties. The returned {@link CompletableFuture} will be ++ * completed once the updated profile is available. In order to not block ++ * the server's main thread, you should not wait for the result of the ++ * returned CompletableFuture on the server's main thread. Instead, if you ++ * want to do something with the updated player profile on the server's main ++ * thread once it is available, you could do something like this: ++ *
++ * profile.update().thenAcceptAsync(updatedProfile -> { ++ * // Do something with the updated profile: ++ * // ... ++ * }, runnable -> Bukkit.getScheduler().runTask(plugin, runnable)); ++ *++ */ ++ @Override ++ @NotNull CompletableFuture