Class CloudSync

java.lang.Object
com.wildfire.client.cloud.CloudSync

public final class CloudSync extends Object
Utility class for managing syncing player data to/from the cloud, even if the current connected server doesn't have the mod installed.
  • Method Details

    • syncOnCooldown

      public static boolean syncOnCooldown()
      Returns:
      true if the last sync was within the last 10 seconds
    • unavailableReason

      public static @Nullable SyncUnavailable unavailableReason()
      Returns:
      A SyncUnavailable enum indicating the reason for syncing being unavailable, or null if available
    • isAvailable

      public static boolean isAvailable()
      Returns:
      true if syncing is available; this method is shorthand for unavailableReason() == null.
    • isEnabled

      public static boolean isEnabled()
      Returns:
      true if syncing is enabled; this will always return false if syncing is unavailable.
    • getCloudServer

      public static String getCloudServer()
      Returns:
      The URL of the sync server currently being used
    • getContributors

      @Internal public static CompletableFuture<Map<UUID, Contributor>> getContributors()
    • sync

      public static CompletableFuture<Void> sync(PlayerConfigHolder config)
      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 CompletableFuture indicating when the process has finished, or with an exception if syncing failed.
    • deleteProfile

      public static CompletableFuture<Void> deleteProfile(PlayerConfigHolder config)
      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 CompletableFuture indicating when the process has finished, or with an exception if the request failed.
    • getProfile

      public static CompletableFuture<@Nullable com.google.gson.JsonObject> getProfile(UUID uuid)
      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 CompletableFuture containing a JsonObject of the player's data if they have any data stored in the sync server, or null otherwise.
      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 CompletableFuture containing 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

      public static 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.

      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 CompletableFuture containing a JsonObject of the relevant player data, which will be completed once the next queued batch is finished.
    • sendNextQueueBatch

      @Internal public static void sendNextQueueBatch()
      Sends up to 20 queued sync queries
      API Note:
      This method is not intended to be used by other mods.