Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Change transfer API methods to have a default.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Jul 25, 2018
1 parent 43bd869 commit 14b6c06
Showing 1 changed file with 50 additions and 18 deletions.
68 changes: 50 additions & 18 deletions src/net/tnemc/core/economy/EconomyAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,16 @@ default boolean vault() {

/**
* Used to transfer funds from one account to another.
*
* @param fromIdentifier The identifier of the account that the holdings will be coming from.
* @param toIdentifier The identifier of the account that the holdings will be going to.
* @param amount The amount you wish to remove from this account.
*
* @return True if the funds were transferred.
*/
boolean transferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount);
default boolean transferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount) {
return removeHoldings(fromIdentifier, amount) && addHoldings(toIdentifier, amount);
}

/**
* Used to transfer funds from one account to another.
Expand All @@ -630,7 +634,9 @@ default boolean vault() {
* @param world The name of the {@link World} associated with the amount.
* @return True if the funds were transferred.
*/
boolean transferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world);
default boolean transferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world) {
return removeHoldings(fromIdentifier, amount, world) && addHoldings(toIdentifier, amount, world);
}

/**
* Used to transfer funds from one account to another.
Expand All @@ -641,7 +647,9 @@ default boolean vault() {
* @param currency The {@link Currency} associated with the balance.
* @return True if the funds were transferred.
*/
boolean transferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world, String currency);
default boolean transferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world, String currency) {
return removeHoldings(fromIdentifier, amount, world, currency) && addHoldings(toIdentifier, amount, world, currency);
}

/**
* Used to transfer funds from one account to another.
Expand All @@ -650,7 +658,9 @@ default boolean vault() {
* @param amount The amount you wish to remove from this account.
* @return True if the funds were transferred.
*/
boolean transferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount);
default boolean transferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount) {
return removeHoldings(fromIdentifier, amount) && addHoldings(toIdentifier, amount);
}

/**
* Used to transfer funds from one account to another.
Expand All @@ -660,7 +670,9 @@ default boolean vault() {
* @param world The name of the {@link World} associated with the amount.
* @return True if the funds were transferred.
*/
boolean transferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world);
default boolean transferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world) {
return removeHoldings(fromIdentifier, amount, world) && addHoldings(toIdentifier, amount, world);
}

/**
* Used to transfer funds from one account to another.
Expand All @@ -671,7 +683,9 @@ default boolean vault() {
* @param currency The {@link Currency} associated with the balance.
* @return True if the funds were transferred.
*/
boolean transferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world, String currency);
default boolean transferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world, String currency) {
return removeHoldings(fromIdentifier, amount, world, currency) && addHoldings(toIdentifier, amount, world, currency);
}

/**
* Used to determine if a call to the corresponding transferHoldings method would be successful. This method does not
Expand All @@ -681,7 +695,9 @@ default boolean vault() {
* @param amount The amount you wish to remove from this account.
* @return True if a call to the corresponding transferHoldings method would return true, otherwise false.
*/
boolean canTransferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount);
default boolean canTransferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount) {
return canRemoveHoldings(fromIdentifier, amount) && canAddHoldings(toIdentifier, amount);
}

/**
* Used to determine if a call to the corresponding transferHoldings method would be successful. This method does not
Expand All @@ -692,7 +708,9 @@ default boolean vault() {
* @param world The name of the {@link World} associated with the amount.
* @return True if a call to the corresponding transferHoldings method would return true, otherwise false.
*/
boolean canTransferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world);
default boolean canTransferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world) {
return canRemoveHoldings(fromIdentifier, amount, world) && canAddHoldings(toIdentifier, amount, world);
}

/**
* Used to determine if a call to the corresponding transferHoldings method would be successful. This method does not
Expand All @@ -704,7 +722,9 @@ default boolean vault() {
* @param currency The {@link Currency} associated with the balance.
* @return True if a call to the corresponding transferHoldings method would return true, otherwise false.
*/
boolean canTransferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world, String currency);
default boolean canTransferHoldings(String fromIdentifier, String toIdentifier, BigDecimal amount, String world, String currency) {
return canRemoveHoldings(fromIdentifier, amount, world, currency) && canAddHoldings(toIdentifier, amount, world, currency);
}

/**
* Used to determine if a call to the corresponding transferHoldings method would be successful. This method does not
Expand All @@ -714,30 +734,42 @@ default boolean vault() {
* @param amount The amount you wish to remove from this account.
* @return True if a call to the corresponding transferHoldings method would return true, otherwise false.
*/
boolean canTransferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount);
default boolean canTransferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount) {
return canRemoveHoldings(fromIdentifier, amount) && canAddHoldings(toIdentifier, amount);
}

/**
* Used to determine if a call to the corresponding transferHoldings method would be successful. This method does not
* affect an account's funds.
* Used to determine if a call to the corresponding transferHoldings method would be successful.
* This method does not affect an account's funds.
*
* @param fromIdentifier The identifier of the account that the holdings will be coming from.
* @param toIdentifier The identifier of the account that the holdings will be going to.
* @param amount The amount you wish to remove from this account.
* @param world The name of the {@link World} associated with the amount.
* @return True if a call to the corresponding transferHoldings method would return true, otherwise false.
*
* @return True if a call to the corresponding transferHoldings method would return true,
* otherwise false.
*/
boolean canTransferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world);
default boolean canTransferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world) {
return canRemoveHoldings(fromIdentifier, amount, world) && canAddHoldings(toIdentifier, amount, world);
}

/**
* Used to determine if a call to the corresponding transferHoldings method would be successful. This method does not
* affect an account's funds.
* Used to determine if a call to the corresponding transferHoldings method would be successful.
* This method does not affect an account's funds.
*
* @param fromIdentifier The identifier of the account that the holdings will be coming from.
* @param toIdentifier The identifier of the account that the holdings will be going to.
* @param amount The amount you wish to remove from this account.
* @param world The name of the {@link World} associated with the amount.
* @param currency The {@link Currency} associated with the balance.
* @return True if a call to the corresponding transferHoldings method would return true, otherwise false.
*
* @return True if a call to the corresponding transferHoldings method would return true,
* otherwise false.
*/
boolean canTransferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world, String currency);
default boolean canTransferHoldings(UUID fromIdentifier, UUID toIdentifier, BigDecimal amount, String world, String currency) {
return canRemoveHoldings(fromIdentifier, amount, world, currency) && canAddHoldings(toIdentifier, amount, world, currency);
}

/**
* Formats a monetary amount into a more text-friendly version.
Expand Down

0 comments on commit 14b6c06

Please sign in to comment.