Class EconomyUtils

java.lang.Object
com.ultikits.ultitools.utils.EconomyUtils

public final class EconomyUtils extends Object
Utility class for economy operations using Vault. Provides convenient static methods for common economy operations.

使用 Vault 进行经济操作的工具类。 提供常用经济操作的便捷静态方法。

Since:
6.2.0
Version:
1.0.0
Author:
wisdomme
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static net.milkbowl.vault.economy.Economy
     
    private static boolean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    deposit(UUID uuid, double amount)
    Deposits money into a player's account.
    static boolean
    deposit(org.bukkit.OfflinePlayer player, double amount)
    Deposits money into a player's account.
    static String
    format(double amount)
    Formats an amount according to the economy's format.
    static double
    Gets the balance of a player by UUID.
    static double
    getBalance(org.bukkit.OfflinePlayer player)
    Gets the balance of a player.
    static String
    Gets the currency name (singular).
    static String
    Gets the currency name (plural).
    static net.milkbowl.vault.economy.Economy
    Gets the economy instance.
    static boolean
    has(UUID uuid, double amount)
    Checks if a player has at least the specified amount.
    static boolean
    has(org.bukkit.OfflinePlayer player, double amount)
    Checks if a player has at least the specified amount.
    static boolean
    Checks if Vault economy is available.
    static void
    Resets the economy setup state.
    static boolean
    Sets up the economy provider from Vault.
    static boolean
    transfer(UUID from, UUID to, double amount)
    Transfers money from one player to another.
    static boolean
    transfer(org.bukkit.OfflinePlayer from, org.bukkit.OfflinePlayer to, double amount)
    Transfers money from one player to another.
    static boolean
    withdraw(UUID uuid, double amount)
    Withdraws money from a player's account.
    static boolean
    withdraw(org.bukkit.OfflinePlayer player, double amount)
    Withdraws money from a player's account.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • economy

      private static net.milkbowl.vault.economy.Economy economy
    • setupAttempted

      private static boolean setupAttempted
  • Constructor Details

    • EconomyUtils

      private EconomyUtils()
  • Method Details

    • setup

      public static boolean setup()
      Sets up the economy provider from Vault.

      从 Vault 设置经济提供者。

      Returns:
      true if economy was set up successfully
    • isAvailable

      public static boolean isAvailable()
      Checks if Vault economy is available.

      检查 Vault 经济是否可用。

      Returns:
      true if economy is available
    • getEconomy

      @Nullable public static net.milkbowl.vault.economy.Economy getEconomy()
      Gets the economy instance.

      获取经济实例。

      Returns:
      the economy instance, or null if not available
    • getBalance

      public static double getBalance(org.bukkit.OfflinePlayer player)
      Gets the balance of a player.

      获取玩家余额。

      Parameters:
      player - the player
      Returns:
      the balance, or 0 if economy is not available
    • getBalance

      public static double getBalance(UUID uuid)
      Gets the balance of a player by UUID.

      通过 UUID 获取玩家余额。

      Parameters:
      uuid - the player's UUID
      Returns:
      the balance, or 0 if economy is not available
    • has

      public static boolean has(org.bukkit.OfflinePlayer player, double amount)
      Checks if a player has at least the specified amount.

      检查玩家是否拥有至少指定数量的金钱。

      Parameters:
      player - the player
      amount - the amount to check
      Returns:
      true if the player has at least the amount
    • has

      public static boolean has(UUID uuid, double amount)
      Checks if a player has at least the specified amount.

      检查玩家是否拥有至少指定数量的金钱。

      Parameters:
      uuid - the player's UUID
      amount - the amount to check
      Returns:
      true if the player has at least the amount
    • deposit

      public static boolean deposit(org.bukkit.OfflinePlayer player, double amount)
      Deposits money into a player's account.

      向玩家账户存入金钱。

      Parameters:
      player - the player
      amount - the amount to deposit
      Returns:
      true if the deposit was successful
    • deposit

      public static boolean deposit(UUID uuid, double amount)
      Deposits money into a player's account.

      向玩家账户存入金钱。

      Parameters:
      uuid - the player's UUID
      amount - the amount to deposit
      Returns:
      true if the deposit was successful
    • withdraw

      public static boolean withdraw(org.bukkit.OfflinePlayer player, double amount)
      Withdraws money from a player's account.

      从玩家账户取出金钱。

      Parameters:
      player - the player
      amount - the amount to withdraw
      Returns:
      true if the withdrawal was successful
    • withdraw

      public static boolean withdraw(UUID uuid, double amount)
      Withdraws money from a player's account.

      从玩家账户取出金钱。

      Parameters:
      uuid - the player's UUID
      amount - the amount to withdraw
      Returns:
      true if the withdrawal was successful
    • transfer

      public static boolean transfer(org.bukkit.OfflinePlayer from, org.bukkit.OfflinePlayer to, double amount)
      Transfers money from one player to another.

      在两个玩家之间转账。

      Parameters:
      from - the player to withdraw from
      to - the player to deposit to
      amount - the amount to transfer
      Returns:
      true if the transfer was successful
    • transfer

      public static boolean transfer(UUID from, UUID to, double amount)
      Transfers money from one player to another.

      在两个玩家之间转账。

      Parameters:
      from - the UUID of the player to withdraw from
      to - the UUID of the player to deposit to
      amount - the amount to transfer
      Returns:
      true if the transfer was successful
    • format

      public static String format(double amount)
      Formats an amount according to the economy's format.

      根据经济插件的格式格式化金额。

      Parameters:
      amount - the amount to format
      Returns:
      the formatted amount string
    • getCurrencyName

      public static String getCurrencyName()
      Gets the currency name (singular).

      获取货币名称(单数形式)。

      Returns:
      the currency name
    • getCurrencyNamePlural

      public static String getCurrencyNamePlural()
      Gets the currency name (plural).

      获取货币名称(复数形式)。

      Returns:
      the currency name (plural)
    • reset

      public static void reset()
      Resets the economy setup state. Used primarily for testing.

      重置经济设置状态。主要用于测试。