Skip to content

Commit 8e0f192

Browse files
committed
tabcomlpete invoice send recipient
1 parent 81f9408 commit 8e0f192

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/pro/cloudnode/smp/bankaccounts/commands/InvoiceCommand.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ else if (args.length == 3) {
8686
if (sender.hasPermission(Permissions.INVOICE_SEND_OTHER)) list.addAll(Arrays.stream(Invoice.get()).map(a -> a.id).toList());
8787
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());
8888
}
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+
}
95+
}
8996
}
9097
case "list" -> {
9198
if (!sender.hasPermission(Permissions.INVOICE_VIEW)) break;

0 commit comments

Comments
 (0)