@@ -52,59 +52,67 @@ public static LiteralCommandNode<CommandSourceStack> create(EconomistPlugin plug
5252 private static ArgumentBuilder <CommandSourceStack , ?> reset (EconomistPlugin plugin ) {
5353 return Commands .literal ("reset" )
5454 .then (Commands .argument ("player" , CustomArgumentTypes .cachedOfflinePlayer ())
55- .then (Commands .argument ("world" , ArgumentTypes .world ()).executes (context -> {
56- var player = context .getArgument ("player" , OfflinePlayer .class );
57- var world = context .getArgument ("world" , World .class );
58- return execute (context , "balance.reset.world" , List .of (player ), plugin .config .startBalance , world , Account ::setBalance , plugin );
59- })).executes (context -> {
55+ .then (Commands .argument ("world" , ArgumentTypes .world ())
56+ .requires (stack -> plugin .config .accounts .perWorld )
57+ .executes (context -> {
58+ var player = context .getArgument ("player" , OfflinePlayer .class );
59+ var world = context .getArgument ("world" , World .class );
60+ return execute (context , "balance.reset.world" , List .of (player ), plugin .config .startBalance , world , Account ::setBalance , plugin );
61+ })).executes (context -> {
6062 var player = context .getArgument ("player" , OfflinePlayer .class );
6163 return execute (context , "balance.reset" , List .of (player ), plugin .config .startBalance , null , Account ::setBalance , plugin );
6264 }))
6365 .then (Commands .argument ("players" , ArgumentTypes .players ())
64- .then (Commands .argument ("world" , ArgumentTypes .world ()).executes (context -> {
65- var players = context .getArgument ("players" , PlayerSelectorArgumentResolver .class );
66- var resolve = players .resolve (context .getSource ());
67- var world = context .getArgument ("world" , World .class );
68- return execute (context , "balance.reset.world" , resolve , plugin .config .startBalance , world , Account ::setBalance , plugin );
69- })).executes (context -> {
66+ .then (Commands .argument ("world" , ArgumentTypes .world ())
67+ .requires (stack -> plugin .config .accounts .perWorld )
68+ .executes (context -> {
69+ var players = context .getArgument ("players" , PlayerSelectorArgumentResolver .class );
70+ var resolve = players .resolve (context .getSource ());
71+ var world = context .getArgument ("world" , World .class );
72+ return execute (context , "balance.reset.world" , resolve , plugin .config .startBalance , world , Account ::setBalance , plugin );
73+ })).executes (context -> {
7074 var players = context .getArgument ("players" , PlayerSelectorArgumentResolver .class );
7175 var resolve = players .resolve (context .getSource ());
7276 return execute (context , "balance.reset" , resolve , plugin .config .startBalance , null , Account ::setBalance , plugin );
7377 }));
7478 }
7579
7680 private static ArgumentBuilder <CommandSourceStack , ?> create (String command , String successMessage , String successMessageWorld ,
77- BiFunction <Account , Number , BigDecimal > function , Double minimum , EconomistPlugin plugin ) {
81+ BiFunction <Account , Number , BigDecimal > function , Double minimum , EconomistPlugin plugin ) {
7882 return Commands .literal (command )
7983 .then (Commands .argument ("player" , CustomArgumentTypes .cachedOfflinePlayer ())
8084 .then (Commands .argument ("amount" , DoubleArgumentType .doubleArg (minimum ))
81- .then (Commands .argument ("world" , ArgumentTypes .world ()).executes (context -> {
82- var player = context .getArgument ("player" , OfflinePlayer .class );
83- var amount = context .getArgument ("amount" , Double .class );
84- var world = context .getArgument ("world" , World .class );
85- return execute (context , successMessageWorld , List .of (player ), amount , world , function , plugin );
86- })).executes (context -> {
85+ .then (Commands .argument ("world" , ArgumentTypes .world ())
86+ .requires (stack -> plugin .config .accounts .perWorld )
87+ .executes (context -> {
88+ var player = context .getArgument ("player" , OfflinePlayer .class );
89+ var amount = context .getArgument ("amount" , Double .class );
90+ var world = context .getArgument ("world" , World .class );
91+ return execute (context , successMessageWorld , List .of (player ), amount , world , function , plugin );
92+ })).executes (context -> {
8793 var player = context .getArgument ("player" , OfflinePlayer .class );
8894 var amount = context .getArgument ("amount" , Double .class );
8995 return execute (context , successMessage , List .of (player ), amount , null , function , plugin );
9096 })))
9197 .then (Commands .argument ("players" , ArgumentTypes .players ())
9298 .then (Commands .argument ("amount" , DoubleArgumentType .doubleArg (minimum ))
93- .then (Commands .argument ("world" , ArgumentTypes .world ()).executes (context -> {
94- var players = context .getArgument ("players" , PlayerSelectorArgumentResolver .class );
95- var amount = context .getArgument ("amount" , Double .class );
96- var world = context .getArgument ("world" , World .class );
97- return execute (context , successMessageWorld , List .copyOf (players .resolve (context .getSource ())), amount , world , function , plugin );
98- })).executes (context -> {
99+ .then (Commands .argument ("world" , ArgumentTypes .world ())
100+ .requires (stack -> plugin .config .accounts .perWorld )
101+ .executes (context -> {
102+ var players = context .getArgument ("players" , PlayerSelectorArgumentResolver .class );
103+ var amount = context .getArgument ("amount" , Double .class );
104+ var world = context .getArgument ("world" , World .class );
105+ return execute (context , successMessageWorld , List .copyOf (players .resolve (context .getSource ())), amount , world , function , plugin );
106+ })).executes (context -> {
99107 var players = context .getArgument ("players" , PlayerSelectorArgumentResolver .class );
100108 var amount = context .getArgument ("amount" , Double .class );
101109 return execute (context , successMessage , List .copyOf (players .resolve (context .getSource ())), amount , null , function , plugin );
102110 })));
103111 }
104112
105113 private static int execute (CommandContext <CommandSourceStack > context , String successMessage ,
106- Collection <? extends OfflinePlayer > players , Number amount , @ Nullable World world ,
107- BiFunction <Account , Number , BigDecimal > function , EconomistPlugin plugin ) {
114+ Collection <? extends OfflinePlayer > players , Number amount , @ Nullable World world ,
115+ BiFunction <Account , Number , BigDecimal > function , EconomistPlugin plugin ) {
108116 var sender = context .getSource ().getSender ();
109117 var locale = sender instanceof Player p ? p .locale () : Locale .US ;
110118 if (!players .isEmpty ()) players .forEach (player -> (world != null
0 commit comments