@@ -50,7 +50,7 @@ public boolean execute(final @NotNull CommandSender sender, final @NotNull Strin
5050 }
5151 else switch (args [0 ]) {
5252 case "create" , "new" -> {
53- if ("--player" .equals (args [args .length - 1 ])) return null ;
53+ if ("--player" .equals (args [args .length - 2 ])) return null ;
5454 else if (!args [args .length - 1 ].isEmpty () && "--player" .startsWith (args [args .length - 1 ])) list .add ("--player" );
5555 else if (args .length == 2 ) {
5656 if (sender .hasPermission (Permissions .INVOICE_CREATE ) && sender .hasPermission (Permissions .INVOICE_CREATE_OTHER ))
@@ -84,7 +84,14 @@ else if (args.length == 3) {
8484 if (!sender .hasPermission (Permissions .INVOICE_SEND )) break ;
8585 if (args .length == 2 ) {
8686 if (sender .hasPermission (Permissions .INVOICE_SEND_OTHER )) list .addAll (Arrays .stream (Invoice .get ()).map (a -> a .id ).toList ());
87- else list .addAll (Arrays .stream (Invoice .get (BankAccounts .getOfflinePlayer (sender ))).map (a -> a .id ).toList ());
87+ else list .addAll (Arrays .stream (Invoice .get (BankAccounts .getOfflinePlayer (sender ), Account .get (BankAccounts .getOfflinePlayer (sender )))).filter (i -> i .transaction == null ).map (a -> a .id ).toList ());
88+ }
89+ if (args .length == 3 ) {
90+ final @ NotNull Optional <@ NotNull Invoice > invoice = Invoice .get (args [1 ]);
91+ if (invoice .isPresent () && (sender .hasPermission (Permissions .INVOICE_SEND_OTHER ) || invoice .get ().seller .owner .equals (BankAccounts .getOfflinePlayer (sender )))) {
92+ invoice .get ().buyer ().flatMap (buyer -> Optional .ofNullable (buyer .getPlayer ()))
93+ .ifPresent (player -> list .add (player .getName ()));
94+ }
8895 }
8996 }
9097 case "list" -> {
@@ -193,7 +200,7 @@ public static boolean details(final @NotNull CommandSender sender, @NotNull Stri
193200 final @ NotNull Optional <@ NotNull Invoice > invoice = Invoice .get (args [0 ]);
194201 if (invoice .isEmpty ()) return sendMessage (sender , BankAccounts .getInstance ().config ().messagesErrorsInvoiceNotFound ());
195202 if (!sender .hasPermission (Permissions .INVOICE_VIEW_OTHER )
196- && invoice .get ().buyer ().map (b -> b .getUniqueId ().equals (BankAccounts .getOfflinePlayer (sender ).getUniqueId ())).orElse (true )
203+ && ! invoice .get ().buyer ().map (b -> b .getUniqueId ().equals (BankAccounts .getOfflinePlayer (sender ).getUniqueId ())).orElse (true )
197204 && !invoice .get ().seller .owner .getUniqueId ().equals (BankAccounts .getOfflinePlayer (sender ).getUniqueId ())
198205 ) return sendMessage (sender , BankAccounts .getInstance ().config ().messagesErrorsInvoiceNotFound ());
199206
@@ -262,6 +269,8 @@ public static boolean send(final @NotNull CommandSender sender, @NotNull String
262269 return sendMessage (sender , BankAccounts .getInstance ().config ().messagesErrorsInvoiceNotFound ());
263270 if (invoice .get ().buyer ().isPresent () && !invoice .get ().buyer ().get ().getUniqueId ().equals (player .get ().getUniqueId ()) && !player .get ().hasPermission (Permissions .INVOICE_VIEW_OTHER ))
264271 return sendMessage (sender , BankAccounts .getInstance ().config ().messagesErrorsInvoiceCannotSend ());
272+ if (invoice .get ().transaction != null )
273+ return sendMessage (sender , BankAccounts .getInstance ().config ().messagesErrorsInvoiceAlreadyPaid ());
265274
266275 sendMessage (player .get (), BankAccounts .getInstance ().config ().messagesInvoiceReceived (invoice .get ()));
267276 return sendMessage (sender , BankAccounts .getInstance ().config ().messagesInvoiceSent (invoice .get ()));
0 commit comments