java.lang.Object
de.marcely.bedwars.api.cosmetics.shop.data.Image
All Implemented Interfaces:
ActionData

public abstract class Image extends Object implements ActionData
Data for when an image is displayed.
See Also:
  • Constructor Details

    • Image

      public Image()
  • Method Details

    • getType

      public ActionDataType<Image> getType()
      Description copied from interface: ActionData
      Returns the type of this action data.
      Specified by:
      getType in interface ActionData
      Returns:
      The type represented by this data
    • get

      @Nullable public abstract @Nullable BufferedImage get()
      Tries to retrieve the image data.

      Might attempt IO operations if isCached() returns false. It's recommended to run it asynchronously, only if it's cached or simply use getAsync(Consumer).

      Returns:
      The image, or null if it couldn't be retrieved
    • getAsync

      public abstract void getAsync(Consumer<Optional<BufferedImage>> callback)
      Tries to retrieve the image data asynchronously.

      The callback is guaranteed to be called on the main server thread.

      Parameters:
      callback - The callback that receives the image, or an empty optional if it couldn't be retrieved
    • isCached

      public abstract boolean isCached()
      Returns whether the image is already cached in memory.

      Might be cached even if get() or getAsync(Consumer) return null (e.g. if the image couldn't be loaded properly).

      Returns:
      true if cached
    • clearCache

      public abstract void clearCache()
      Clears the cached image, if any.

      As a result, the next call to get() or getAsync(Consumer) might attempt IO operations again.