@@ -26,23 +26,23 @@ public class BalanceCommand {
26
26
27
27
public void register () {
28
28
var command = Commands .literal ("balance" )
29
- .requires (stack -> stack .getSender ().hasPermission ("economist.admin " ))
29
+ .requires (stack -> stack .getSender ().hasPermission ("economist.balance " ))
30
30
.then (Commands .argument ("player" , CustomArgumentTypes .cachedOfflinePlayer ())
31
+ .requires (stack -> stack .getSender ().hasPermission ("economist.balance.others" ))
31
32
.then (Commands .argument ("world" , ArgumentTypes .world ())
33
+ .requires (stack -> stack .getSender ().hasPermission ("economist.balance.world" ))
32
34
.executes (context -> {
33
35
var player = context .getArgument ("player" , OfflinePlayer .class );
34
36
var world = context .getArgument ("world" , World .class );
35
37
return balance (context , player , world );
36
38
}))
37
39
.executes (context -> {
38
- var target = context .getArgument ("player" , OfflinePlayer .class );
39
- if (context .getSource ().getSender () instanceof Player player )
40
- return balance (context , target , player .getWorld ());
41
- return balance (context , target , null );
40
+ var player = context .getArgument ("player" , OfflinePlayer .class );
41
+ return balance (context , player , null );
42
42
}))
43
43
.executes (context -> {
44
44
if (context .getSource ().getSender () instanceof Player player )
45
- return balance (context , player , player . getWorld () );
45
+ return balance (context , player , null );
46
46
throw new IllegalArgumentException ("No player defined" );
47
47
})
48
48
.build ();
@@ -59,26 +59,22 @@ private int balance(CommandContext<CommandSourceStack> context, OfflinePlayer pl
59
59
.thenAccept (optional -> optional .ifPresentOrElse (account -> {
60
60
var locale = sender instanceof Player p ? p .locale () : Locale .US ;
61
61
62
- var message = world != null && world . equals ( sender instanceof Player p ? p . getWorld () : null )
63
- ? (player .equals (sender ) ? "account.balance.self" : "account.balance.other" )
64
- : (player .equals (sender ) ? "account.balance.world. self" : "account.balance.world .other" );
62
+ var message = world != null
63
+ ? (player .equals (sender ) ? "account.balance.world. self" : "account.balance.world .other" )
64
+ : (player .equals (sender ) ? "account.balance.self" : "account.balance.other" );
65
65
66
66
plugin .bundle ().sendMessage (sender , message ,
67
67
Placeholder .parsed ("player" , String .valueOf (player .getName ())),
68
68
Placeholder .parsed ("balance" , controller .format (account .getBalance (), locale )),
69
- Placeholder .parsed ("currency" , account .getBalance ().intValueExact () == 1
69
+ Placeholder .parsed ("currency" , account .getBalance ().intValue () == 1
70
70
? controller .getCurrencyNameSingular (locale )
71
71
: controller .getCurrencyNamePlural (locale )),
72
- Placeholder .parsed ("symbol" , controller .getCurrencySymbol ()));
73
-
74
- }, () -> {
75
- var message = world != null && !world .equals (sender instanceof Player p ? p .getWorld () : null )
76
- ? "account.not-found.world" : "account.not-found" ;
77
-
78
- plugin .bundle ().sendMessage (sender , message ,
79
- Placeholder .parsed ("player" , String .valueOf (player .getName ())),
72
+ Placeholder .parsed ("symbol" , controller .getCurrencySymbol ()),
80
73
Placeholder .parsed ("world" , world != null ? world .key ().asString () : "null" ));
81
- }));
74
+
75
+ }, () -> plugin .bundle ().sendMessage (sender , world != null ? "account.not-found.world" : "account.not-found" ,
76
+ Placeholder .parsed ("player" , String .valueOf (player .getName ())),
77
+ Placeholder .parsed ("world" , world != null ? world .key ().asString () : "null" ))));
82
78
83
79
return Command .SINGLE_SUCCESS ;
84
80
}
0 commit comments