Class MVEconomist


  • public class MVEconomist
    extends java.lang.Object
    Multiverse's Friendly Economist. This is used to deal with external economies and also item costs for stuff in MV.
    • Constructor Summary

      Constructors 
      Constructor Description
      MVEconomist​(org.bukkit.plugin.Plugin plugin)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void 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.
      java.lang.String 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.
      java.lang.String getEconomyName()
      Returns the name of the economy in use.
      java.lang.String getNSFMessage​(org.bukkit.Material currency, java.lang.String message)
      Formats a message for a player indicating they don't have enough currency.
      VaultHandler getVaultHandler()
      Deprecated.
      just use the other methods in this class for economy stuff.
      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 isUsingEconomyPlugin()
      Checks if an economy plugin is in use.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MVEconomist

        public MVEconomist​(org.bukkit.plugin.Plugin plugin)
    • Method Detail

      • isUsingEconomyPlugin

        public boolean isUsingEconomyPlugin()
        Checks if an economy plugin is in use.
        Returns:
        true if an economy plugin is detected by Vault.
      • formatPrice

        public java.lang.String formatPrice​(double amount,
                                            @Nullable
                                            @Nullable org.bukkit.Material currency)
        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

        public java.lang.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

        public java.lang.String getNSFMessage​(org.bukkit.Material currency,
                                              java.lang.String message)
        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.
      • 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

        public double getBalance​(org.bukkit.entity.Player player)
                          throws java.lang.IllegalStateException
        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:
        java.lang.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 java.lang.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:
        java.lang.IllegalStateException - thrown if this is used when no economy plugin is available.
      • setBalance

        public void setBalance​(org.bukkit.entity.Player player,
                               double amount)
                        throws java.lang.IllegalStateException
        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:
        java.lang.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 java.lang.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:
        java.lang.IllegalStateException - thrown if this is used when no economy plugin is available.
      • getVaultHandler

        @Deprecated
        public VaultHandler getVaultHandler()
        Deprecated.
        just use the other methods in this class for economy stuff.
        This method is public for backwards compatibility.
        Returns:
        the old VaultHandler.
      • 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.