99import org .bukkit .command .CommandSender ;
1010import org .bukkit .entity .Player ;
1111import org .bukkit .plugin .Plugin ;
12+ import org .checkerframework .checker .units .qual .A ;
1213import org .incendo .cloud .SenderMapper ;
1314import org .incendo .cloud .annotations .AnnotationParser ;
1415import org .incendo .cloud .annotations .Argument ;
1819import org .incendo .cloud .execution .ExecutionCoordinator ;
1920import org .incendo .cloud .paper .LegacyPaperCommandManager ;
2021import org .incendo .cloud .paper .PaperCommandManager ;
22+ import org .incendo .cloud .paper .util .sender .PaperSimpleSenderMapper ;
23+ import org .incendo .cloud .paper .util .sender .PlayerSource ;
24+ import org .incendo .cloud .paper .util .sender .Source ;
2125
2226import javax .annotation .Nonnull ;
2327
@@ -27,10 +31,10 @@ public class PostCommand {
2731
2832 public PostCommand (@ Nonnull Plugin plugin , @ Nonnull PostOfficeMenu postOfficeMenu ) {
2933 this .postOfficeMenu = postOfficeMenu ;
30- var commandManager = PaperCommandManager .builder ()
34+ var commandManager = PaperCommandManager .builder (PaperSimpleSenderMapper . simpleSenderMapper () )
3135 .executionCoordinator (ExecutionCoordinator .simpleCoordinator ())
3236 .buildOnEnable (plugin );
33- var annotationParser = new AnnotationParser <>(commandManager , CommandSourceStack .class );
37+ var annotationParser = new AnnotationParser <>(commandManager , Source .class );
3438 annotationParser .parse (this );
3539 }
3640
@@ -53,22 +57,35 @@ public void commandOpen(
5357 @ Command ("post view <player>" )
5458 @ Permission ("democracypost.view" )
5559 public void commandView (
56- @ Nonnull CommandSourceStack senderSourceStack ,
60+ @ Nonnull PlayerSource playerSource ,
5761 @ Nonnull @ Argument (value = "player" ) OfflinePlayer who ) {
58- CommandSender sender = senderSourceStack .getSender ();
59- if (!(senderSourceStack .getExecutor () instanceof Player executor )) {
60- sender .sendMessage ("Executor must be an instance of a player!" );
61- return ;
62- }
62+ Player sender = playerSource .source ();
6363 // Prevent the sender from going "back"
64- InventoryGui .clearHistory (executor );
64+ InventoryGui .clearHistory (sender );
6565 this .postOfficeMenu .createParcelListUi (who .getUniqueId ()).whenComplete ((gui , throwable ) -> {
6666 if (throwable != null ) {
6767 sender .sendMessage (Component .text ("Error occurred when retrieving packages for " + who .getName (),
6868 NamedTextColor .RED ));
6969 return ;
7070 }
71- gui .show (executor );
71+ gui .show (sender );
72+ });
73+ }
74+
75+ @ Command ("post view <player> <targetPlayer>" )
76+ @ Permission ("democracypost.view.other" )
77+ public void commandViewOther (
78+ @ Nonnull @ Argument (value = "player" ) OfflinePlayer who ,
79+ @ Nonnull @ Argument (value = "targetPlayer" ) Player toOpen ) {
80+ // Prevent the sender from going "back"
81+ InventoryGui .clearHistory (toOpen );
82+ this .postOfficeMenu .createParcelListUi (who .getUniqueId ()).whenComplete ((gui , throwable ) -> {
83+ if (throwable != null ) {
84+ toOpen .sendMessage (Component .text ("Error occurred when retrieving packages for " + who .getName (),
85+ NamedTextColor .RED ));
86+ return ;
87+ }
88+ gui .show (toOpen );
7289 });
7390 }
7491
0 commit comments