Class Economy
java.lang.Object
us.teaminceptus.novaconomy.api.economy.Economy
- All Implemented Interfaces:
Comparable<Economy>,ConfigurationSerializable
Represents an Economy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classClass used for Creating Economies -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe maximum amount of a conversion scalestatic final intThe maximum length of an Economy name -
Method Summary
Modifier and TypeMethodDescriptionstatic Economy.Builderbuilder()Fetch a Builder used for creating economiesintdoubleconvertAmount(@NotNull Economy to, double fromAmount) Convert this economy to another economystatic doubleconvertAmount(@NotNull Economy from, @NotNull Economy to, double fromAmount) Convert one economy's balance to anotherstatic Economydeserialize(@Nullable Map<String, Object> serial) Serialization from a YML Filebooleanstatic booleanexists(char c) Whether an Economy with this symbol exists.static booleanWhether this Economy exists.static booleanWhetehr an economy with this UUID exists.Fetches a set of Economies that havehasClickableReward()to true.doubleReturn the scale of which this economy will be converted to a different economyintFetches the custom model data integer for this Economy.Fetch a set of all economies registered on the Pluginstatic @Nullable EconomygetEconomy(char symbol) Fetches an Economy by its unique symbol.static @Nullable EconomygetEconomy(@NotNull String name) Fetch an Economystatic @Nullable EconomygetEconomy(@Nullable UUID uid) Attempts to lookup an Economy by its unique id.Deprecated.Economies are no longer stored in an individual file@NotNull ItemStackgetIcon()Get the Icon of this Economy@NotNull MaterialGets the Economy Icon's Type.Fetch a set of all economies supporting interest@NotNull StringgetName()Fetch the name of this economyFetch a set of economies that increase naturallycharFetches the economy's symbol.Fetches a set of Economies that havehasTax()to true.@NotNull UUIDGet the Economy's unique identifier.booleanWhether this Economy is rewarded when a business is clicked on when advertising.inthashCode()booleanWhether this Economy supports interestbooleanWhether this economy will naturally increase (not the same as Interest)booleanhasTax()Whether this Economy is taxable.booleanFetches whether an Economy can be converted to another Economy.static voidReloads the Economy Cache.static voidremoveEconomy(@NotNull String name) Remove an Economy from the Pluginstatic voidremoveEconomy(@Nullable Economy econ) Remove an Economy from the PluginvoidSaves this Economy to its file.Serialization inside a YML FilevoidsetConversionScale(double scale) Sets the conversion scale of this Economy.voidsetConvertable(boolean convertable) Sets whether an Economy can be converted to another Economy.voidsetCustomModelData(int customModelData) Sets the custom model data integer of this economyvoidsetHasClickableReward(boolean clickable) Sets whether this economy is rewarded by clicking on a business icon when advertising.voidSets the icon of this economy.voidSets the icon of this economy.voidsetIncreaseNaturally(boolean increase) Sets whether this economy naturally increases.voidsetInterest(boolean interest) Set the interest acception state of this economyvoidSets the economy's name.booleansetTax(boolean tax) Sets whether this Economy is taxable.toString()
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHThe maximum length of an Economy name- See Also:
-
MAX_CONVERSION_SCALE
public static final double MAX_CONVERSION_SCALEThe 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
Fetch a set of all economies supporting interest- Returns:
- Set of Interest Economies
-
getTaxableEconomies
Fetches a set of Economies that havehasTax()to true.- Returns:
- Set of Taxable Economies
-
getClickableRewardEconomies
Fetches a set of Economies that havehasClickableReward()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
Sets the economy's name.- Parameters:
name- Name of the economy
-
setIcon
Sets the icon of this economy.- Parameters:
icon- Icon of the economy- Throws:
IllegalArgumentException- if icon is null
-
setIcon
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
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
Remove an Economy from the Plugin- Parameters:
name- Name of the Economy- See Also:
-
removeEconomy
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
Whether this Economy exists.- Parameters:
name- Name of the Economy- Returns:
- true if economy exists, else false
-
exists
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 economyAn economy with a conversion scale of
1and another with a conversion scale of0.5would 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
Fetch a set of all economies registered on the Plugin- Returns:
- Set of Registered Economies
-
getNaturalEconomies
Fetch a set of economies that increase naturally- Returns:
- Set of Economies that increase naturally
-
getEconomySection
Deprecated.Economies are no longer stored in an individual fileReturn the ConfigurationSection that this Economy is stored in- Returns:
ConfigurationSectionof this economy
-
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
Get the Icon of this Economy- Returns:
- Icon of this Economy
-
getIconType
Gets the Economy Icon's Type.- Returns:
- Icon Material Type
-
convertAmount
public double convertAmount(@NotNull @NotNull Economy to, double fromAmount) throws IllegalArgumentException Convert this economy to another economy- Parameters:
to- The New Economy to convert tofromAmount- How much amount is to be converted- Returns:
- Converted amount in the other economy's form
- Throws:
IllegalArgumentException- if to or from is null, economies are identical, or either are not convertable- See Also:
-
getUniqueId
Get the Economy's unique identifier.- Returns:
- Unique Identifier
-
convertAmount
public static double convertAmount(@NotNull @NotNull Economy from, @NotNull @NotNull Economy to, double fromAmount) throws IllegalArgumentException Convert one economy's balance to another- Parameters:
from- The Economy to convert fromto- The Economy to convert tofromAmount- How much amount is to be converted- Returns:
- Converted amount in the other economy's form
- Throws:
IllegalArgumentException- if to or from is null, economies are identical, or either is not convertable
-
getEconomy
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
-
isConvertable
public boolean isConvertable()Fetches whether an Economy can be converted to another Economy.- Returns:
- true if convertable, else false
-
setConvertable
public void setConvertable(boolean convertable) Sets whether an Economy can be converted to another Economy.- Parameters:
convertable- true if convertable, else false
-
getEconomy
Fetches an Economy by its unique symbol.- Parameters:
symbol- Symbol to find- Returns:
- Economy found, or null if not found
-
builder
Fetch a Builder used for creating economies- Returns:
Economy.BuilderClass
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<Economy>
-
toString
-
saveEconomy
public void saveEconomy()Saves this Economy to its file. -
serialize
Serialization inside a YML File- Specified by:
serializein interfaceConfigurationSerializable- Returns:
- Serialized Economy
-
deserialize
public static Economy deserialize(@Nullable @Nullable Map<String, Object> serial) throws NullPointerExceptionSerialization from a YML FileThis 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:
-