Class TownyEconomyHandler

java.lang.Object
com.palmergames.bukkit.towny.TownyEconomyHandler

public class TownyEconomyHandler extends Object
Economy handler to interface with Register or Vault directly.
Author:
ElgarL, Suneet Tipirneni (Siris)
  • Constructor Details

    • TownyEconomyHandler

      public TownyEconomyHandler()
  • Method Details

    • getServerAccount

      public static String getServerAccount()
    • getTownyObjectUUID

      @Nullable public static @Nullable UUID getTownyObjectUUID(String accountName)
      Method which can be used by Economy plugins in order to get a valid UUID from a Towny object, for use in making FakePlayer accounts.
      Parameters:
      accountName - String name which Towny uses when interacting with Vault's Economy class.
      Returns:
      the TownyObject's UUID or null if no Towny Object could be resolved.
    • initialize

      public static void initialize(Towny plugin)
    • getType

      public static TownyEconomyHandler.EcoType getType()
      Returns:
      the economy type we have detected.
    • isActive

      public static boolean isActive()
      Are we using any economy system?
      Returns:
      true if we found one.
    • getVersion

      public static String getVersion()
      Returns:
      The current economy providers version string
    • setupEconomy

      public static boolean setupEconomy()
      Find and configure a suitable economy provider
      Returns:
      true if successful.
    • removeAccount

      public static void removeAccount(String accountName)
      Attempt to delete the economy account.
      Parameters:
      accountName - name of the account to delete
    • getBalance

      public static double getBalance(String accountName, org.bukkit.World world)
      Returns the accounts current balance
      Parameters:
      accountName - name of the economy account
      world - name of world to check in (for TNE Reserve)
      Returns:
      double containing the total in the account
    • hasEnough

      public static boolean hasEnough(String accountName, double amount, org.bukkit.World world)
      Returns true if the account has enough money
      Parameters:
      accountName - name of an economy account
      amount - minimum amount to check against (Double)
      world - name of the world to check in (for TNE Reserve)
      Returns:
      true if there is enough in the account
    • subtract

      public static boolean subtract(String accountName, double amount, org.bukkit.World world)
      Attempts to remove an amount from an account
      Parameters:
      accountName - name of the account to modify
      amount - amount of currency to remove from the account
      world - name of the world in which to check in (TNE Reserve)
      Returns:
      true if successful
    • add

      public static boolean add(String accountName, double amount, org.bukkit.World world)
      Add funds to an account.
      Parameters:
      accountName - account to add funds to
      amount - amount of currency to add
      world - name of world (for TNE Reserve)
      Returns:
      true if successful
    • setBalance

      public static boolean setBalance(String accountName, double amount, org.bukkit.World world)
    • getFormattedBalance

      public static String getFormattedBalance(double balance)
      Format this balance according to the current economy systems settings.
      Parameters:
      balance - account balance passed by the economy handler
      Returns:
      string containing the formatted balance
    • addToServer

      public static boolean addToServer(double amount, org.bukkit.World world)
      Adds money to the server account (used for towny closed economy.)
      Parameters:
      amount - The amount to deposit.
      world - The world of the deposit.
      Returns:
      A boolean indicating success.
    • subtractFromServer

      public static boolean subtractFromServer(double amount, org.bukkit.World world)
      Removes money to the server account (used for towny closed economy.)
      Parameters:
      amount - The amount to withdraw.
      world - The world of the withdraw.
      Returns:
      A boolean indicating success.
    • hasAccount

      public static boolean hasAccount(String accountName)
    • isEssentials

      public static boolean isEssentials()
    • economyExecutor

      public static Executor economyExecutor()
      Returns:
      An executor that will schedule tasks on the right thread to respect TownySettings.isEconomyAsync()