Class CompletionCriteria

java.lang.Object
me.gamercoder215.starcosmetics.api.CompletionCriteria

public final class CompletionCriteria extends Object
Represents Criteria needed to unlock a Cosmetic
  • Field Details

    • NONE

      public static final CompletionCriteria NONE
      Represents a CompletionCriteria that requires nothing.
  • Method Details

    • getCriteria

      @NotNull public @NotNull Predicate<Player> getCriteria()
      Fetches the criteria needed to unlock a Cosmetic.
      Returns:
      Predicate representing the criteria
    • isUnlocked

      public boolean isUnlocked(@Nullable @Nullable Player p)
      Whether this Player meets the criteria.
      Parameters:
      p - Player to check
      Returns:
      true if meets criteria, else false
    • getDisplayMessage

      @NotNull public @NotNull String getDisplayMessage()
      Fetches the display message of this criteria.
      Returns:
      Display Message
    • getProgressPercentage

      public double getProgressPercentage(@NotNull @NotNull Player p)
      Fetches the progress of a Player for this CompletionCriteria.
      Parameters:
      p - Player to fetch progress for
      Returns:
      Progress Percentage
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromCompletion

      @NotNull public static @NotNull CompletionCriteria fromCompletion(@NotNull @NotNull Completion completion) throws IllegalArgumentException
      Generates a CompletionCriteria from a Completion.
      Parameters:
      completion - Completion to Check for
      Returns:
      CompletionCriteria with the given criteria
      Throws:
      IllegalArgumentException - if criteria is null
    • fromMined

      @NotNull public static @NotNull CompletionCriteria fromMined(int amount, Material m)
      Generates a CompletionCriteria with Statistic.MINE_BLOCK.
      Parameters:
      amount - The amount of blocks to mine
      m - The material to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromDistance

      @NotNull public static @NotNull CompletionCriteria fromDistance(Statistic stat, double cm)
      Generates a CompletionCriteria from a distance statistic (e.g. Statistic.WALK_ONE_CM).
      Parameters:
      stat - Statistic to check
      cm - The amount of centimeters to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromMined

      @NotNull public static @NotNull CompletionCriteria fromMined(int amount, Collection<Material> materials)
      Generates a CompletionCriteria with Statistic.MINE_BLOCK, using multiple. Materials mined will count EITHER and amounts will not be added together.
      Parameters:
      amount - The amount of blocks to mine
      materials - Collection of Materials to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromMined

      public static CompletionCriteria fromMined(int amount, Material... materials)
      Generates a CompletionCriteria with Statistic.MINE_BLOCK, using multiple. Materials mined will count EITHER and amounts will not be added together.
      Parameters:
      amount - The amount of blocks to mine
      materials - Array of Materials to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromKilled

      public static CompletionCriteria fromKilled(int amount, EntityType type)
      Generates a CompletionCriteria with Statistic.KILL_ENTITY.
      Parameters:
      amount - The amount of kills to check for
      type - The type of entity to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromStatistic

      public static CompletionCriteria fromStatistic(Statistic stat, int amount)

      Generates a CompletionCriteria with a Bukkit Statistic.

      NOTE: Statistics that require addition input in Player.getStatistic(Statistic) will not work properly.

      Parameters:
      stat - The statistic to check for
      amount - The amount of kills to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromBlocksMined

      public static CompletionCriteria fromBlocksMined(int amount)
      Generates a CompletionCriteria from the amount of blocks mined.
      Parameters:
      amount - Blocks Mined
      Returns:
      CompletionCriteria with the given criteria
    • fromCrafted

      public static CompletionCriteria fromCrafted(int amount, Material m)
      Generates a CompletionCriteria with Statistic.CRAFT_ITEM.
      Parameters:
      amount - The amount of items crafted
      m - The material to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromCrafted

      public static CompletionCriteria fromCrafted(int amount, Material... materials)
      Generates a CompletionCriteria with Statistic.CRAFT_ITEM, using multiple. Materials crafted will count EITHER and amounts will not be added together.
      Parameters:
      amount - The amount of items crafted
      materials - Array of Materials to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromCrafted

      public static CompletionCriteria fromCrafted(int amount, Collection<Material> materials)
      Generates a CompletionCriteria with Statistic.CRAFT_ITEM, using multiple. Materials crafted will count EITHER and amounts will not be added together.
      Parameters:
      amount - The amount of items crafted
      materials - Collection of Materials to check for
      Returns:
      CompletionCriteria with the given criteria
    • fromPlaytime

      @NotNull public static @NotNull CompletionCriteria fromPlaytime(long ticks)
      Generates a CompletionCrtieria with the player's playtime.
      Parameters:
      ticks - The amount of ticks the player must play for
      Returns:
      CompletionCriteria with the given criteria
    • fromSelectionLimit

      @NotNull public static @NotNull CompletionCriteria fromSelectionLimit(int limit) throws IllegalArgumentException
      Constructs a CompletionCriteria required to have the given selection limit.
      Parameters:
      limit - Selection Limit
      Returns:
      CompletionCriteria based on selection limit
      Throws:
      IllegalArgumentException - if the limit is not positive