1
1
package net .thenextlvl .service .wrapper ;
2
2
3
+ import net .kyori .adventure .text .serializer .plain .PlainTextComponentSerializer ;
3
4
import net .milkbowl .vault .economy .Economy ;
4
5
import net .milkbowl .vault .economy .EconomyResponse ;
5
6
import net .thenextlvl .service .api .economy .Account ;
@@ -52,22 +53,25 @@ public boolean hasBankSupport() {
52
53
53
54
@ Override
54
55
public int fractionalDigits () {
55
- return economyController .fractionalDigits ();
56
+ return economyController .getDefaultCurrency (). getFractionalDigits ();
56
57
}
57
58
58
59
@ Override
59
60
public String format (double amount ) {
60
- return economyController .format (amount );
61
+ var format = economyController .getDefaultCurrency ().format (amount , Locale .US );
62
+ return PlainTextComponentSerializer .plainText ().serialize (format );
61
63
}
62
64
63
65
@ Override
64
66
public String currencyNamePlural () {
65
- return economyController .getCurrencyNamePlural (Locale .US );
67
+ var name = economyController .getDefaultCurrency ().getDisplayNamePlural (Locale .US );
68
+ return PlainTextComponentSerializer .plainText ().serialize (name );
66
69
}
67
70
68
71
@ Override
69
72
public String currencyNameSingular () {
70
- return economyController .getCurrencyNameSingular (Locale .US );
73
+ var name = economyController .getDefaultCurrency ().getDisplayNameSingular (Locale .US );
74
+ return PlainTextComponentSerializer .plainText ().serialize (name );
71
75
}
72
76
73
77
@ Override
@@ -110,7 +114,7 @@ public double getBalance(String playerName, String worldName) {
110
114
@ Override
111
115
public double getBalance (OfflinePlayer player , String worldName ) {
112
116
return getAccount (player , worldName )
113
- .map (Account :: getBalance )
117
+ .map (account -> account . getBalance ( economyController . getDefaultCurrency ()) )
114
118
.map (Number ::doubleValue )
115
119
.orElse (0.0 );
116
120
}
@@ -154,8 +158,8 @@ public EconomyResponse withdrawPlayer(String playerName, String worldName, doubl
154
158
@ Override
155
159
public EconomyResponse withdrawPlayer (OfflinePlayer player , String worldName , double amount ) {
156
160
return getAccount (player , worldName ).map (account -> {
157
- var balance = account .getBalance ();
158
- var withdraw = account .withdraw (amount );
161
+ var balance = account .getBalance (economyController . getDefaultCurrency () );
162
+ var withdraw = account .withdraw (amount , economyController . getDefaultCurrency () );
159
163
var responseType = amount != 0 && balance .equals (withdraw ) ? FAILURE : SUCCESS ;
160
164
return new EconomyResponse (amount , withdraw .doubleValue (), responseType , null );
161
165
}).orElseGet (() -> new EconomyResponse (amount , 0 , FAILURE , null ));
@@ -180,8 +184,8 @@ public EconomyResponse depositPlayer(String name, String worldName, double amoun
180
184
@ Override
181
185
public EconomyResponse depositPlayer (OfflinePlayer player , String worldName , double amount ) {
182
186
return getAccount (player , worldName ).map (account -> {
183
- var balance = account .getBalance ();
184
- var deposit = account .deposit (amount );
187
+ var balance = account .getBalance (economyController . getDefaultCurrency () );
188
+ var deposit = account .deposit (amount , economyController . getDefaultCurrency () );
185
189
var responseType = amount != 0 && balance .equals (deposit ) ? FAILURE : SUCCESS ;
186
190
return new EconomyResponse (amount , deposit .doubleValue (), responseType , null );
187
191
}).orElseGet (() -> new EconomyResponse (amount , 0 , FAILURE , null ));
@@ -211,7 +215,8 @@ public EconomyResponse deleteBank(String name) {
211
215
public EconomyResponse bankBalance (String name ) {
212
216
try {
213
217
var bank = bankController ().tryGetBank (name ).get ();
214
- return new EconomyResponse (0 , bank .getBalance ().doubleValue (), SUCCESS , null );
218
+ var balance = bank .getBalance (economyController .getDefaultCurrency ());
219
+ return new EconomyResponse (0 , balance .doubleValue (), SUCCESS , null );
215
220
} catch (InterruptedException | ExecutionException e ) {
216
221
return new EconomyResponse (0 , 0 , FAILURE , e .getMessage ());
217
222
}
@@ -221,7 +226,7 @@ public EconomyResponse bankBalance(String name) {
221
226
public EconomyResponse bankHas (String name , double amount ) {
222
227
try {
223
228
var bank = bankController ().tryGetBank (name ).get ();
224
- var balance = bank .getBalance ().doubleValue ();
229
+ var balance = bank .getBalance (economyController . getDefaultCurrency () ).doubleValue ();
225
230
var response = balance >= amount ? SUCCESS : FAILURE ;
226
231
return new EconomyResponse (amount , balance , response , null );
227
232
} catch (InterruptedException | ExecutionException e ) {
@@ -233,7 +238,7 @@ public EconomyResponse bankHas(String name, double amount) {
233
238
public EconomyResponse bankWithdraw (String name , double amount ) {
234
239
try {
235
240
var bank = bankController ().tryGetBank (name ).get ();
236
- var balance = bank .withdraw (amount ).doubleValue ();
241
+ var balance = bank .withdraw (amount , economyController . getDefaultCurrency () ).doubleValue ();
237
242
var response = balance >= amount ? SUCCESS : FAILURE ;
238
243
return new EconomyResponse (amount , balance , response , null );
239
244
} catch (InterruptedException | ExecutionException e ) {
@@ -245,7 +250,7 @@ public EconomyResponse bankWithdraw(String name, double amount) {
245
250
public EconomyResponse bankDeposit (String name , double amount ) {
246
251
try {
247
252
var bank = bankController ().tryGetBank (name ).get ();
248
- var balance = bank .deposit (amount ).doubleValue ();
253
+ var balance = bank .deposit (amount , economyController . getDefaultCurrency () ).doubleValue ();
249
254
var response = balance >= amount ? SUCCESS : FAILURE ;
250
255
return new EconomyResponse (amount , balance , response , null );
251
256
} catch (InterruptedException | ExecutionException e ) {
@@ -264,7 +269,8 @@ public EconomyResponse isBankOwner(String name, OfflinePlayer player) {
264
269
try {
265
270
var bank = bankController ().tryGetBank (name ).get ();
266
271
var response = player != null && bank .getOwner ().equals (player .getUniqueId ()) ? SUCCESS : FAILURE ;
267
- return new EconomyResponse (0 , bank .getBalance ().doubleValue (), response , null );
272
+ var balance = bank .getBalance (economyController .getDefaultCurrency ());
273
+ return new EconomyResponse (0 , balance .doubleValue (), response , null );
268
274
} catch (InterruptedException | ExecutionException e ) {
269
275
return new EconomyResponse (0 , 0 , FAILURE , e .getMessage ());
270
276
}
@@ -281,7 +287,8 @@ public EconomyResponse isBankMember(String name, OfflinePlayer player) {
281
287
try {
282
288
var bank = bankController ().tryGetBank (name ).get ();
283
289
var response = player != null && bank .isMember (player .getUniqueId ()) ? SUCCESS : FAILURE ;
284
- return new EconomyResponse (0 , bank .getBalance ().doubleValue (), response , null );
290
+ var balance = bank .getBalance (economyController .getDefaultCurrency ());
291
+ return new EconomyResponse (0 , balance .doubleValue (), response , null );
285
292
} catch (InterruptedException | ExecutionException e ) {
286
293
return new EconomyResponse (0 , 0 , FAILURE , e .getMessage ());
287
294
}
0 commit comments