11package dev .booky .craftattack .commands ;
22// Created by booky10 in CraftAttack (15:36 29.10.23)
33
4+ import com .destroystokyo .paper .profile .PlayerProfile ;
45import dev .booky .craftattack .CaManager ;
56import dev .booky .craftattack .utils .CaConfig ;
67import dev .jorel .commandapi .CommandAPICommand ;
7- import dev .jorel .commandapi .arguments .OfflinePlayerArgument ;
8+ import dev .jorel .commandapi .arguments .PlayerProfileArgument ;
89import dev .jorel .commandapi .exceptions .WrapperCommandSyntaxException ;
910import dev .jorel .commandapi .executors .CommandArguments ;
1011import dev .jorel .commandapi .executors .PlayerCommandExecutor ;
2324import java .util .ArrayList ;
2425import java .util .Comparator ;
2526import java .util .List ;
27+ import java .util .Objects ;
2628import java .util .Optional ;
2729import java .util .Set ;
2830import java .util .UUID ;
@@ -44,7 +46,7 @@ public MineStatsCommand(String objectiveName) {
4446 super (objectiveName );
4547 this .objectiveName = objectiveName ;
4648
47- this .withOptionalArguments (new OfflinePlayerArgument ("target" ));
49+ this .withOptionalArguments (new PlayerProfileArgument ("target" ));
4850
4951 this .withPermission ("craftattack.command.minestats." + objectiveName );
5052 this .executesPlayer (this );
@@ -76,13 +78,16 @@ public void run(Player sender, CommandArguments args) throws WrapperCommandSynta
7678 }
7779
7880 // if there was an explicit target specified, look up only itself
79- Optional <Integer > targetScore = args .<OfflinePlayer >getOptionalUnchecked ("target" )
80- .map (objective ::getScore )
81- .map (Score ::getScore );
82- if (targetScore .isPresent ()) {
83- sender .sendMessage (CaManager .getPrefix ().append (translatable (
84- "ca.command.mine-stats.value" , NamedTextColor .GREEN ,
85- text (this .objectiveName ), text (targetScore .get ()))));
81+ Optional <List <PlayerProfile >> targets = args .<List <PlayerProfile >>getOptionalUnchecked ("target" )
82+ .filter (list -> !list .isEmpty ());
83+ if (targets .isPresent ()) {
84+ for (PlayerProfile target : targets .get ()) {
85+ String name = Objects .requireNonNull (target .getName ());
86+ int score = objective .getScore (name ).getScore ();
87+ sender .sendMessage (CaManager .getPrefix ().append (translatable (
88+ "ca.command.mine-stats.value" , NamedTextColor .GREEN ,
89+ text (this .objectiveName ), text (score ))));
90+ }
8691 return ;
8792 }
8893
0 commit comments