Class MVEconomist
java.lang.Object
org.mvplugins.multiverse.core.economy.MVEconomist
Multiverse's Friendly Economist. This is used to deal with external economies and also item costs for stuff in MV.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
deposit
(org.bukkit.entity.Player player, double amount, @Nullable org.bukkit.Material currency) Deposits a given amount of currency either into the player's economy account or inventory if the currency is not null.formatPrice
(double amount, @Nullable org.bukkit.Material currency) Formats the amount to a human readable currency string.double
getBalance
(org.bukkit.entity.Player player) Returns the economy balance of the given player.double
getBalance
(org.bukkit.entity.Player player, org.bukkit.World world) Returns the economy balance of the given player in the given world.Returns the name of the economy in use.getNSFMessage
(org.bukkit.Material currency, String message) Formats a message for a player indicating they don't have enough currency.static boolean
isItemCurrency
(org.bukkit.Material currency) Determines if the currency type string given represents an item currency.boolean
isPlayerWealthyEnough
(org.bukkit.entity.Player player, double amount, org.bukkit.Material currency) Determines if a player has enough of a given currency.boolean
Checks if an economy plugin is in use.void
payEntryFee
(org.bukkit.entity.Player player, double price, org.bukkit.Material currency) Pays for a given amount of currency either from the player's economy account or inventory if the currency.void
payEntryFee
(org.bukkit.entity.Player player, MultiverseWorld world) Pays for a given amount of currency either from the player's economy account or inventory if the currency.void
setBalance
(org.bukkit.entity.Player player, double amount) Sets the economy balance for the given player.void
setBalance
(org.bukkit.entity.Player player, org.bukkit.World world, double amount) Sets the economy balance for the given player in the given world.void
withdraw
(org.bukkit.entity.Player player, double amount, @Nullable org.bukkit.Material currency) Withdraws a given amount of currency either from the player's economy account or inventory if the currency is not null.
-
Field Details
-
VAULT_ECONOMY_CODE
- See Also:
-
VAULT_ECONOMY_MATERIAL
public static final org.bukkit.Material VAULT_ECONOMY_MATERIAL
-
-
Method Details
-
isUsingEconomyPlugin
public boolean isUsingEconomyPlugin()Checks if an economy plugin is in use.- Returns:
- true if an economy plugin is detected by Vault.
-
formatPrice
Formats the amount to a human readable currency string.- Parameters:
amount
- the amount of currency.currency
- the type of currency. Null indicates a non-item currency is used.- Returns:
- the human readable currency string.
-
getEconomyName
Returns the name of the economy in use.- Returns:
- the name of the economy in use.
-
isPlayerWealthyEnough
public boolean isPlayerWealthyEnough(org.bukkit.entity.Player player, double amount, org.bukkit.Material currency) Determines if a player has enough of a given currency.- Parameters:
player
- the player to check for currency.amount
- the amount of currency.currency
- the type of currency. Null indicates non-item currency is used.- Returns:
- true if the player has enough of the given currency or the amount is 0 or less.
-
getNSFMessage
Formats a message for a player indicating they don't have enough currency.- Parameters:
currency
- the type of currency. Null indicates a non-item currency is used.message
- The more specific message to append to the generic message of not having enough.- Returns:
- the formatted insufficient funds message.
-
payEntryFee
Pays for a given amount of currency either from the player's economy account or inventory if the currency.- Parameters:
player
- the player to deposit currency into.world
- the world to take entry fee from.
-
payEntryFee
public void payEntryFee(org.bukkit.entity.Player player, double price, org.bukkit.Material currency) Pays for a given amount of currency either from the player's economy account or inventory if the currency.- Parameters:
player
- the player to take currency from.price
- the amount to take.currency
- the type of currency.
-
deposit
public void deposit(org.bukkit.entity.Player player, double amount, @Nullable @Nullable org.bukkit.Material currency) Deposits a given amount of currency either into the player's economy account or inventory if the currency is not null.- Parameters:
player
- the player to give currency to.amount
- the amount to give.currency
- the type of currency.
-
withdraw
public void withdraw(org.bukkit.entity.Player player, double amount, @Nullable @Nullable org.bukkit.Material currency) Withdraws a given amount of currency either from the player's economy account or inventory if the currency is not null.- Parameters:
player
- the player to take currency from.amount
- the amount to take.currency
- the type of currency.
-
getBalance
Returns the economy balance of the given player.- Parameters:
player
- the player to get the balance for.- Returns:
- the economy balance of the given player.
- Throws:
IllegalStateException
- thrown if this is used when no economy plugin is available.
-
getBalance
public double getBalance(org.bukkit.entity.Player player, org.bukkit.World world) throws IllegalStateException Returns the economy balance of the given player in the given world. If the economy plugin does not have world specific balances then the global balance will be returned.- Parameters:
player
- the player to get the balance for.world
- the world to get the balance for.- Returns:
- the economy balance of the given player in the given world.
- Throws:
IllegalStateException
- thrown if this is used when no economy plugin is available.
-
setBalance
Sets the economy balance for the given player.- Parameters:
player
- the player to set the balance for.amount
- the amount to set the player's balance to.- Throws:
IllegalStateException
- thrown if this is used when no economy plugin is available.
-
setBalance
public void setBalance(org.bukkit.entity.Player player, org.bukkit.World world, double amount) throws IllegalStateException Sets the economy balance for the given player in the given world. If the economy plugin does not have world specific balances then the global balance will be set.- Parameters:
player
- the player to set the balance for.world
- the world to get the balance for.amount
- the amount to set the player's balance to.- Throws:
IllegalStateException
- thrown if this is used when no economy plugin is available.
-
isItemCurrency
public static boolean isItemCurrency(org.bukkit.Material currency) Determines if the currency type string given represents an item currency.- Parameters:
currency
- the type of currency.- Returns:
- true if currency string matches a valid material.
-