Interface CosmeticsAPI


public interface CosmeticsAPI
The main API class of the MBedwars' Cosmetics&Coins add-on.
  • 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

      @Nullable @Nullable CosmeticItem getCosmeticById(String id)
      Gets a cosmetic by its CosmeticItem.getId().
      Parameters:
      id - The id to match
      Returns:
      The cosmetic or null if not found
    • getRarities

      Collection<Rarity> getRarities()
      Returns all available rarities.
      Returns:
      All available rarities
    • getRarityById

      @Nullable @Nullable Rarity getRarityById(String id)
      Gets a rarity by its Rarity.getId().
      Parameters:
      id - The id to match
      Returns:
      The rarity or null if not found
    • getCurrencies

      Collection<Currency> getCurrencies()
      Returns all available currencies.
      Returns:
      All available currencies
    • getCurrencyById

      @Nullable @Nullable Currency getCurrencyById(String id)
      Gets a currency by its Currency.getId().
      Parameters:
      id - The id to match
      Returns:
      The currency or null if not found
    • getPlayerData

      void getPlayerData(Player player, Consumer<CosmeticPlayer> callback)
      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 for
      callback - The callback to call when the data is loaded
    • getShops

      Collection<Shop> getShops()
      Returns all configured shop (pages).
      Returns:
      All configured shops
    • getShopById

      @Nullable @Nullable Shop getShopById(String id)
      Get a shop (page) by its Shop.getId().
      Parameters:
      id - The id to match
      Returns:
      The shop or null if not found
    • getCategories

      Returns all available cosmetic item categories.
      Returns:
      All available cosmetic item categories
    • getCategoryById

      @Nullable @Nullable CosmeticItemCategory getCategoryById(String id)
      Gets a cosmetic item category by its CosmeticItemCategory.getId().
      Parameters:
      id - The id to match
      Returns:
      The cosmetic item category or null if not found
    • registerCategory

      CosmeticItemCategory registerCategory(String id, ActionDataType<?> dataType, Plugin plugin)
      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 category
      dataType - The data type of the category
      plugin - The plugin that is registering the category
      Returns:
      The registered category
      Throws:
      IllegalArgumentException - If the id is already used by another category
      IllegalStateException - If the register time has already passed
      IllegalArgumentException - 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

      Animation getAnimationById(String id)
      Tries to find an animation whose Animation.getId() match.
      Parameters:
      id - The id to match with
      Returns:
      The matching animation. null if none was found
    • registerCustomHandlerType

      void registerCustomHandlerType(CustomAnimationHandlerType type)
      Registers a custom handler type for creating custom animations.

      Extend CustomAnimationHandlerType and 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

      void registerActionDataType(ActionDataType<?> type)
      Registers a new action data type.

      To create a custom one, simply implement the ActionDataType interface and register it using this method.

      Parameters:
      type - The type to register
      Throws:
      IllegalArgumentException - If the type is already registered
      IllegalArgumentException - If there is something wrong with the type (e.g. ActionDataType.getPlugin() returns null)
    • hasShopOpen

      boolean hasShopOpen(Player player)
      Get if the player has a shop open.
      Parameters:
      player - The player to check
      Returns:
      true if the player has a shop open, false otherwise
    • getShopOpen

      @Nullable @Nullable Shop getShopOpen(Player player)
      Get the shop (page) that the player has open.
      Parameters:
      player - The player to check
      Returns:
      The shop that the player has open, null if 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

      static CosmeticsAPI get()
      Get the instance of the API.
      Returns:
      The instance of the API