File tree Expand file tree Collapse file tree
src/main/java/fr/traqueur/currencies/providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111public 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}
You can’t perform that action at this time.
0 commit comments