Class EconomySystemAPI
java.lang.Object
enterprises.iwakura.economysystem.api.EconomySystemAPI
API class for accessing Economy System's features.
-
Constructor Summary
ConstructorsConstructorDescriptionEconomySystemAPI(org.bukkit.plugin.Plugin plugin) Creates an instance of EconomySystemAPI with your plugin. -
Method Summary
Modifier and TypeMethodDescriptioncreateBasicStandingOrder(long fromAccountNumber, long toAccountNumber, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull String note) Creates a basic standing order.createBasicStandingOrder(UUID fromEntityUuid, BankingAccountTypeEnum fromEntityAccountType, UUID toEntityUuid, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull String note) Creates a basic standing order.createUniqueStandingOrder(long fromAccountNumber, long toAccountNumber, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull String uniqueNote, boolean silent) Creates a unique standing order.createUniqueStandingOrder(UUID fromEntityUuid, BankingAccountTypeEnum fromEntityAccountType, String infiniteAccountName, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull String uniqueNote, boolean silent) Creates a unique standing order.createUniqueStandingOrder(UUID fromEntityUuid, BankingAccountTypeEnum fromEntityAccountType, UUID toEntityUuid, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, int gameDayPeriod, boolean fromAccountEntityMustBeOnline, @NonNull String uniqueNote, boolean silent) Creates a unique standing order.deposit(Long accountNumber, BigDecimal amount, String detail) Deposits money to an account.deposit(UUID entity, BankingAccountTypeEnum type, BigDecimal amount, String detail) Deposits money to an account.getAccount(UUID entityId, BankingAccountTypeEnum accountType) Gets the account for the given entity ID and account type.getAccounts(UUID entityId) Gets the accounts for the given entity ID.getInfiniteAccount(String name) Gets the infinite account for the given name.getStandingOrders(long fromAccountNumber) Gets standing orders based on the provided criteria.getStandingOrders(long fromAccountNumber, long toAccountNumber, @NonNull String note) Gets standing orders based on the provided criteria.removeStandingOrderById(long standingOrderId) Removes a standing order by its ID.transfer(Long fromAccountNumber, Long toAccountNumber, BigDecimal amount, String detail) Transfers money between two accounts.transfer(Long fromAccountNumber, Long toAccountNumber, BigDecimal amount, String detail, boolean silent) Transfers money between two accounts.transfer(UUID fromEntity, BankingAccountTypeEnum fromEntityAccountType, UUID toEntity, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, String detail) Transfers money between two entities.transfer(UUID fromEntity, BankingAccountTypeEnum fromEntityAccountType, UUID toEntity, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, String detail, boolean silent) Transfers money between two entities.withdraw(Long accountNumber, BigDecimal amount, String detail, boolean silent, boolean allowNegative) Withdraws money from an account.withdraw(UUID entity, BankingAccountTypeEnum type, BigDecimal amount, String detail, boolean silent, boolean allowNegative) Withdraws money from an account.
-
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 entityfromEntityAccountType- From entity account typetoEntity- To entitytoEntityAccountType- To entity account typeamount- Amount to transferdetail- 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 numbertoAccountNumber- To account numberamount- Amount to transferdetail- Transaction detail- Returns:
- A CompletableFuture that will be completed with the transaction DTO. If transactions fails due to non-existing accounts or invalid
-
transfer
public CompletableFuture<AccountingTransactionDTO> transfer(UUID fromEntity, BankingAccountTypeEnum fromEntityAccountType, UUID toEntity, BankingAccountTypeEnum toEntityAccountType, BigDecimal amount, String detail, boolean silent) Transfers money between two entities.- Parameters:
fromEntity- From entityfromEntityAccountType- From entity account typetoEntity- To entitytoEntityAccountType- To entity account typeamount- Amount to transferdetail- Transaction detailsilent- If true, the transfer will be processed silently without sending any messages to the players involved.- 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, boolean silent) Transfers money between two accounts.- Parameters:
fromAccountNumber- From account numbertoAccountNumber- To account numberamount- Amount to transferdetail- Transaction detailsilent- If true, the transfer will be processed silently without sending any messages to the players involved.- 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, boolean silent, boolean allowNegative) Withdraws money from an account.- Parameters:
accountNumber- Account numberamount- Amount to withdrawdetail- 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, boolean silent, boolean allowNegative) Withdraws money from an account.- Parameters:
entity- Entity IDtype- Account typeamount- Amount to withdrawdetail- 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 numberamount- Amount to depositdetail- 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 IDtype- Account typeamount- Amount to depositdetail- 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
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 IDaccountType- 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
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 numbertoAccountNumber- To account numberamount- Amount to transfergameDayPeriod- 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 processednote- 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 UUIDfromEntityAccountType- From entity account typetoEntityUuid- To entity UUIDtoEntityAccountType- To entity account typeamount- Amount to transfergameDayPeriod- 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 processednote- 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 numbertoAccountNumber- To account numberamount- Amount to transfergameDayPeriod- 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 processeduniqueNote- Unique note for the standing ordersilent- 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.
-
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 UUIDfromEntityAccountType- From entity account typetoEntityUuid- To entity UUIDtoEntityAccountType- To entity account typeamount- Amount to transfergameDayPeriod- 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 processeduniqueNote- Unique note for the standing ordersilent- 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.
-
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 UUIDfromEntityAccountType- From entity account typeinfiniteAccountName- Name of the infinite accountamount- 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 processeduniqueNote- Unique note for the standing ordersilent- 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.
-
getStandingOrders
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
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.
-