Class Image
java.lang.Object
de.marcely.bedwars.api.cosmetics.shop.data.Image
- All Implemented Interfaces:
ActionData
Data for when an image is displayed.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidClears the cached image, if any.abstract @Nullable BufferedImageget()Tries to retrieve the image data.abstract voidgetAsync(Consumer<Optional<BufferedImage>> callback) Tries to retrieve the image data asynchronously.getType()Returns the type of this action data.abstract booleanisCached()Returns whether the image is already cached in memory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.marcely.bedwars.api.cosmetics.shop.data.ActionData
as, asAnimation, asImage, asKillMessages, asProductModifier, asSkin
-
Constructor Details
-
Image
public Image()
-
-
Method Details
-
getType
Description copied from interface:ActionDataReturns the type of this action data.- Specified by:
getTypein interfaceActionData- Returns:
- The type represented by this data
-
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 usegetAsync(Consumer).- Returns:
- The image, or
nullif it couldn't be retrieved
-
getAsync
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()orgetAsync(Consumer)returnnull(e.g. if the image couldn't be loaded properly).- Returns:
trueif cached
-
clearCache
public abstract void clearCache()Clears the cached image, if any.As a result, the next call to
get()orgetAsync(Consumer)might attempt IO operations again.
-