Package de.marcely.bedwars.api.cosmetics
Interface CosmeticsAPI
public interface CosmeticsAPI
The main API class of the MBedwars' Cosmetics&Coins add-on.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CosmeticsAPIget()Get the instance of the API.Returns all registered action data types.getAddon()Returns the add-on instance that is being used within MBedwars.Tries to find an animation whoseAnimation.getId()match.Collection<? extends Animation> Get all configured animations.Returns all available cosmetic item categories.@Nullable CosmeticItemCategoryGets a cosmetic item category by itsCosmeticItemCategory.getId().@Nullable CosmeticItemGets a cosmetic by itsCosmeticItem.getId().Returns all available cosmetics.Returns all available currencies.@Nullable CurrencyGets a currency by itsCurrency.getId().Get all registered custom handler types for creating custom animations.voidgetPlayerData(Player player, Consumer<CosmeticPlayer> callback) Loads and returns the player's data.Get all players that have a shop open.Returns all available rarities.@Nullable RaritygetRarityById(String id) Gets a rarity by itsRarity.getId().@Nullable ShopgetShopById(String id) Get a shop (page) by itsShop.getId().@Nullable ShopgetShopOpen(Player player) Get the shop (page) that the player has open.getShops()Returns all configured shop (pages).booleanhasShopOpen(Player player) Get if the player has a shop open.voidregisterActionDataType(ActionDataType<?> type) Registers a new action data type.registerCategory(String id, ActionDataType<?> dataType, Plugin plugin) Registers a new cosmetic item category.voidRegisters a custom handler type for creating custom animations.
-
Method Details
-
getAddon
BedwarsAddon getAddon()Returns the add-on instance that is being used within MBedwars.- Returns:
- The add-on instance
-
getCosmetics
Collection<CosmeticItem> getCosmetics()Returns all available cosmetics.- Returns:
- All available cosmetics
-
getCosmeticById
Gets a cosmetic by itsCosmeticItem.getId().- Parameters:
id- The id to match- Returns:
- The cosmetic or
nullif not found
-
getRarities
Collection<Rarity> getRarities()Returns all available rarities.- Returns:
- All available rarities
-
getRarityById
Gets a rarity by itsRarity.getId().- Parameters:
id- The id to match- Returns:
- The rarity or
nullif not found
-
getCurrencies
Collection<Currency> getCurrencies()Returns all available currencies.- Returns:
- All available currencies
-
getCurrencyById
Gets a currency by itsCurrency.getId().- Parameters:
id- The id to match- Returns:
- The currency or
nullif not found
-
getPlayerData
Loads and returns the player's data.Player data is loaded asynchronously and the callback is called on the server's main-thread when the data is loaded.
- Parameters:
player- The player to load the data forcallback- The callback to call when the data is loaded
-
getShops
Collection<Shop> getShops()Returns all configured shop (pages).- Returns:
- All configured shops
-
getShopById
Get a shop (page) by itsShop.getId().- Parameters:
id- The id to match- Returns:
- The shop or
nullif not found
-
getCategories
Collection<CosmeticItemCategory> getCategories()Returns all available cosmetic item categories.- Returns:
- All available cosmetic item categories
-
getCategoryById
Gets a cosmetic item category by itsCosmeticItemCategory.getId().- Parameters:
id- The id to match- Returns:
- The cosmetic item category or
nullif not found
-
registerCategory
Registers a new cosmetic item category.Note that the id must be unique and not already used by another category.
- Parameters:
id- The unique id of the categorydataType- The data type of the categoryplugin- The plugin that is registering the category- Returns:
- The registered category
- Throws:
IllegalArgumentException- If the id is already used by another categoryIllegalStateException- If the register time has already passedIllegalArgumentException- If the dataType is not registered
-
getActionDataTypes
Collection<ActionDataType<?>> getActionDataTypes()Returns all registered action data types.- Returns:
- An immutable collection of all registered action data types
-
getAnimations
Collection<? extends Animation> getAnimations()Get all configured animations.- Returns:
- An immutable collection of all added animations
-
getAnimationById
Tries to find an animation whoseAnimation.getId()match.- Parameters:
id- The id to match with- Returns:
- The matching animation.
nullif none was found
-
registerCustomHandlerType
Registers a custom handler type for creating custom animations.Extend
CustomAnimationHandlerTypeand call this method to add your own handler!- Parameters:
type- The type you want to register- Throws:
IllegalArgumentException- If there is something wrong with the type, such as if it's already registered
-
getCustomHandlerTypes
Collection<CustomAnimationHandlerType> getCustomHandlerTypes()Get all registered custom handler types for creating custom animations.This does not include built-in handlers.
- Returns:
- All registered custom handler types
-
registerActionDataType
Registers a new action data type.To create a custom one, simply implement the
ActionDataTypeinterface and register it using this method.- Parameters:
type- The type to register- Throws:
IllegalArgumentException- If the type is already registeredIllegalArgumentException- If there is something wrong with the type (e.g.ActionDataType.getPlugin()returnsnull)
-
hasShopOpen
Get if the player has a shop open.- Parameters:
player- The player to check- Returns:
trueif the player has a shop open,falseotherwise
-
getShopOpen
Get the shop (page) that the player has open.- Parameters:
player- The player to check- Returns:
- The shop that the player has open,
nullif the player has no shop open
-
getPlayersWithShopOpen
Collection<Player> getPlayersWithShopOpen()Get all players that have a shop open.- Returns:
- All players that have a shop open
-
get
Get the instance of the API.- Returns:
- The instance of the API
-