Class EconomySystemAPI

java.lang.Object
enterprises.iwakura.economysystem.api.EconomySystemAPI

public class EconomySystemAPI extends Object
API class for accessing Economy System's features.
  • Constructor Details

    • EconomySystemAPI

      public EconomySystemAPI(org.bukkit.plugin.Plugin plugin)
      Creates an instance of EconomySystemAPI with your plugin.
      Parameters:
      plugin - The plugin instance that is using the API.
  • Method Details

    • transfer

      public CompletableFuture<AccountingTransactionDTO> transfer(UUID fromEntity, BankingAccountTypeEnum fromEntityAccountType, UUID toEntity, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, String detail)
      Transfers money between two entities.
      Parameters:
      fromEntity - From entity
      fromEntityAccountType - From entity account type
      toEntity - To entity
      toEntityAccountType - To entity account type
      amount - Amount to transfer
      detail - Transaction detail
      Returns:
      A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid arguments (such as non-positive amount), the future will be completed exceptionally.
    • transfer

      public CompletableFuture<AccountingTransactionDTO> transfer(Long fromAccountNumber, Long toAccountNumber, BigDecimal amount, String detail)
      Transfers money between two accounts.
      Parameters:
      fromAccountNumber - From account number
      toAccountNumber - To account number
      amount - Amount to transfer
      detail - Transaction detail
      Returns:
      A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid
    • withdraw

      public CompletableFuture<AccountingTransactionDTO> withdraw(Long accountNumber, BigDecimal amount, String detail)
      Withdraws money from an account.
      Parameters:
      accountNumber - Account number
      amount - Amount to withdraw
      detail - Transaction detail
      Returns:
      A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid arguments (such as non-positive amount), the future will be completed exceptionally.
    • withdraw

      public CompletableFuture<AccountingTransactionDTO> withdraw(UUID entity, BankingAccountTypeEnum type, BigDecimal amount, String detail)
      Withdraws money from an account.
      Parameters:
      entity - Entity ID
      type - Account type
      amount - Amount to withdraw
      detail - Transaction detail
      Returns:
      A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid arguments (such as non-positive amount), the future will be completed exceptionally.
    • deposit

      public CompletableFuture<AccountingTransactionDTO> deposit(Long accountNumber, BigDecimal amount, String detail)
      Deposits money to an account.
      Parameters:
      accountNumber - Account number
      amount - Amount to deposit
      detail - Transaction detail
      Returns:
      A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid arguments (such as non-positive amount), the future will be completed exceptionally.
    • deposit

      public CompletableFuture<AccountingTransactionDTO> deposit(UUID entity, BankingAccountTypeEnum type, BigDecimal amount, String detail)
      Deposits money to an account.
      Parameters:
      entity - Entity ID
      type - Account type
      amount - Amount to deposit
      detail - Transaction detail
      Returns:
      A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid arguments (such as non-positive amount), the future will be completed exceptionally.
    • getAccounts

      public CompletableFuture<List<BankingAccountDTO>> getAccounts(UUID entityId)
      Gets the accounts for the given entity ID.
      Parameters:
      entityId - Entity ID
      Returns:
      A CompletableFuture that will be completed with the list of account DTOs for the given entity ID. If entity has no accounts, the list will be empty.
    • getAccount

      public CompletableFuture<BankingAccountDTO> getAccount(UUID entityId, BankingAccountTypeEnum accountType)
      Gets the account for the given entity ID and account type.
      Parameters:
      entityId - Entity ID
      accountType - Account type
      Returns:
      A CompletableFuture that will be completed with the account DTO for the given entity ID and account type. If entity has no account of the given type, the future will be completed exceptionally.
    • getInfiniteAccount

      public CompletableFuture<BankingAccountDTO> getInfiniteAccount(String name)
      Gets the infinite account for the given name.
      Parameters:
      name - Name of the infinite account to retrieve.
      Returns:
      A CompletableFuture that will be completed with the BankingAccountDTO for the infinite account.
    • createBasicStandingOrder

      public CompletableFuture<StandingOrderDTO> createBasicStandingOrder(long fromAccountNumber, long toAccountNumber, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull @NonNull String note)
      Creates a basic standing order.
      Parameters:
      fromAccountNumber - From account number
      toAccountNumber - To account number
      amount - Amount to transfer
      gameDayPeriod - Game day period for the standing order (how often it should be processed)
      fromAccountEntityMustBeOnline - If true, the from account entity must be online for the standing order to be processed
      note - Note for the standing order
      Returns:
      A CompletableFuture that will be completed with the StandingOrderDTO. If the standing order creation fails due to invalid arguments or
    • createBasicStandingOrder

      public CompletableFuture<StandingOrderDTO> createBasicStandingOrder(UUID fromEntityUuid, BankingAccountTypeEnum fromEntityAccountType, UUID toEntityUuid, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull @NonNull String note)
      Creates a basic standing order.
      Parameters:
      fromEntityUuid - From entity UUID
      fromEntityAccountType - From entity account type
      toEntityUuid - To entity UUID
      toEntityAccountType - To entity account type
      amount - Amount to transfer
      gameDayPeriod - Game day period for the standing order (how often it should be processed)
      fromAccountEntityMustBeOnline - If true, the from account entity must be online for the standing order to be processed
      note - Note for the standing order
      Returns:
      A CompletableFuture that will be completed with the StandingOrderDTO. If the standing order creation fails due to invalid arguments or
    • createUniqueStandingOrder

      public CompletableFuture<StandingOrderDTO> createUniqueStandingOrder(long fromAccountNumber, long toAccountNumber, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull @NonNull String uniqueNote, boolean silent)
      Creates a unique standing order. If there's already a standing order with the same note, it will be updated instead of creating a new one. If the specified amount is negative, it deletes the existing standing order. If no standing order exists with the specified note and the amount is less than or equal to 0, it throws an CannotCreateUniqueStandingOrderException.
      Parameters:
      fromAccountNumber - From account number
      toAccountNumber - To account number
      amount - Amount to transfer
      gameDayPeriod - Game day period for the standing order (how often it should be processed)
      fromAccountEntityMustBeOnline - If true, the from account entity must be online for the standing order to be processed
      uniqueNote - Unique note for the standing order
      silent - If true, the standing order will be processed silently without sending any messages to the players involved.
      Returns:
      A CompletableFuture that will be completed with the StandingOrderDTO. If the standing order creation fails due to invalid arguments or any other way, the future will be completed exceptionally.
      Throws:
      gol.economy.exception.CannotCreateUniqueStandingOrderException - if no standing order exists with the specified note and the amount is less than or equal to 0.
    • createUniqueStandingOrder

      public CompletableFuture<StandingOrderDTO> createUniqueStandingOrder(UUID fromEntityUuid, BankingAccountTypeEnum fromEntityAccountType, UUID toEntityUuid, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull @NonNull String uniqueNote, boolean silent)
      Creates a unique standing order. If there's already a standing order with the same note, it will be updated instead of creating a new one. If the specified amount is negative, it deletes the existing standing order. If no standing order exists with the specified note and the amount is less than or equal to 0, it throws an CannotCreateUniqueStandingOrderException.
      Parameters:
      fromEntityUuid - From entity UUID
      fromEntityAccountType - From entity account type
      toEntityUuid - To entity UUID
      toEntityAccountType - To entity account type
      amount - Amount to transfer
      gameDayPeriod - Game day period for the standing order (how often it should be processed)
      fromAccountEntityMustBeOnline - If true, the from account entity must be online for the standing order to be processed
      uniqueNote - Unique note for the standing order
      silent - If true, the standing order will be processed silently without sending any messages to the players involved.
      Returns:
      A CompletableFuture that will be completed with the StandingOrderDTO. If the standing order creation fails due to invalid arguments or any other way, the future will be completed exceptionally.
      Throws:
      gol.economy.exception.CannotCreateUniqueStandingOrderException - if no standing order exists with the specified note and the amount is less than or equal to 0.
    • createUniqueStandingOrder

      public CompletableFuture<StandingOrderDTO> createUniqueStandingOrder(UUID fromEntityUuid, BankingAccountTypeEnum fromEntityAccountType, String infiniteAccountName, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull @NonNull String uniqueNote, boolean silent)
      Creates a unique standing order. If there's already a standing order with the same note, it will be updated instead of creating a new one. If the specified amount is negative, it deletes the existing standing order. If no standing order exists with the specified note and the amount is less than or equal to 0, it throws an CannotCreateUniqueStandingOrderException.
      Parameters:
      fromEntityUuid - From entity UUID
      fromEntityAccountType - From entity account type
      infiniteAccountName - Name of the infinite account
      amount - Amount to transfer, should be positive to create a standing order, or negative to delete an existing one.
      gameDayPeriod - Game day period for the standing order (how often it should be processed)
      fromAccountEntityMustBeOnline - If true, the from account entity must be online for the standing order to be processed
      uniqueNote - Unique note for the standing order
      silent - If true, the standing order will be processed silently without sending any messages to the players involved.
      Returns:
      A CompletableFuture that will be completed with the StandingOrderDTO. If the standing order creation fails due to invalid arguments or any other way, the future will be completed exceptionally.
      Throws:
      gol.economy.exception.CannotCreateUniqueStandingOrderException - if no standing order exists with the specified note and the amount is less than or equal to 0.
    • getStandingOrders

      public CompletableFuture<List<StandingOrderDTO>> getStandingOrders(long fromAccountNumber)
      Gets standing orders based on the provided criteria.
      Parameters:
      fromAccountNumber - From account number to filter standing orders.
      Returns:
      A CompletableFuture that will be completed with a list of StandingOrderDTOs matching the criteria.
    • getStandingOrders

      public CompletableFuture<List<StandingOrderDTO>> getStandingOrders(long fromAccountNumber, long toAccountNumber, @NonNull @NonNull String note)
      Gets standing orders based on the provided criteria.
      Parameters:
      fromAccountNumber - From account number to filter standing orders.
      toAccountNumber - To account number to filter standing orders.
      note - Note to filter standing orders
      Returns:
      A CompletableFuture that will be completed with a list of StandingOrderDTOs matching the criteria.
    • removeStandingOrderById

      public CompletableFuture<Void> removeStandingOrderById(long standingOrderId)
      Removes a standing order by its ID.
      Parameters:
      standingOrderId - ID of the standing order to remove.
      Returns:
      A CompletableFuture that will be completed when the standing order is removed. If the removal fails (e.g., standing order does not exist), the future will be completed exceptionally.