Class HuskSyncAPI

java.lang.Object
net.william278.husksync.api.BaseHuskSyncAPI
net.william278.husksync.api.HuskSyncAPI

public class HuskSyncAPI extends net.william278.husksync.api.BaseHuskSyncAPI
The HuskSync API implementation for the Bukkit platform, providing methods to access and modify player UserData held by Users.

Retrieve an instance of the API class via getInstance().
  • Method Details

    • getInstance

      @NotNull public static HuskSyncAPI getInstance()
      Entrypoint to the HuskSync API - returns an instance of the API
      Returns:
      instance of the HuskSync API
    • getUser

      @NotNull public net.william278.husksync.player.OnlineUser getUser(@NotNull org.bukkit.entity.Player player)
      Returns a User instance for the given bukkit Player.
      Parameters:
      player - the bukkit player to get the User instance for
      Returns:
      the User instance for the given bukkit Player
      Since:
      2.0
    • setInventoryData

      public CompletableFuture<Void> setInventoryData(@NotNull net.william278.husksync.player.User user, @NotNull org.bukkit.inventory.ItemStack[] inventoryContents)
      Set the inventory in the database of the given User to the given ItemStack contents
      Parameters:
      user - the User to set the inventory of
      inventoryContents - the ItemStack contents to set the inventory to
      Returns:
      future returning void when complete
      Since:
      2.0
    • setInventoryData

      public CompletableFuture<Void> setInventoryData(@NotNull net.william278.husksync.player.User user, @NotNull BukkitInventoryMap inventoryMap)
      Set the inventory in the database of the given User to the given BukkitInventoryMap contents
      Parameters:
      user - the User to set the inventory of
      inventoryMap - the BukkitInventoryMap contents to set the inventory to
      Returns:
      future returning void when complete
      Since:
      2.0
    • setEnderChestData

      public CompletableFuture<Void> setEnderChestData(@NotNull net.william278.husksync.player.User user, @NotNull org.bukkit.inventory.ItemStack[] enderChestContents)
      Set the Ender Chest in the database of the given User to the given ItemStack contents
      Parameters:
      user - the User to set the Ender Chest of
      enderChestContents - the ItemStack contents to set the Ender Chest to
      Returns:
      future returning void when complete
      Since:
      2.0
    • getPlayerInventory

      public CompletableFuture<Optional<BukkitInventoryMap>> getPlayerInventory(@NotNull net.william278.husksync.player.User user)
      Returns a BukkitInventoryMap for the given User, containing their current inventory item data
      Parameters:
      user - the User to get the BukkitInventoryMap for
      Returns:
      future returning the BukkitInventoryMap for the given User if they exist, otherwise an empty Optional
      Since:
      2.0
    • getPlayerEnderChest

      public CompletableFuture<Optional<org.bukkit.inventory.ItemStack[]>> getPlayerEnderChest(@NotNull net.william278.husksync.player.User user)
      Returns the ItemStacks array contents of the given User's Ender Chest data
      Parameters:
      user - the User to get the Ender Chest contents of
      Returns:
      future returning the ItemStack array of Ender Chest items for the user if they exist, otherwise an empty Optional
      Since:
      2.0
    • deserializeItemStackArray

      public CompletableFuture<org.bukkit.inventory.ItemStack[]> deserializeItemStackArray(@NotNull String serializedItemStackArray) throws net.william278.husksync.data.DataSerializationException
      Deserialize a Base-64 encoded inventory array string into a ItemStack array.
      Parameters:
      serializedItemStackArray - The Base-64 encoded inventory array string.
      Returns:
      The deserialized ItemStack array.
      Throws:
      net.william278.husksync.data.DataSerializationException - If an error occurs during deserialization.
      Since:
      2.0
    • deserializeInventory

      public CompletableFuture<BukkitInventoryMap> deserializeInventory(@NotNull String serializedInventory) throws net.william278.husksync.data.DataSerializationException
      Deserialize a serialized ItemStack array of player inventory contents into a BukkitInventoryMap
      Parameters:
      serializedInventory - The serialized ItemStack array of player inventory contents.
      Returns:
      A BukkitInventoryMap of the deserialized ItemStack contents array
      Throws:
      net.william278.husksync.data.DataSerializationException - If an error occurs during deserialization.
      Since:
      2.0
    • serializeItemStackArray

      public CompletableFuture<String> serializeItemStackArray(@NotNull org.bukkit.inventory.ItemStack[] itemStacks) throws net.william278.husksync.data.DataSerializationException
      Serialize an ItemStack array into a Base-64 encoded string.
      Parameters:
      itemStacks - The ItemStack array to serialize.
      Returns:
      The serialized Base-64 encoded string.
      Throws:
      net.william278.husksync.data.DataSerializationException - If an error occurs during serialization.
      Since:
      2.0
      See Also:
      deserializeItemStackArray(String), ItemData
    • deserializePotionEffectArray

      public CompletableFuture<org.bukkit.potion.PotionEffect[]> deserializePotionEffectArray(@NotNull String serializedPotionEffectArray) throws net.william278.husksync.data.DataSerializationException
      Deserialize a Base-64 encoded potion effect array string into a PotionEffect array.
      Parameters:
      serializedPotionEffectArray - The Base-64 encoded potion effect array string.
      Returns:
      The deserialized PotionEffect array.
      Throws:
      net.william278.husksync.data.DataSerializationException - If an error occurs during deserialization.
      Since:
      2.0
    • serializePotionEffectArray

      public CompletableFuture<String> serializePotionEffectArray(@NotNull org.bukkit.potion.PotionEffect[] potionEffects) throws net.william278.husksync.data.DataSerializationException
      Serialize a PotionEffect array into a Base-64 encoded string.
      Parameters:
      potionEffects - The PotionEffect array to serialize.
      Returns:
      The serialized Base-64 encoded string.
      Throws:
      net.william278.husksync.data.DataSerializationException - If an error occurs during serialization.
      Since:
      2.0
      See Also:
      deserializePotionEffectArray(String), PotionEffectData