Class Business

java.lang.Object
us.teaminceptus.novaconomy.api.business.Business
All Implemented Interfaces:
ConfigurationSerializable

public final class Business extends Object implements ConfigurationSerializable
Represents a Novaconomy Business
  • Field Details

    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      The maximum length of a Business Name.
      See Also:
    • MAX_KEYWORDS

      public static final int MAX_KEYWORDS
      The maximum number of keywords a Business can have.
      See Also:
    • MAX_KETWORD_LENGTH

      public static final int MAX_KETWORD_LENGTH
      The maximum length of a business keyword.
      See Also:
  • Method Details

    • builder

      public static Business.Builder builder()
      Fetches the Business Builder.
      Returns:
      Business Builder
    • getOwner

      @NotNull public @NotNull OfflinePlayer getOwner()
      Fetches the Business's Owner.
      Returns:
      Business Owner
    • getName

      @NotNull public @NotNull String getName()
      Fetches the Business's Name.
      Returns:
      Business Name
    • getUniqueId

      @NotNull public @NotNull UUID getUniqueId()
      Fetches the Business's Unique ID.
      Returns:
      Business ID
    • getHome

      @Nullable public @Nullable Location getHome()
      Fetches the Business's Home Location.
      Returns:
      Business Home Location, or null if not found
    • hasHome

      public boolean hasHome()
      Whether this Busienss has a home set.
      Returns:
      true if home set, else false
    • setHome

      public void setHome(@Nullable @Nullable Location home)
      Sets the Business's Home Location.
      Parameters:
      home - Business Home Location
    • setIcon

      public void setIcon(@NotNull @NotNull Material icon) throws IllegalArgumentException
      Sets the icon of this Business.
      Parameters:
      icon - Business Icon
      Throws:
      IllegalArgumentException - if icon is null
    • setName

      public void setName(@NotNull @NotNull String name) throws IllegalArgumentException
      Sets the name of this Business.
      Parameters:
      name - Business Name
      Throws:
      IllegalArgumentException - if name is null or empty
    • isOwner

      public boolean isOwner(@Nullable @Nullable OfflinePlayer p)
      Whether this Player is the owner of this Business.
      Parameters:
      p - Player to check
      Returns:
      true if owner, else false
    • exists

      public static boolean exists()
      Utility method to check if any Businesses currently exist.
      Returns:
      true if any Businesses exist, else false
    • getProducts

      @NotNull public @NotNull List<BusinessProduct> getProducts()
      Fetches the List of Products this Business is selling.
      Returns:
      Products to add
    • serialize

      @Deprecated public Map<String,Object> serialize()
      Deprecated.
      Specified by:
      serialize in interface ConfigurationSerializable
    • addResource

      @NotNull public @NotNull Business addResource(@Nullable @Nullable ItemStack... items)
      Adds Resources available for purchase from this Business.
      Parameters:
      items - Items to add
      Returns:
      this Business, for chaining
    • getResources

      @NotNull public @NotNull List<ItemStack> getResources()
      Returns an immutable version of Business's Resources available for selling via Products.
      Returns:
      List of Resources used for selling with Products
    • addResource

      @NotNull public @NotNull Business addResource(@Nullable @Nullable Iterable<? extends ItemStack> resources)
      Adds a Collection of Resources available for purchase from this Business.
      Parameters:
      resources - Items to add
      Returns:
      this Business, fo rchaining
    • isInStock

      public boolean isInStock(@Nullable @Nullable ItemStack item)
      Whether this item is in stock.
      Parameters:
      item - Item to test
      Returns:
      true if item is in stock, else false
    • getTotalStock

      public int getTotalStock(@Nullable @Nullable ItemStack item)
      Fetches the total stock amount of this item.
      Parameters:
      item - Item to test
      Returns:
      Total stock amount of this item, or 0 if item is null or not found
    • isInStock

      public boolean isInStock(@Nullable @Nullable Material m)
      Whether a Resource matching this Material is in stock.
      Parameters:
      m - Material to use
      Returns:
      true if material matches an item in stock, else false
    • removeProduct

      @NotNull public @NotNull Business removeProduct(@Nullable @Nullable BusinessProduct... products)
      Removes an Array of Products from this Business.
      Parameters:
      products - Business Products to Remove
      Returns:
      this Business, for chaining
    • removeProduct

      @NotNull public @NotNull Business removeProduct(@Nullable @Nullable ItemStack... items)
      Removes an Array of ItemStacks from this Business's Products.
      Parameters:
      items - Products to Remove
      Returns:
      this Business, for chaining
    • removeResource

      @NotNull public @NotNull Business removeResource(@Nullable @Nullable ItemStack... resources)
      Removes an Array of Resources from this Business.
      Parameters:
      resources - Resources to Remove
      Returns:
      this Business, for chaining
    • removeResource

      @NotNull public @NotNull Business removeResource(@Nullable @Nullable Iterable<? extends ItemStack> resources)
      Removes an iterable of Resources from this Business.
      Parameters:
      resources - Resources to Remove
      Returns:
      this Business, for chaining
    • removeProduct

      @NotNull public @NotNull Business removeProduct(@Nullable @Nullable Iterable<? extends BusinessProduct> products)
      Removes an iterable of Products from this Business.
      Parameters:
      products - Products to Remove
      Returns:
      this Business, for chaining
    • isProduct

      public boolean isProduct(@Nullable @Nullable ItemStack i)
      Whether this Item is a Registered Product.
      Parameters:
      i - Item to test
      Returns:
      true if item is product, else false
    • isProduct

      public boolean isProduct(@Nullable @Nullable Material m)
      Whether one of the products has this Material as its product.
      Parameters:
      m - Material to test
      Returns:
      true if product has material, else false
    • getProduct

      @Nullable public @Nullable BusinessProduct getProduct(@Nullable @Nullable ItemStack item)
      Fetches a BusinessProduct by its Item.
      Parameters:
      item - Item to fetch
      Returns:
      Business Product found, or null if not found or if item is null
    • addProduct

      @NotNull public @NotNull Business addProduct(@Nullable @Nullable Product... products)
      Adds an Array of Products to this Business.
      Parameters:
      products - Products to Add
      Returns:
      this Business, for chaining
    • getIcon

      @NotNull public @NotNull ItemStack getIcon()
      Fetches this Business's Icon.
      Returns:
      Business Icon
    • addProduct

      @NotNull public @NotNull Business addProduct(@Nullable @Nullable Collection<? extends Product> products)
      Adds a Collection of Products to this Business.
      Parameters:
      products - Products to Add
      Returns:
      this Business, for chaining
    • getLeftoverStock

      @NotNull public @NotNull List<ItemStack> getLeftoverStock()

      Fetches any extra stock that are no longer products in the Business.

      This method can be used to fetch stock of products that sold on deleted economies.

      Returns:
      Extra Stock
    • getSetting

      public <T> T getSetting(@Nullable Settings.Business<T> setting)
      Fetches a Setting Value for this Business.
      Parameters:
      setting - Setting to check
      Returns:
      Setting Value, or false if setting is null
    • getSettings

      @NotNull public @NotNull Map<Settings.Business<?>,Object> getSettings()
      Fetches an immutable version of all of the settings on this business.
      Returns:
      Immutable Map of Settings
    • getRatings

      @NotNull public @NotNull List<Rating> getRatings()
      Fetches a list of all ratings for this Business.
      Returns:
      List of Ratings
    • getAverageRating

      public double getAverageRating()
      Fetches the average rating level for this Business.
      Returns:
      Average Rating Level
    • setSetting

      @NotNull public <T> @NotNull Business setSetting(@NotNull Settings.Business<T> setting, T value)
      Sets a Setting Value for this Business.
      Parameters:
      setting - Setting to set
      value - Value of the new setting
      Returns:
      this Business, for chaining
    • getBlacklist

      @NotNull public @NotNull List<Business> getBlacklist()
      Fetches a list of all Businesses that are prohibited from associating with this Business, such as with Advertising.
      Returns:
      List of Blacklisted Businesses
    • blacklist

      @NotNull public @NotNull Business blacklist(@NotNull @NotNull Business business) throws IllegalArgumentException
      Adds a Business to this Business's blacklist.
      Parameters:
      business - Business to add
      Returns:
      this Business, for chaining
      Throws:
      IllegalArgumentException - if business is this business
    • isBlacklisted

      public boolean isBlacklisted(@NotNull @NotNull Business business)
      Checks whether a Business is blacklisted from associating with this Business.
      Parameters:
      business - Business to check
      Returns:
      true if blacklisted, else false
    • unblacklist

      @NotNull public @NotNull Business unblacklist(@NotNull @NotNull Business business)
      Removes a Business from this Business's blacklist.
      Parameters:
      business - Business to remove
      Returns:
      this Business, for chaining
    • getCustomModelData

      public int getCustomModelData()
      Fetches the custom model data ID for this Business.
      Returns:
      Custom Model Data
    • setCustomModelData

      public void setCustomModelData(int customModelData)
      Sets the custom model data ID for this Business.
      Parameters:
      customModelData - Custom Model Data
    • getSupplyChests

      @NotNull public @NotNull Set<Chest> getSupplyChests()
      Fetches an immutable set of all of the supply chests for this Business.
      Returns:
      Immutable Set of Supply Chest States
    • addSupplyChest

      @NotNull public void addSupplyChest(@NotNull @NotNull Chest chest)
      Adds a supply chest to this Business.
      Parameters:
      chest - Chest Block to add
    • addSupplyChest

      @NotNull public void addSupplyChest(@NotNull @NotNull Location loc)
      Adds a supply chest to this Business.
      Parameters:
      loc - Location of the chest
    • removeSupplyChest

      @NotNull public void removeSupplyChest(@Nullable @Nullable Location loc)
      Removes a supply chest from this Business.
      Parameters:
      loc - Location of the chest
    • supply

      public void supply()
      Adds the resources from all of the supply chests to the Business's inventory, calling BusinessSupplyEvent. This method will silently fail if the event is cancelled.
    • deserialize

      @Deprecated @Nullable public static @Nullable Business deserialize(@Nullable @Nullable Map<String,Object> serial)
      Deprecated.
      Entire Bukkit Serialization is no longer used; this method exists only for the purposes of converting legacy businesses
      Deserializes a Map into a Business.
      Parameters:
      serial - Serialization from serialize()
      Returns:
      Deserialized Business
    • getTotalRevenue

      public double getTotalRevenue()
      Fetches the total amount of money this Business has earned, accounting for conversion scales.
      Returns:
      Total Money Earned by this Business
    • getBusinessFolder

      @NotNull public @NotNull File getBusinessFolder()
      Fetches the folder this Business is stored in, if NovaConfig.isDatabaseEnabled() is false.
      Returns:
      Business Folder
    • saveBusiness

      public void saveBusiness()
      Saves this Business in getBusinessFolder().
    • reloadBusinesses

      public static void reloadBusinesses()
      Reloads the Business Cache.
    • getBusinesses

      @NotNull public static @NotNull Set<Business> getBusinesses() throws IllegalStateException
      Fetches an immutable version of all registered Businesses.
      Returns:
      All Registered Businesses
      Throws:
      IllegalStateException - if a business file is invalid
    • byId

      @Nullable public static @Nullable Business byId(@Nullable @Nullable UUID uid) throws IllegalStateException
      Fetches a Business by its unique ID.
      Parameters:
      uid - Business ID
      Returns:
      Found business, or null if not found / ID is null
      Throws:
      IllegalStateException - if the business file is malformed
    • byName

      @Nullable public static @Nullable Business byName(@Nullable @Nullable String name)
      Fetches a Business by its name.
      Parameters:
      name - Business Name
      Returns:
      Found business, or null if not found
    • byOwner

      @Nullable public static @Nullable Business byOwner(@Nullable @Nullable OfflinePlayer p)
      Fetches a Business by its Owner.
      Parameters:
      p - Owner of Business
      Returns:
      Found business, or null if not found / Player is null
    • remove

      public static void remove(@Nullable @Nullable Business b)
      Deletes a Business.
      Parameters:
      b - Business to remove
    • exists

      public static boolean exists(@Nullable @Nullable String name)
      Checks whether this Business exists.
      Parameters:
      name - Business name
      Returns:
      true if business exists, else false
    • isSupplyClaimed

      public static boolean isSupplyClaimed(@Nullable @Nullable Location loc)
      Fetches if any of the Businesses have claimed this Supply Chest.
      Parameters:
      loc - Supply Chest Location
      Returns:
      true if claimed, else false
    • getAdvertisingBalance

      public double getAdvertisingBalance()
      Fetches the Business's Advertising Balance.
      Returns:
      Advertising Balance
    • setAdvertisingBalance

      @NotNull public @NotNull Business setAdvertisingBalance(double advertisingBalance)
      Sets the Business's Advertising Balance.
      Parameters:
      advertisingBalance - Advertising Balance
      Returns:
      this business, for chaining
    • addAdvertisingBalance

      @NotNull public @NotNull Business addAdvertisingBalance(double amount)
      Adds to the Business's Advertising Balance.
      Parameters:
      amount - Amount to add
      Returns:
      this business, for chaining
    • addAdvertisingBalance

      @NotNull public @NotNull Business addAdvertisingBalance(@Nullable @Nullable Price price)
      Adds to the Business's Advertising Balance.
      Parameters:
      price - Price to add
      Returns:
      this business, for chaining
    • addAdvertisingBalance

      @NotNull public @NotNull Business addAdvertisingBalance(double amount, @Nullable @Nullable Economy econ)
      Adds to the Business's Advertising Balance.
      Parameters:
      amount - Amount to add
      econ - Economy to use with the Conversion Scale
      Returns:
      this business, for chaining
    • removeAdvertisingBalance

      @NotNull public @NotNull Business removeAdvertisingBalance(double amount)
      Removes from the Business's Advertising Balance.
      Parameters:
      amount - Amount to remove
      Returns:
      this business, for chaining
    • removeAdvertisingBalance

      @NotNull public @NotNull Business removeAdvertisingBalance(double amount, @Nullable @Nullable Economy econ)
      Removes from the Business's Advertising Balance.
      Parameters:
      amount - Amount to remove
      econ - Economy to use with the Conversion Scale
      Returns:
      this business, for chaining
    • removeAdvertisingBalance

      @NotNull public @NotNull Business removeAdvertisingBalance(@Nullable @Nullable Price p)
      Removes from the Business's Advertising Balance.
      Parameters:
      p - Price to remove
      Returns:
      this business, for chaining
    • equals

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

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

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

      public static boolean exists(@Nullable @Nullable UUID uid)
      Checks whether this Business exists.
      Parameters:
      uid - Business ID
      Returns:
      true if business exists, else false
    • exists

      public static boolean exists(@Nullable @Nullable OfflinePlayer p)
      Checks whether this Business exists.
      Parameters:
      p - Owner of Business
      Returns:
      true if business exists, else false
    • getStatistics

      @NotNull public @NotNull BusinessStatistics getStatistics()
      Fetches the Business's Statistics.
      Returns:
      Business Statistics
    • getProductSales

      @NotNull public @NotNull Map<Product,Integer> getProductSales()
      Returns:
      Product Sales
    • getPurchaseCount

      public int getPurchaseCount(@NotNull @NotNull Product p)
      Parameters:
      p - Product to check
      Returns:
      Purchase Count, or 0 if none
    • getCreationDate

      @NotNull public @NotNull Date getCreationDate()
      Fetches the Business's Creation Date.
      Returns:
      Business Creation Date, or May 17, 2009 (MC's Birth Date) if not set / created before this was tracked
    • getKeywords

      @NotNull public @NotNull List<String> getKeywords()
      Fetches an immutable version of the Business's Keywords.
      Returns:
      Business Keywords
    • addKeywords

      public void addKeywords(@Nullable @Nullable String... keywords)
      Adds keywords to the Business.
      Parameters:
      keywords - Keywords to add
    • addKeywords

      public void addKeywords(@Nullable @Nullable Iterable<String> keywords) throws IllegalArgumentException
      Adds a collection of keywords to the Business.
      Parameters:
      keywords - Keywords to add
      Throws:
      IllegalArgumentException - if keywords are too long or the business has exceeded the amount of keywords
    • removeKeywords

      public void removeKeywords(@Nullable @Nullable String... keywords)
      Removes keywords from the Business.
      Parameters:
      keywords - Keywords to remove
    • removeKeywords

      public void removeKeywords(@Nullable @Nullable Iterable<String> keywords)
      Removes a collection of keywords from the Business.
      Parameters:
      keywords - Keywords to remove
    • hasAllKeywords

      public boolean hasAllKeywords(@Nullable @Nullable String... keywords)
      Whether this Business contains all of the keywords in this array.
      Parameters:
      keywords - Keywords to check
      Returns:
      true if all keywords are present, else false
    • hasAllKeywords

      public boolean hasAllKeywords(@Nullable @Nullable Iterable<String> keywords)
      Whether this Business contains all of the keywords in this collection.
      Parameters:
      keywords - Keywords to check
      Returns:
      true if all keywords are present, else false
    • hasAnyKeywords

      public boolean hasAnyKeywords(@Nullable @Nullable String... keywords)
      Whether this Business contains any of the keywords in this array.
      Parameters:
      keywords - Keywords to check
      Returns:
      true if any keywords are present, else false
    • hasAnyKeywords

      public boolean hasAnyKeywords(@Nullable @Nullable Iterable<String> keywords)
      Whether this Business contains any of the keywords in this collection.
      Parameters:
      keywords - Keywords to check
      Returns:
      true if any keywords are present, else false
    • getAdvertisingBalancePlace

      public int getAdvertisingBalancePlace()
      Creates an integer representation of the place this Businesses is in, according to its Advertising Balance.
      Returns:
      Place in Advertising Balance
    • getTotalResources

      public int getTotalResources()
      Utility method for fetching BusinessStatistics.getTotalResources().
      Returns:
      Total Resources ever collected by this Business
    • getPublicIcon

      @NotNull public @NotNull ItemStack getPublicIcon()
      Creates a Public Icon for this Business.
      Returns:
      Generated Public Icon
    • getParentCorporation

      @Nullable public @Nullable Corporation getParentCorporation()
      Fetches the corporation that this Business belongs to.
      Returns:
      Parent Corporation, or null if none
    • leaveParentCorporation

      public void leaveParentCorporation() throws IllegalStateException
      Makes this Business leave its parent Corporation.
      Throws:
      IllegalStateException - if this Business is not in a Corporation
    • getCorporationJoinDate

      @Nullable public @Nullable Date getCorporationJoinDate()
      Fetches the date this Business joined its parent Corporation.
      Returns:
      Date joined, or null if not in a Corporation
    • getInvites

      @NotNull public @NotNull Set<CorporationInvite> getInvites()
      Fetches an immutable set of all of the Corporations this Business has been invited to.
      Returns:
      Set of Corporation Invites
    • randomAdvertisingBusiness

      @Nullable public static @Nullable Business randomAdvertisingBusiness()

      Fetches a random business based on its advertising balance.

      Will return null if NovaConfig.isAdvertisingEnabled() is false.

      Returns:
      Random Business