java.lang.Object
us.teaminceptus.novaconomy.api.economy.Economy
All Implemented Interfaces:
Comparable<Economy>, ConfigurationSerializable

public final class Economy extends Object implements ConfigurationSerializable, Comparable<Economy>
Represents an Economy
  • Field Details

    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      The maximum length of an Economy name
      See Also:
    • MAX_CONVERSION_SCALE

      public static final double MAX_CONVERSION_SCALE
      The maximum amount of a conversion scale
      See Also:
  • Method Details

    • hasInterest

      public boolean hasInterest()
      Whether this Economy supports interest
      Returns:
      true if allows, else false
    • getInterestEconomies

      @NotNull public static @NotNull Set<Economy> getInterestEconomies()
      Fetch a set of all economies supporting interest
      Returns:
      Set of Interest Economies
    • getTaxableEconomies

      @NotNull public static @NotNull Set<Economy> getTaxableEconomies()
      Fetches a set of Economies that have hasTax() to true.
      Returns:
      Set of Taxable Economies
    • getClickableRewardEconomies

      @NotNull public static @NotNull Set<Economy> getClickableRewardEconomies()
      Fetches a set of Economies that have hasClickableReward() to true.
      Returns:
      Set of Economies that can be rewarded on click
    • hasClickableReward

      public boolean hasClickableReward()
      Whether this Economy is rewarded when a business is clicked on when advertising.
      Returns:
      true if rewarded, else false
    • setInterest

      public void setInterest(boolean interest)
      Set the interest acception state of this economy
      Parameters:
      interest - Whether to allow interest
    • setCustomModelData

      public void setCustomModelData(int customModelData)
      Sets the custom model data integer of this economy
      Parameters:
      customModelData - Custom Model Data
    • setName

      public void setName(@NotNull @NotNull String name)
      Sets the economy's name.
      Parameters:
      name - Name of the economy
    • setIcon

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

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

      public void setIncreaseNaturally(boolean increase)
      Sets whether this economy naturally increases.
      Parameters:
      increase - Whether to increase naturally
    • setConversionScale

      public void setConversionScale(double scale) throws IllegalArgumentException
      Sets the conversion scale of this Economy.
      Parameters:
      scale - Conversion Scale
      Throws:
      IllegalArgumentException - if scale is less than 0
    • setHasClickableReward

      public void setHasClickableReward(boolean clickable)
      Sets whether this economy is rewarded by clicking on a business icon when advertising.
      Parameters:
      clickable - true if clickable, else false
    • hasTax

      public boolean hasTax()
      Whether this Economy is taxable.

      This value is not serialized with the Economy and is changable from config.yml.
      Returns:
      true if taxable, else false
    • setTax

      public boolean setTax(boolean tax)
      Sets whether this Economy is taxable.

      This value is not serialized with the Economy and is changable from config.yml.
      Parameters:
      tax - Whether to allow tax
      Returns:
      true if successful, else false
    • removeEconomy

      public static void removeEconomy(@NotNull @NotNull String name)
      Remove an Economy from the Plugin
      Parameters:
      name - Name of the Economy
      See Also:
    • removeEconomy

      public static void removeEconomy(@Nullable @Nullable Economy econ) throws IllegalArgumentException
      Remove an Economy from the Plugin
      Parameters:
      econ - Economy to remove
      Throws:
      IllegalArgumentException - if economy is null
    • getEconomy

      @Nullable public static @Nullable Economy getEconomy(@NotNull @NotNull String name) throws IllegalArgumentException
      Fetch an Economy
      Parameters:
      name - Name of the Economy
      Returns:
      Found Economy, or null if none found
      Throws:
      IllegalArgumentException - if name is null
    • exists

      public static boolean exists(@Nullable @Nullable String name)
      Whether this Economy exists.
      Parameters:
      name - Name of the Economy
      Returns:
      true if economy exists, else false
    • exists

      public static boolean exists(@Nullable @Nullable UUID uid)
      Whetehr an economy with this UUID exists.
      Parameters:
      uid - UUID of the Economy
      Returns:
      true if economy exists, else false
    • exists

      public static boolean exists(char c)
      Whether an Economy with this symbol exists.
      Parameters:
      c - Symbol of the economy
      Returns:
      true if economy exists, else false`
    • hasNaturalIncrease

      public boolean hasNaturalIncrease()
      Whether this economy will naturally increase (not the same as Interest)

      An economy increasing naturally means that it increases from NaturalCauses (i.e. Mining, Fishing). Specific events can be turned off in the configuration.

      Death Decrease applies to ALL Economies, so turn it off globally if you don't want that.

      Returns:
      true if naturally increases, else false
    • getConversionScale

      public double getConversionScale()
      Return the scale of which this economy will be converted to a different economy

      An economy with a conversion scale of 1 and another with a conversion scale of 0.5 would have a 2:1 ratio, meaning that 100 in the first economy would be 200 in the second economy.

      Returns:
      conversion scale of this economy
    • reloadEconomies

      public static void reloadEconomies()
      Reloads the Economy Cache.
    • getEconomies

      @NotNull public static @NotNull Set<Economy> getEconomies()
      Fetch a set of all economies registered on the Plugin
      Returns:
      Set of Registered Economies
    • getNaturalEconomies

      public static Set<Economy> getNaturalEconomies()
      Fetch a set of economies that increase naturally
      Returns:
      Set of Economies that increase naturally
    • getEconomySection

      @Deprecated public ConfigurationSection getEconomySection()
      Deprecated.
      Economies are no longer stored in an individual file
      Return the ConfigurationSection that this Economy is stored in
      Returns:
      ConfigurationSection of this economy
    • getName

      public String getName()
      Fetch the name of this economy
      Returns:
      Name of this economy
    • getSymbol

      public char getSymbol()
      Fetches the economy's symbol.
      Returns:
      Symbol of Economy
    • getIcon

      public ItemStack getIcon()
      Get the Icon of this Economy
      Returns:
      Icon of this Economy
    • getIconType

      public Material getIconType()
      Gets the Economy Icon's Type.
      Returns:
      Icon Material Type
    • convertAmount

      public double convertAmount(Economy to, double fromAmount) throws IllegalArgumentException
      Convert this economy to another economy
      Parameters:
      to - The New Economy to convert to
      fromAmount - How much amount is to be converted
      Returns:
      Converted amount in the other economy's form
      Throws:
      IllegalArgumentException - if to or from is null, or economies are identical
      See Also:
    • getUniqueId

      @NotNull public @NotNull UUID getUniqueId()
      Get the Economy's unique identifier.
      Returns:
      Unique Identifier
    • convertAmount

      public static double convertAmount(Economy from, Economy to, double fromAmount) throws IllegalArgumentException
      Convert one economy's balance to another
      Parameters:
      from - The Economy to convert from
      to - The Economy to convert to
      fromAmount - How much amount is to be converted
      Returns:
      Converted amount in the other economy's form
      Throws:
      IllegalArgumentException - if to or from is null, or economies are identical
    • getEconomy

      @Nullable public static @Nullable Economy getEconomy(@Nullable @Nullable UUID uid)
      Attempts to lookup an Economy by its unique id.
      Parameters:
      uid - UUID to find
      Returns:
      Economy found, or null if not found or if UUID is null
    • getCustomModelData

      public int getCustomModelData()
      Fetches the custom model data integer for this Economy.
      Returns:
      Custom Model Data Integer
    • getEconomy

      @Nullable public static @Nullable Economy getEconomy(char symbol)
      Fetches an Economy by its unique symbol.
      Parameters:
      symbol - Symbol to find
      Returns:
      Economy found, or null if not found
    • builder

      public static Economy.Builder builder()
      Fetch a Builder used for creating economies
      Returns:
      Economy.Builder Class
    • equals

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

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

      public int compareTo(@NotNull @NotNull Economy o)
      Specified by:
      compareTo in interface Comparable<Economy>
    • toString

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

      public void saveEconomy()
      Saves this Economy to its file.
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      Serialization inside a YML File
      Specified by:
      serialize in interface ConfigurationSerializable
      Returns:
      Serialized Economy
    • deserialize

      public static Economy deserialize(@Nullable @Nullable Map<String,Object> serial) throws NullPointerException
      Serialization from a YML File

      This method is only meant to take maps from serialize(). **Using Maps outside of this may break the plugin**.

      Parameters:
      serial - Map of serialization
      Returns:
      Economy Class
      Throws:
      NullPointerException - if a necessary part is missing
      See Also: