Skip to content

Commit a6cd174

Browse files
committed
📝 fix eco bits
1 parent 77aed96 commit a6cd174

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/main/java/fr/traqueur/currencies/providers/EcoBitProvider.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,34 @@
1010

1111
public class EcoBitProvider implements CurrencyProvider {
1212

13-
private final Currency currency;
13+
private Currency currency;
14+
private final String currencyName;
1415

1516
public EcoBitProvider(String currencyName) {
16-
this.currency = Currencies.getByID(currencyName);
17+
this.currencyName = currencyName;
18+
}
19+
20+
private void initialize() {
21+
if (currency == null) {
22+
this.currency = Currencies.getByID(currencyName);
23+
}
1724
}
1825

1926
@Override
2027
public void deposit(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
28+
initialize();
2129
CurrencyUtils.adjustBalance(offlinePlayer, currency, amount);
2230
}
2331

2432
@Override
2533
public void withdraw(OfflinePlayer offlinePlayer, BigDecimal amount, String reason) {
34+
initialize();
2635
CurrencyUtils.adjustBalance(offlinePlayer, currency, amount.negate());
2736
}
2837

2938
@Override
3039
public BigDecimal getBalance(OfflinePlayer offlinePlayer) {
40+
initialize();
3141
return CurrencyUtils.getBalance(offlinePlayer, currency);
3242
}
3343
}

0 commit comments

Comments
 (0)