|
10 | 10 | import pro.cloudnode.smp.bankaccounts.Permissions; |
11 | 11 |
|
12 | 12 | import java.math.BigDecimal; |
13 | | -import java.util.Optional; |
14 | 13 |
|
15 | 14 | public final class Join implements Listener { |
16 | 15 | @EventHandler |
17 | 16 | public void onPlayerJoin(final @NotNull PlayerJoinEvent event) { |
18 | | - final Player player = event.getPlayer(); |
19 | | - final @NotNull Optional<@NotNull Double> startingBalance = BankAccounts.getInstance().config() |
20 | | - .startingBalance(); |
21 | | - startingBalance.ifPresent(aDouble -> BankAccounts.getInstance().getServer().getScheduler() |
22 | | - .runTaskAsynchronously(BankAccounts.getInstance(), () -> { |
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 | | - } |
28 | | - })); |
| 17 | + final @NotNull Player player = event.getPlayer(); |
| 18 | + final @NotNull BigDecimal startingBalance = BankAccounts.getInstance().config().startingBalance(); |
| 19 | + BankAccounts.getInstance().getServer().getScheduler().runTaskAsynchronously(BankAccounts.getInstance(), () -> { |
| 20 | + if (Account.getVaultAccount(player).isEmpty()) { |
| 21 | + // if the player already has a personal account, they will not be given starting balance |
| 22 | + final @NotNull BigDecimal balance = startingBalance.compareTo(BigDecimal.ZERO) <= 0 || Account.get(player, Account.Type.PERSONAL).length > 0 ? BigDecimal.ZERO : startingBalance; |
| 23 | + new Account(player, Account.Type.VAULT, null, balance, false).insert(); |
| 24 | + } |
| 25 | + }); |
29 | 26 | if (player.hasPermission(Permissions.NOTIFY_UPDATE)) { |
30 | 27 | BankAccounts.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(BankAccounts.getInstance(), () -> BankAccounts.checkForUpdates().ifPresent(latestVersion -> { |
31 | 28 | player.sendMessage(BankAccounts.getInstance().config().messagesUpdateAvailable(latestVersion)); |
|
0 commit comments