Class Corporation

java.lang.Object
us.teaminceptus.novaconomy.api.corporation.Corporation

public final class Corporation extends Object
Represents a Novaconomy Corporation
  • Field Details

    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      The maximum length of a corporation name
      See Also:
    • MAX_DESCRIPTION_LENGTH

      public static final int MAX_DESCRIPTION_LENGTH
      The maximum length of a corporation description
      See Also:
    • MAX_LEVEL

      public static final int MAX_LEVEL
      The maximum level a of a corporation
      See Also:
    • MAX_INVITES

      public static final int MAX_INVITES
      The maximum amount of pending invites this Corporation can have
      See Also:
  • Method Details

    • getUniqueId

      @NotNull public @NotNull UUID getUniqueId()
      Fetches the ID of this Corporation.
      Returns:
      Corporation ID
    • getFolder

      @NotNull public @NotNull File getFolder()
      Fetches the folder that this corporation's data is stored in.
      Returns:
      Corporation Folder
    • getCreationDate

      @NotNull public @NotNull Date getCreationDate()
      Fetches the date that this Corporation was created.
      Returns:
      Corporation Creation Date
    • getOwner

      @NotNull public @NotNull OfflinePlayer getOwner()
      Fetches the owner of this Corporation.
      Returns:
      Corporation Owner
    • isOwner

      public boolean isOwner(@Nullable @Nullable OfflinePlayer owner)
      Whether the player is the owner of this Corporation.
      Parameters:
      owner - Player to check
      Returns:
      true if player owns corporation, false otherwise
    • getChildren

      @NotNull public @NotNull Set<Business> 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

      @NotNull public @NotNull Set<OfflinePlayer> 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 null
      IllegalStateException - if the Corporation already has the maximum amount of children
    • removeChild

      public void removeChild(@NotNull @NotNull Business b) throws IllegalArgumentException
      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

      @NotNull public @NotNull String getName()
      Fetches the name of this Corporation.
      Returns:
      Corporation Name
    • setName

      public void setName(@NotNull @NotNull String name) throws IllegalArgumentException
      Sets the name of this Corporation.
      Parameters:
      name - New Corporation Name
      Throws:
      IllegalArgumentException - if name is too long according to MAX_NAME_LENGTH or is null
    • getDescription

      @NotNull public @NotNull String 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 to MAX_DESCRIPTION_LENGTH or is null
    • getExperience

      public double getExperience()
      Fetches the amount of experience this Corporation has.
      Returns:
      Corporation Experience
    • setExperience

      public void setExperience(double experience) throws IllegalArgumentException
      Sets the amount of experience this Corporation has.
      Parameters:
      experience - New Corporation Experience
      Throws:
      IllegalArgumentException - if experience is negative
    • addExperience

      public void addExperience(double add) throws IllegalArgumentException
      Adds experience to this Corporation.
      Parameters:
      add - Experience to add
      Throws:
      IllegalArgumentException - if result is negative
    • removeExperience

      public void removeExperience(double remove) throws IllegalArgumentException
      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

      public void setLevel(int level) throws IllegalArgumentException
      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

      @NotNull public @NotNull Material getIcon()
      Fetches this Corporation's Icon.
      Returns:
      Corporation Icon
    • setIcon

      public void setIcon(@NotNull @NotNull Material icon) throws IllegalArgumentException
      Sets this Corporation's Icon.
      Parameters:
      icon - New Corporation Icon
      Throws:
      IllegalArgumentException - if icon is null
    • getPublicIcon

      public ItemStack getPublicIcon()
      Fetches this Corporation's Icon as an ItemStack.
      Returns:
      Corporation Icon
    • getHeadquarters

      @Nullable public @Nullable Location getHeadquarters()
      Fetches the Location of this Corporation's Headquarters.
      Returns:
      Corporation Headquarters
    • setHeadquarters

      public void setHeadquarters(@Nullable @Nullable Location headquarters) throws IllegalStateException
      Sets the Location of this Corporation's Headquarters.
      Parameters:
      headquarters - New Corporation Headquarters
      Throws:
      IllegalStateException - if Corporation is less than 5
    • getAchievements

      @NotNull public @NotNull Map<CorporationAchievement,Integer> 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

      @NotNull public @NotNull CorporationStatistics 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

      @Nullable public <T> T getSetting(@NotNull Settings.Corporation<T> setting)
      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

      @Nullable public <T> T getSetting(@NotNull Settings.Corporation<T> setting, @Nullable T def)
      Fetches the value of a Corporation's setting.
      Type Parameters:
      T - Setting Type
      Parameters:
      setting - Setting to fetch
      def - 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 set
      value - New value of setting
      Throws:
      IllegalArgumentException - if setting or value is null, or value is not a valid value for this setting
    • getInvited

      @NotNull public @NotNull Set<Business> getInvited() throws IllegalStateException
      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

      public boolean isInvited(@NotNull @NotNull Business b) throws IllegalArgumentException
      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

      public void removeInvite(@NotNull @NotNull Business b) throws IllegalArgumentException
      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 invited
      IllegalStateException - if Corporation is not invite only or invite count is above MAX_INVITES
    • broadcastMessage

      public void broadcastMessage(@NotNull @NotNull String message) throws IllegalArgumentException
      Broadcasts a Message to all memebrs of the Corporation.
      Parameters:
      message - Message to broadcast
      Throws:
      IllegalArgumentException - if message is null
    • 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
    • reloadCorporations

      public static void reloadCorporations()
      Reloads the Corporation Cache.
    • getCorporations

      @NotNull public static @NotNull Set<Corporation> getCorporations()
      Fetches an immutable set of all of the corporations that exist.
      Returns:
      All Corporations
    • byName

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

      @Nullable public static @Nullable Corporation byId(@Nullable @Nullable UUID id)
      Fetches a Corporation by its ID.
      Parameters:
      id - Corporation ID
      Returns:
      Corporation found, or null if not found
    • byOwner

      @Nullable public static @Nullable Corporation byOwner(@Nullable @Nullable OfflinePlayer owner)
      Fetches a Corporation by its owner.
      Parameters:
      owner - Corporation Owner
      Returns:
      Corporation found, or null if not found
    • byMember

      @Nullable public static @Nullable Corporation byMember(@Nullable @Nullable OfflinePlayer member)
      Fetches a Corporation by a member.
      Parameters:
      member - Corporation Member
      Returns:
      Corporation found, or null if not found
    • byMember

      @Nullable public static @Nullable Corporation byMember(@Nullable @Nullable Business child)
      Fetches a Corporation by a member.
      Parameters:
      child - Corporation Member as a Business
      Returns:
      Corporation found, or null if not found
    • exists

      public static boolean exists(@Nullable @Nullable String name)
      Whether a Corporation exists with the given name.
      Parameters:
      name - Corporation Name
      Returns:
      true if exists, false otherwise
    • exists

      public static boolean exists(@Nullable @Nullable UUID id)
      Whether a Corporation exists with the given ID.
      Parameters:
      id - Corporation ID
      Returns:
      true if exists, false otherwise
    • exists

      public static boolean exists(@Nullable @Nullable OfflinePlayer owner)
      Whether a Corporation exists with the given owner.
      Parameters:
      owner - Corporation Owner
      Returns:
      true if exists, false otherwise
    • existsByMember

      public static boolean existsByMember(@Nullable @Nullable OfflinePlayer member)
      Whether the given member is in a Corporation.
      Parameters:
      member - Corporation Member
      Returns:
      true if member is in a corporation, false otherwise
    • removeCorporation

      public static void removeCorporation(@NotNull @NotNull Corporation c)
      Deletes a Corporation.
      Parameters:
      c - Corporation to delete
    • toExperience

      public static double toExperience(int level) throws IllegalArgumentException
      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

      public static int toLevel(double experience) throws IllegalArgumentException
      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

      @NotNull public static @NotNull Corporation.Builder 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.