Class Corporation
java.lang.Object
us.teaminceptus.novaconomy.api.corporation.Corporation
Represents a Novaconomy Corporation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class used to create Corporationsstatic enumRepresents the joining type of a Corporation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length of a corporation descriptionstatic final intThe maximum amount of pending invites this Corporation can havestatic final intThe maximum level a of a corporationstatic final intThe maximum length of a corporation name -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a Business to this Corporation's children.voidaddExperience(double add) Adds experience to this Corporation.voidaddView()Adds a single view to this Corporation.voidaddView(long count) Adds a specific amount of views to this Corporation.voidawardAchievement(@NotNull CorporationAchievement achievement) Awards an Achievement to this Corporation, increasing its level by 1 and awarding the necessary experience.voidbroadcastMessage(@NotNull String message) Broadcasts a Message to all memebrs of the Corporation.static @NotNull Corporation.Builderbuilder()Creates a new Corporation Builder.static @Nullable CorporationFetches a Corporation by its ID.static @Nullable CorporationbyMember(@Nullable OfflinePlayer member) Fetches a Corporation by a member.static @Nullable CorporationFetches a Corporation by a member.static @Nullable CorporationFetches a Corporation by its name.static @Nullable CorporationbyOwner(@Nullable OfflinePlayer owner) Fetches a Corporation by its owner.voiddelete()Deletes this Corporation.booleanstatic booleanWhether a Corporation exists with the given name.static booleanWhether a Corporation exists with the given ID.static booleanexists(@Nullable OfflinePlayer owner) Whether a Corporation exists with the given owner.static booleanexistsByMember(@Nullable OfflinePlayer member) Whether the given member is in a Corporation.@org.jetbrains.annotations.NotNull intgetAchievementLevel(@NotNull CorporationAchievement achievement) Fetches an Corporation Achievement's level.@NotNull Map<CorporationAchievement,Integer> Fetches an immutable version of all of the Corporation's Achievements to their level.Fetches an immutable set of the Businesses this Corporation is responsible for.static @NotNull Set<Corporation>Fetches an immutable set of all of the corporations that exist.@NotNull DateFetches the date that this Corporation was created.@NotNull StringFetches the description of this Corporation.doubleFetches the amount of experience this Corporation has.@NotNull FileFetches the folder that this corporation's data is stored in.@Nullable LocationFetches the Location of this Corporation's Headquarters.@NotNull MaterialgetIcon()Fetches this Corporation's Icon.@Nullable CorporationInviteFetches this Businesses' CorporationInvite.Fetches an immutable set of all of the businesses invited to this Corporation.@NotNull DategetJoinDate(@NotNull Business b) Fetches the Date a Business joined this Corporation.intgetLevel()Fetches this Corporation's Level.intFetches the maximum amount of Children this Corporation can hold.@NotNull Set<OfflinePlayer>Fetches an immutable map of the Business Owners this Corporation is responsible for.@NotNull StringgetName()Fetches the name of this Corporation.@NotNull OfflinePlayergetOwner()Fetches the owner of this Corporation.doubleFetches the profit modifier when purchasing products from a Corporation's Child.Fetches this Corporation's Icon as an ItemStack.<T> TgetSetting(Settings.Corporation<T> setting) Fetches the value of a Corporation's setting.<T> TgetSetting(Settings.Corporation<T> setting, T def) Fetches the value of a Corporation's setting.@NotNull CorporationStatisticsFetches the Corporation's Statistic.@NotNull UUIDFetches the ID of this Corporation.longgetViews()Fetches how many views this Corporation has received.inthashCode()@NotNull CorporationInviteinviteBusiness(@NotNull Business b) Invites a Business to this Corporation.booleanWhether this Business has been invited to this Corporation.booleanisOwner(@Nullable OfflinePlayer owner) Whether the player is the owner of this Corporation.static voidReloads the Corporation Cache.voidremoveChild(@NotNull Business b) Removes a Business from this Corporation's children.static voidremoveCorporation(@NotNull Corporation c) Deletes a Corporation.voidremoveExperience(double remove) Removes experience from this Corporation.voidremoveInvite(@NotNull Business b) Removes an invite to this Corporation.voidSaves this Corporation to its Corporation file.voidsetDescription(@NotNull String description) Sets the description of this Corporation.voidsetExperience(double experience) Sets the amount of experience this Corporation has.voidsetHeadquarters(@Nullable Location headquarters) Sets the Location of this Corporation's Headquarters.voidSets this Corporation's Icon.voidsetLevel(int level) Sets this corporation's level, setting the experience to the minimum required.voidSets the name of this Corporation.<T> voidsetSetting(Settings.Corporation<T> setting, T value) Sets the value of a Corporation's setting.static doubletoExperience(int level) Converts the experience of a Corporation to a level.static inttoLevel(double experience) Converts the experience of a Corporation to a level.toString()
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHThe maximum length of a corporation name- See Also:
-
MAX_DESCRIPTION_LENGTH
public static final int MAX_DESCRIPTION_LENGTHThe maximum length of a corporation description- See Also:
-
MAX_LEVEL
public static final int MAX_LEVELThe maximum level a of a corporation- See Also:
-
MAX_INVITES
public static final int MAX_INVITESThe maximum amount of pending invites this Corporation can have- See Also:
-
-
Method Details
-
getUniqueId
Fetches the ID of this Corporation.- Returns:
- Corporation ID
-
getFolder
Fetches the folder that this corporation's data is stored in.- Returns:
- Corporation Folder
-
getCreationDate
Fetches the date that this Corporation was created.- Returns:
- Corporation Creation Date
-
getOwner
Fetches the owner of this Corporation.- Returns:
- Corporation Owner
-
isOwner
Whether the player is the owner of this Corporation.- Parameters:
owner- Player to check- Returns:
- true if player owns corporation, false otherwise
-
getChildren
Fetches an immutable set of the Businesses this Corporation is responsible for.- Returns:
- Business Children
-
getMaxChildren
public int getMaxChildren()Fetches the maximum amount of Children this Corporation can hold.- Returns:
- Maximum Children
-
getMembers
Fetches an immutable map of the Business Owners this Corporation is responsible for.- Returns:
- Business Owners
-
addChild
public void addChild(@NotNull @NotNull Business b) throws IllegalArgumentException, IllegalStateException Adds a Business to this Corporation's children.- Parameters:
b- Business to add- Throws:
IllegalArgumentException- if the Business already has a parent corporation, or is nullIllegalStateException- if the Corporation already has the maximum amount of children
-
removeChild
Removes a Business from this Corporation's children.- Parameters:
b- Business to remove- Throws:
IllegalArgumentException- if the Business is not a child of this Corporation, is null, or Business matches owner's business
-
getJoinDate
@NotNull public @NotNull Date getJoinDate(@NotNull @NotNull Business b) throws IllegalArgumentException Fetches the Date a Business joined this Corporation.- Parameters:
b- Business to fetch join date for- Returns:
- Business Join Date
- Throws:
IllegalArgumentException- if the Business is not a child of this Corporation, or is null
-
getName
Fetches the name of this Corporation.- Returns:
- Corporation Name
-
setName
Sets the name of this Corporation.- Parameters:
name- New Corporation Name- Throws:
IllegalArgumentException- if name is too long according toMAX_NAME_LENGTHor is null
-
getDescription
Fetches the description of this Corporation.- Returns:
- Corporation Description
-
setDescription
@NotNull public void setDescription(@NotNull @NotNull String description) throws IllegalArgumentException Sets the description of this Corporation.- Parameters:
description- New Corporation Description- Throws:
IllegalArgumentException- if description is too long according toMAX_DESCRIPTION_LENGTHor is null
-
getExperience
public double getExperience()Fetches the amount of experience this Corporation has.- Returns:
- Corporation Experience
-
setExperience
Sets the amount of experience this Corporation has.- Parameters:
experience- New Corporation Experience- Throws:
IllegalArgumentException- if experience is negative
-
addExperience
Adds experience to this Corporation.- Parameters:
add- Experience to add- Throws:
IllegalArgumentException- if result is negative
-
removeExperience
Removes experience from this Corporation.- Parameters:
remove- Experience to remove- Throws:
IllegalArgumentException- if result is negative
-
getLevel
public int getLevel()Fetches this Corporation's Level.- Returns:
- Corporation Level
-
setLevel
Sets this corporation's level, setting the experience to the minimum required.- Parameters:
level- New Corporation Level- Throws:
IllegalArgumentException- if level is not postiive
-
getIcon
Fetches this Corporation's Icon.- Returns:
- Corporation Icon
-
setIcon
Sets this Corporation's Icon.- Parameters:
icon- New Corporation Icon- Throws:
IllegalArgumentException- if icon is null
-
getPublicIcon
Fetches this Corporation's Icon as an ItemStack.- Returns:
- Corporation Icon
-
getHeadquarters
Fetches the Location of this Corporation's Headquarters.- Returns:
- Corporation Headquarters
-
setHeadquarters
Sets the Location of this Corporation's Headquarters.- Parameters:
headquarters- New Corporation Headquarters- Throws:
IllegalStateException- if Corporation is less than 5
-
getAchievements
Fetches an immutable version of all of the Corporation's Achievements to their level.- Returns:
- Corporation Achievements
-
getAchievementLevel
@NotNull public @org.jetbrains.annotations.NotNull int getAchievementLevel(@NotNull @NotNull CorporationAchievement achievement) Fetches an Corporation Achievement's level.- Parameters:
achievement- Achievement to fetch- Returns:
- Achievement Level
-
awardAchievement
@NotNull public void awardAchievement(@NotNull @NotNull CorporationAchievement achievement) throws IllegalArgumentException Awards an Achievement to this Corporation, increasing its level by 1 and awarding the necessary experience.- Parameters:
achievement- Achievement to award- Throws:
IllegalArgumentException- if achievement is null, or achievement is already at max level
-
getStatistics
Fetches the Corporation's Statistic.- Returns:
- Corporation Statistics
-
delete
public void delete()Deletes this Corporation. -
getViews
public long getViews()Fetches how many views this Corporation has received.- Returns:
- Corporation Views
-
addView
public void addView(long count) Adds a specific amount of views to this Corporation.- Parameters:
count- Views to add
-
addView
public void addView()Adds a single view to this Corporation. -
getProfitModifier
public double getProfitModifier()Fetches the profit modifier when purchasing products from a Corporation's Child.- Returns:
- Profit Modifier
-
getSetting
Fetches the value of a Corporation's setting.- Type Parameters:
T- Setting Type- Parameters:
setting- Setting to fetch- Returns:
- Setting Value, or null if not found
-
getSetting
Fetches the value of a Corporation's setting.- Type Parameters:
T- Setting Type- Parameters:
setting- Setting to fetchdef- Default value to return if setting is not found- Returns:
- Setting Value, or default value if not found
-
setSetting
public <T> void setSetting(@NotNull Settings.Corporation<T> setting, @NotNull T value) throws IllegalArgumentException Sets the value of a Corporation's setting.- Type Parameters:
T- Setting Type- Parameters:
setting- Setting to setvalue- New value of setting- Throws:
IllegalArgumentException- if setting or value is null, or value is not a valid value for this setting
-
getInvited
Fetches an immutable set of all of the businesses invited to this Corporation.- Returns:
- Businesses invited to this Corporation
- Throws:
IllegalStateException- if Corporation is not invite only
-
isInvited
Whether this Business has been invited to this Corporation.- Parameters:
b- Business to check- Returns:
- true if Business has been invited, false otherwise
- Throws:
IllegalArgumentException- if business is null
-
removeInvite
Removes an invite to this Corporation.- Parameters:
b- Business to remove invite from- Throws:
IllegalArgumentException- if business is null, or business is not invited to this Corporation
-
getInvite
@Nullable public @Nullable CorporationInvite getInvite(@NotNull @NotNull Business b) throws IllegalArgumentException Fetches this Businesses' CorporationInvite.- Parameters:
b- Business to fetch invite for- Returns:
- CorporationInvite, or null if Business is not invited
- Throws:
IllegalArgumentException- if business is null
-
inviteBusiness
@NotNull public @NotNull CorporationInvite inviteBusiness(@NotNull @NotNull Business b) throws IllegalArgumentException, IllegalStateException Invites a Business to this Corporation.- Parameters:
b- Business to invite- Returns:
- CorporationInvite Object
- Throws:
IllegalArgumentException- if business is null, business is already apart of this Corporation, or has already been invitedIllegalStateException- if Corporation is not invite only or invite count is aboveMAX_INVITES
-
broadcastMessage
Broadcasts a Message to all memebrs of the Corporation.- Parameters:
message- Message to broadcast- Throws:
IllegalArgumentException- if message is null
-
equals
-
hashCode
public int hashCode() -
toString
-
reloadCorporations
public static void reloadCorporations()Reloads the Corporation Cache. -
getCorporations
Fetches an immutable set of all of the corporations that exist.- Returns:
- All Corporations
-
byName
Fetches a Corporation by its name.- Parameters:
name- Corporation Name- Returns:
- Corporation found, or null if not found
-
byId
Fetches a Corporation by its ID.- Parameters:
id- Corporation ID- Returns:
- Corporation found, or null if not found
-
byOwner
Fetches a Corporation by its owner.- Parameters:
owner- Corporation Owner- Returns:
- Corporation found, or null if not found
-
byMember
Fetches a Corporation by a member.- Parameters:
member- Corporation Member- Returns:
- Corporation found, or null if not found
-
byMember
Fetches a Corporation by a member.- Parameters:
child- Corporation Member as a Business- Returns:
- Corporation found, or null if not found
-
exists
Whether a Corporation exists with the given name.- Parameters:
name- Corporation Name- Returns:
- true if exists, false otherwise
-
exists
Whether a Corporation exists with the given ID.- Parameters:
id- Corporation ID- Returns:
- true if exists, false otherwise
-
exists
Whether a Corporation exists with the given owner.- Parameters:
owner- Corporation Owner- Returns:
- true if exists, false otherwise
-
existsByMember
Whether the given member is in a Corporation.- Parameters:
member- Corporation Member- Returns:
- true if member is in a corporation, false otherwise
-
removeCorporation
Deletes a Corporation.- Parameters:
c- Corporation to delete
-
toExperience
Converts the experience of a Corporation to a level.- Parameters:
level- Level to convert to- Returns:
- Minimum Experience required for the specified level
- Throws:
IllegalArgumentException- if level is not positive
-
toLevel
Converts the experience of a Corporation to a level.- Parameters:
experience- Experience to convert to- Returns:
- Level conversion at the specified experience
- Throws:
IllegalArgumentException- if experience is not positive
-
builder
Creates a new Corporation Builder.- Returns:
- New Corporation Builder
-
saveCorporation
public void saveCorporation()Saves this Corporation to its Corporation file.
This method is called automatically.
-