geforkt von Mirrors/Paper
Fix update future return type (#8120)
Dieser Commit ist enthalten in:
Ursprung
2a189a99cd
Commit
2dddcb7bf1
@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+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..00000000000000000000000000000000
|
||||
+ 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.
|
||||
+ * <p>
|
||||
+ * 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}.
|
||||
+ * <p>
|
||||
+ * 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.
|
||||
+ * <p>
|
||||
+ * 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:
|
||||
+ * <pre>
|
||||
+ * profile.update().thenAcceptAsync(updatedProfile -> {
|
||||
+ * // Do something with the updated profile:
|
||||
+ * // ...
|
||||
+ * }, runnable -> Bukkit.getScheduler().runTask(plugin, runnable));
|
||||
+ * </pre>
|
||||
+ */
|
||||
+ @Override
|
||||
+ @NotNull CompletableFuture<PlayerProfile> update();
|
||||
+
|
||||
+ /**
|
||||
+ * Whether this Profile has textures associated to it
|
||||
+ * @return If it has a textures property
|
||||
+ */
|
||||
+ default boolean hasTextures() {
|
||||
+ return hasProperty("textures");
|
||||
@ -455,3 +487,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name);
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/profile/PlayerProfile.java b/src/main/java/org/bukkit/profile/PlayerProfile.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/profile/PlayerProfile.java
|
||||
+++ b/src/main/java/org/bukkit/profile/PlayerProfile.java
|
||||
@@ -0,0 +0,0 @@ public interface PlayerProfile extends Cloneable, ConfigurationSerializable {
|
||||
* PlayerProfile once it is available
|
||||
*/
|
||||
@NotNull
|
||||
- CompletableFuture<PlayerProfile> update();
|
||||
+ CompletableFuture<? extends PlayerProfile> update(); // Paper
|
||||
|
||||
@NotNull
|
||||
PlayerProfile clone();
|
||||
|
@ -180,7 +180,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull CompletableFuture<org.bukkit.profile.PlayerProfile> update() {
|
||||
+ public @NotNull CompletableFuture<PlayerProfile> update() {
|
||||
+ return CompletableFuture.supplyAsync(() -> {
|
||||
+ final CraftPlayerProfile clone = clone();
|
||||
+ clone.complete(true);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren