Skip to content

Commit dad2535

Browse files
committed
only issue starting balance if player also has no personal accounts
1 parent 7710801 commit dad2535

File tree

1 file changed

+5
-2
lines changed
  • src/main/java/pro/cloudnode/smp/bankaccounts/events

1 file changed

+5
-2
lines changed

src/main/java/pro/cloudnode/smp/bankaccounts/events/Join.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ public void onPlayerJoin(final @NotNull PlayerJoinEvent event) {
2020
.startingBalance();
2121
startingBalance.ifPresent(aDouble -> BankAccounts.getInstance().getServer().getScheduler()
2222
.runTaskAsynchronously(BankAccounts.getInstance(), () -> {
23-
if (Account.getVaultAccount(player).isEmpty())
24-
new Account(player, Account.Type.VAULT, null, BigDecimal.valueOf(aDouble), false).insert();
23+
if (Account.getVaultAccount(player).isEmpty()) {
24+
// if the player already has a personal account, they will not be given starting balance
25+
final @NotNull BigDecimal balance = Account.get(player, Account.Type.PERSONAL).length > 0 ? BigDecimal.ZERO : BigDecimal.valueOf(aDouble);
26+
new Account(player, Account.Type.VAULT, null, balance, false).insert();
27+
}
2528
}));
2629
if (player.hasPermission(Permissions.NOTIFY_UPDATE)) {
2730
BankAccounts.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(BankAccounts.getInstance(), () -> BankAccounts.checkForUpdates().ifPresent(latestVersion -> {

0 commit comments

Comments
 (0)