Class Business
java.lang.Object
us.teaminceptus.novaconomy.api.business.Business
- All Implemented Interfaces:
ConfigurationSerializable
Represents a Novaconomy Business
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a Business Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length of a business keyword.static final intThe maximum number of keywords a Business can have.static final intThe maximum length of a Business Name. -
Method Summary
Modifier and TypeMethodDescription@NotNull BusinessaddAdvertisingBalance(double amount) Adds to the Business's Advertising Balance.@NotNull BusinessaddAdvertisingBalance(double amount, @Nullable Economy econ) Adds to the Business's Advertising Balance.@NotNull BusinessaddAdvertisingBalance(@Nullable Price price) Adds to the Business's Advertising Balance.voidaddKeywords(@Nullable Iterable<String> keywords) Adds a collection of keywords to the Business.voidaddKeywords(@Nullable String... keywords) Adds keywords to the Business.@NotNull BusinessaddProduct(@Nullable Collection<? extends Product> products) Adds a Collection of Products to this Business.@NotNull BusinessaddProduct(@Nullable Product... products) Adds an Array of Products to this Business.@NotNull BusinessaddResource(@Nullable Iterable<? extends ItemStack> resources) Adds a Collection of Resources available for purchase from this Business.@NotNull BusinessaddResource(@Nullable ItemStack... items) Adds Resources available for purchase from this Business.@NotNull BusinessAdds a Business to this Business's blacklist.static Business.Builderbuilder()Fetches the Business Builder.static @Nullable BusinessFetches a Business by its unique ID.static @Nullable BusinessFetches a Business by its name.static @Nullable BusinessbyOwner(@Nullable OfflinePlayer p) Fetches a Business by its Owner.static @Nullable Businessdeserialize(@Nullable Map<String, Object> serial) Deprecated.Entire Bukkit Serialization is no longer used; this method exists only for the purposes of converting legacy businessesbooleanstatic booleanexists()Utility method to check if any Businesses currently exist.static booleanChecks whether this Business exists.static booleanChecks whether this Business exists.static booleanexists(@Nullable OfflinePlayer p) Checks whether this Business exists.doubleFetches the Business's Advertising Balance.intCreates an integer representation of the place this Businesses is in, according to its Advertising Balance.doubleFetches the average rating level for this Business.Fetches a list of all Businesses that are prohibited from associating with this Business, such as with Advertising.Fetches an immutable version of all registered Businesses.@NotNull FileFetches the folder this Business is stored in, ifNovaConfig.isDatabaseEnabled()is false.@Nullable DateFetches the date this Business joined its parent Corporation.@NotNull DateFetches the Business's Creation Date.@Nullable LocationgetHome()Fetches the Business's Home Location.@NotNull ItemStackgetIcon()Fetches this Business's Icon.@NotNull Set<CorporationInvite>Fetches an immutable set of all of the Corporations this Business has been invited to.Fetches an immutable version of the Business's Keywords.Fetches any extra stock that are no longer products in the Business.@NotNull StringgetName()Fetches the Business's Name.@NotNull OfflinePlayergetOwner()Fetches the Business's Owner.@Nullable CorporationFetches the corporation that this Business belongs to.@Nullable BusinessProductgetProduct(@Nullable ItemStack item) Fetches a BusinessProduct by its Item.@NotNull List<BusinessProduct>Fetches the List of Products this Business is selling.Shortcut method toBusinessStatistics.getProductSales().@NotNull ItemStackCreates a Public Icon for this Business.intgetPurchaseCount(@NotNull Product p) Shortcut method toBusinessStatistics.getPurchaseCount(Product).Fetches a list of all ratings for this Business.Returns an immutable version of Business's Resources available for selling via Products.booleangetSetting(Settings.Business setting) Fetches a Setting Value for this Business.@NotNull Map<Settings.Business,Boolean> Fetches an immutable version of all of the settings on this business.@NotNull BusinessStatisticsFetches the Business's Statistics.intUtility method for fetchingBusinessStatistics.getTotalResources().doubleFetches the total amount of money this Business has earned, accounting for conversion scales.intgetTotalStock(@Nullable ItemStack item) Fetches the total stock amount of this item.@NotNull UUIDFetches the Business's Unique ID.booleanhasAllKeywords(@Nullable Iterable<String> keywords) Whether this Business contains all of the keywords in this collection.booleanhasAllKeywords(@Nullable String... keywords) Whether this Business contains all of the keywords in this array.booleanhasAnyKeywords(@Nullable Iterable<String> keywords) Whether this Business contains any of the keywords in this collection.booleanhasAnyKeywords(@Nullable String... keywords) Whether this Business contains any of the keywords in this array.inthashCode()booleanhasHome()Whether this Busienss has a home set.booleanisBlacklisted(@NotNull Business business) Checks whether a Business is blacklisted from associating with this Business.booleanWhether this item is in stock.booleanWhether a Resource matching this Material is in stock.booleanisOwner(@Nullable OfflinePlayer p) Whether this Player is the owner of this Business.booleanWhether this Item is a Registered Product.booleanWhether one of the products has this Material as its product.voidMakes this Business leave its parent Corporation.static @Nullable BusinessFetches a random business based on its advertising balance.static voidReloads the Business Cache.static voidDeletes a Business.@NotNull BusinessremoveAdvertisingBalance(double amount) Removes from the Business's Advertising Balance.@NotNull BusinessremoveAdvertisingBalance(double amount, @Nullable Economy econ) Removes from the Business's Advertising Balance.@NotNull BusinessremoveAdvertisingBalance(@Nullable Price p) Removes from the Business's Advertising Balance.voidremoveKeywords(@Nullable Iterable<String> keywords) Removes a collection of keywords from the Business.voidremoveKeywords(@Nullable String... keywords) Removes keywords from the Business.@NotNull BusinessremoveProduct(@Nullable Iterable<? extends BusinessProduct> products) Removes an iterable of Products from this Business.@NotNull BusinessremoveProduct(@Nullable ItemStack... items) Removes an Array of ItemStacks from this Business's Products.@NotNull BusinessremoveProduct(@Nullable BusinessProduct... products) Removes an Array of Products from this Business.@NotNull BusinessremoveResource(@Nullable Iterable<? extends ItemStack> resources) Removes an iterable of Resources from this Business.@NotNull BusinessremoveResource(@Nullable ItemStack... resources) Removes an Array of Resources from this Business.voidSaves this Business ingetBusinessFolder().Deprecated.@NotNull BusinesssetAdvertisingBalance(double advertisingBalance) Sets the Business's Advertising Balance.voidSets the Business's Home Location.voidSets the icon of this Business.voidSets the name of this Business.@NotNull BusinesssetSetting(Settings.Business setting, boolean value) Sets a Setting Value for this Business.toString()@NotNull Businessunblacklist(@NotNull Business business) Removes a Business from this Business's blacklist.
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHThe maximum length of a Business Name.- See Also:
-
MAX_KEYWORDS
public static final int MAX_KEYWORDSThe maximum number of keywords a Business can have.- See Also:
-
MAX_KETWORD_LENGTH
public static final int MAX_KETWORD_LENGTHThe maximum length of a business keyword.- See Also:
-
-
Method Details
-
builder
Fetches the Business Builder.- Returns:
- Business Builder
-
getOwner
Fetches the Business's Owner.- Returns:
- Business Owner
-
getName
Fetches the Business's Name.- Returns:
- Business Name
-
getUniqueId
Fetches the Business's Unique ID.- Returns:
- Business ID
-
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
Sets the Business's Home Location.- Parameters:
home- Business Home Location
-
setIcon
Sets the icon of this Business.- Parameters:
icon- Business Icon- Throws:
IllegalArgumentException- if icon is null
-
setName
Sets the name of this Business.- Parameters:
name- Business Name- Throws:
IllegalArgumentException- if name is null or empty
-
isOwner
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
Fetches the List of Products this Business is selling.- Returns:
- Products to add
-
serialize
Deprecated.- Specified by:
serializein interfaceConfigurationSerializable
-
addResource
Adds Resources available for purchase from this Business.- Parameters:
items- Items to add- Returns:
- this Business, for chaining
-
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
Whether this item is in stock.- Parameters:
item- Item to test- Returns:
- true if item is in stock, else false
-
getTotalStock
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
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
Removes an Array of Products from this Business.- Parameters:
products- Business Products to Remove- Returns:
- this Business, for chaining
-
removeProduct
Removes an Array of ItemStacks from this Business's Products.- Parameters:
items- Products to Remove- Returns:
- this Business, for chaining
-
removeResource
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
Whether this Item is a Registered Product.- Parameters:
i- Item to test- Returns:
- true if item is product, else false
-
isProduct
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
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
Adds an Array of Products to this Business.- Parameters:
products- Products to Add- Returns:
- this Business, for chaining
-
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
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
Fetches a Setting Value for this Business.- Parameters:
setting- Setting to check- Returns:
- Setting Value, or false if setting is null
-
getSettings
Fetches an immutable version of all of the settings on this business.- Returns:
- Immutable Map of Settings
-
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
Sets a Setting Value for this Business.- Parameters:
setting- Setting to setvalue- Value of the new setting- Returns:
- this Business, for chaining
-
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
Checks whether a Business is blacklisted from associating with this Business.- Parameters:
business- Business to check- Returns:
- true if blacklisted, else false
-
unblacklist
Removes a Business from this Business's blacklist.- Parameters:
business- Business to remove- Returns:
- this Business, for chaining
-
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 businessesDeserializes a Map into a Business.- Parameters:
serial- Serialization fromserialize()- 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
Fetches the folder this Business is stored in, ifNovaConfig.isDatabaseEnabled()is false.- Returns:
- Business Folder
-
saveBusiness
public void saveBusiness()Saves this Business ingetBusinessFolder(). -
reloadBusinesses
public static void reloadBusinesses()Reloads the Business Cache. -
getBusinesses
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
Fetches a Business by its name.- Parameters:
name- Business Name- Returns:
- Found business, or null if not found
-
byOwner
Fetches a Business by its Owner.- Parameters:
p- Owner of Business- Returns:
- Found business, or null if not found / Player is null
-
remove
Deletes a Business.- Parameters:
b- Business to remove
-
exists
Checks whether this Business exists.- Parameters:
name- Business name- Returns:
- true if business exists, else false
-
getAdvertisingBalance
public double getAdvertisingBalance()Fetches the Business's Advertising Balance.- Returns:
- Advertising Balance
-
setAdvertisingBalance
Sets the Business's Advertising Balance.- Parameters:
advertisingBalance- Advertising Balance- Returns:
- this business, for chaining
-
addAdvertisingBalance
Adds to the Business's Advertising Balance.- Parameters:
amount- Amount to add- Returns:
- this business, for chaining
-
addAdvertisingBalance
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 addecon- Economy to use with the Conversion Scale- Returns:
- this business, for chaining
-
removeAdvertisingBalance
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 removeecon- Economy to use with the Conversion Scale- Returns:
- this business, for chaining
-
removeAdvertisingBalance
Removes from the Business's Advertising Balance.- Parameters:
p- Price to remove- Returns:
- this business, for chaining
-
equals
-
toString
-
hashCode
public int hashCode() -
exists
Checks whether this Business exists.- Parameters:
uid- Business ID- Returns:
- true if business exists, else false
-
exists
Checks whether this Business exists.- Parameters:
p- Owner of Business- Returns:
- true if business exists, else false
-
getStatistics
Fetches the Business's Statistics.- Returns:
- Business Statistics
-
getProductSales
Shortcut method toBusinessStatistics.getProductSales().- Returns:
- Product Sales
-
getPurchaseCount
Shortcut method toBusinessStatistics.getPurchaseCount(Product).- Parameters:
p- Product to check- Returns:
- Purchase Count, or 0 if none
-
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
Fetches an immutable version of the Business's Keywords.- Returns:
- Business Keywords
-
addKeywords
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
Removes keywords from the Business.- Parameters:
keywords- Keywords to remove
-
removeKeywords
Removes a collection of keywords from the Business.- Parameters:
keywords- Keywords to remove
-
hasAllKeywords
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
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
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
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 fetchingBusinessStatistics.getTotalResources().- Returns:
- Total Resources ever collected by this Business
-
getPublicIcon
Creates a Public Icon for this Business.- Returns:
- Generated Public Icon
-
getParentCorporation
Fetches the corporation that this Business belongs to.- Returns:
- Parent Corporation, or null if none
-
leaveParentCorporation
Makes this Business leave its parent Corporation.- Throws:
IllegalStateException- if this Business is not in a Corporation
-
getCorporationJoinDate
Fetches the date this Business joined its parent Corporation.- Returns:
- Date joined, or null if not in a Corporation
-
getInvites
Fetches an immutable set of all of the Corporations this Business has been invited to.- Returns:
- Set of Corporation Invites
-
randomAdvertisingBusiness
Fetches a random business based on its advertising balance.
Will return null if
NovaConfig.isAdvertisingEnabled()is false.- Returns:
- Random Business
-