Class CloudSync
java.lang.Object
com.wildfire.client.cloud.CloudSync
Utility class for managing syncing player data to/from the cloud, even if the current connected server doesn't
have the mod installed.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<Void> deleteProfile(PlayerConfigHolder config) Request that the cloud sync server delete the data stored for the provided client player.static Stringstatic CompletableFuture<Map<UUID, Contributor>> static CompletableFuture<Map<UUID, com.google.gson.JsonObject>> getMultiple(Collection<UUID> uuids) Fetch data for multiple players from the sync server.static CompletableFuture<@Nullable com.google.gson.JsonObject> getProfile(UUID uuid) static CompletableFuture<@Nullable com.google.gson.JsonObject> getProfile(UUID uuid, boolean ignoreConfig) Fetch player data from the sync serverstatic booleanstatic booleanstatic CompletableFuture<@Nullable com.google.gson.JsonObject> queueFetch(UUID uuid) Add a UUID to the fetch queue; this may be requested individually or in bulk, depending on how many other users are queued to be fetched.static voidSends up to 20queued sync queriesstatic CompletableFuture<Void> sync(PlayerConfigHolder config) Send the client player config to the cloud sync server for syncing to other playersstatic booleanstatic @Nullable SyncUnavailable
-
Method Details
-
syncOnCooldown
public static boolean syncOnCooldown()- Returns:
trueif the lastsyncwas within the last 10 seconds
-
isAvailable
public static boolean isAvailable()- Returns:
trueif syncing is available; this method is shorthand forunavailableReason() == null.
-
isEnabled
public static boolean isEnabled()- Returns:
trueif syncing is enabled; this will always returnfalseifsyncing is unavailable.
-
getCloudServer
- Returns:
- The URL of the sync server currently being used
-
getContributors
-
sync
Send the client player config to the cloud sync server for syncing to other players- Parameters:
config- The config of the client player- Returns:
- A
CompletableFutureindicating when the process has finished, or with an exception if syncing failed.
-
deleteProfile
Request that the cloud sync server delete the data stored for the provided client player.- Parameters:
config- The config of the client player- Returns:
- A
CompletableFutureindicating when the process has finished, or with an exception if the request failed.
-
getProfile
- See Also:
-
getProfile
public static CompletableFuture<@Nullable com.google.gson.JsonObject> getProfile(UUID uuid, boolean ignoreConfig) Fetch player data from the sync server- Parameters:
uuid- The UUID of the player to get data for- Returns:
- A
CompletableFuturecontaining aJsonObjectof the player's data if they have any data stored in the sync server, ornullotherwise. - See Also:
- API Note:
- The provided UUID must be
version 4, otherwise the request will fail.
-
getMultiple
public static CompletableFuture<Map<UUID, com.google.gson.JsonObject>> getMultiple(Collection<UUID> uuids) Fetch data for multiple players from the sync server.- Parameters:
uuids- A collection of between 2 and 20 UUIDs to fetch player data for- Returns:
- A
CompletableFuturecontaining a map of player UUIDs to their synced data; any provided player UUIDs without any sync data will not be included in the returned map. - See Also:
- API Note:
- All UUIDs must be
version 4, otherwise the request will fail.
-
queueFetch
Add a UUID to the fetch queue; this may be requested individually or in bulk, depending on how many other users are queued to be fetched.
Queued queries are currently sent once every 2 seconds (or every 40th tick) in batches of up to 20 at once.
- Parameters:
uuid- The UUID of the user to fetch- Returns:
- A
CompletableFuturecontaining aJsonObjectof the relevant player data, which will be completed once the next queued batch is finished.
-
sendNextQueueBatch
@Internal public static void sendNextQueueBatch()Sends up to 20queued sync queries- API Note:
- This method is not intended to be used by other mods.
-