# Balance

These functions are found in **RoyaleEconomy.apiHandler.balance:**

**double getBalance(String player) -** Gets the purse balance of a player. String player could be either their username or their UUID parsed as string.\
If you can choose between username and UUID, go with the UUID.

{% code title="getBalance() example" %}

```java
Player p = e.getPlayer();
double playerBalance = RoyaleEconomy.apiHandler.balance.getBalance(p.getUniqueId().toString());
//or
double playerBalanceAlternative = RoyaleEconomy.apiHandler.balance.getBalance(p.getName());
```

{% endcode %}

**double getBankBalance(String playerUUID) -** Gets the purse balance of a player. String playerUUID is the UUID of the player parsed as string.

{% code title="getBankBalance() example" %}

```java
Player p = e.getPlayer();
double playerBalance = RoyaleEconomy.apiHandler.balance.getBalance(p.getUniqueId().toString());
```

{% endcode %}

**double getSharedBankBalance(String bankID) -** Gets the purse balance of a player. String bankID could be get from player's uuid via getSharedBankID(String playerUUID).

{% code title="getSharedBankBalance() example" %}

```java
Player p = e.getPlayer();
String bankID = RoyaleEconomy.apiHandler.sharedBank.getSharedBankID(p.getUniqueId().toString);
double sharedBankBalance = RoyaleEconomy.apiHandler.balance.getSharedBankBalance(bankID);
```

{% endcode %}

Similar to the functions above, we have the void functions\
&#x20;   \- **addBalance**(String player, double toAdd)\
&#x20;   \- **removeBalance**(String player, double toRemove)\
&#x20;   \- **setBalance**(String player, double toSet)\
&#x20;   \- **addBankBalance**(String playerUUID, double toAdd)\
&#x20;   \- **removeBankBalance**(String playerUUID, double toRemove)\
&#x20;   \- **setBankBalance**(String playerUUID, double toSet)\
&#x20;   \- **addSharedBankBalance**(String bankID, double toAdd)\
&#x20;   \- **removeSharedBankBalance**(String bankID, double toRemove)\
&#x20;   \- **setSharedBankBalance**(String bankID, double toSet)

Using the functions above you can modify balances but make sure you check the amount you add/remove/set because the plugin won't check for negative values and there must be no negative values.
