Skip to content

Commit ef7a993

Browse files
committed
⚙️ adjust getBalance in VaultHook
Took 4 minutes
1 parent 4648323 commit ef7a993

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

jitpack.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
jdk:
22
- openjdk16
33
before_install:
4-
- echo "Before Install"
5-
- bash ensure-java-16 install
6-
install:
7-
- echo "Install"
8-
- if ! bash ensure-java-16 use; then source ~/.sdkman/bin/sdkman-init.sh; fi
9-
- java -version
10-
- mvn install
4+
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
5+
- source ./install-jdk.sh --feature 16 --license GPL

src/main/java/ca/tweetzy/funds/hooks/VaultHook.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ public boolean hasAccount(String playerName, String worldName) {
9090
public double getBalance(OfflinePlayer player) {
9191
final Account account = Funds.getAccountManager().getAccount(player);
9292
final Currency currency = Funds.getCurrencyManager().getVaultOrFirst();
93-
return account != null && currency != null ? account.getCurrencies().get(currency) : 0D;
93+
94+
if (account != null && currency != null) {
95+
return account.getCurrencies().getOrDefault(currency, 0D);
96+
}
97+
98+
return 0D;
9499
}
95100

96101
@Override
@@ -102,7 +107,12 @@ public double getBalance(OfflinePlayer player, String world) {
102107
public double getBalance(String playerName) {
103108
final Account account = Funds.getAccountManager().getAccount(playerName);
104109
final Currency currency = Funds.getCurrencyManager().getVaultOrFirst();
105-
return account != null && currency != null ? account.getCurrencies().get(currency) : 0D;
110+
111+
if (account != null && currency != null) {
112+
return account.getCurrencies().getOrDefault(currency, 0D);
113+
}
114+
115+
return 0D;
106116
}
107117

108118
@Override

0 commit comments

Comments
 (0)