Skip to content

Commit b12bc33

Browse files
committed
invoice notifications config
1 parent 5068b21 commit b12bc33

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/main/java/pro/cloudnode/smp/bankaccounts/BankConfig.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,16 @@ public int invoicePerPage() {
421421
return config.getInt("invoice.per-page");
422422
}
423423

424+
// invoice.notify.join
425+
public boolean invoiceNotifyJoin() {
426+
return config.getBoolean("invoice.notify.join");
427+
}
428+
429+
// invoice.notify.interval
430+
public int invoiceNotifyInterval() {
431+
return config.getInt("invoice.notify.interval");
432+
}
433+
424434
// messages.command-usage
425435
public @NotNull Component messagesCommandUsage(final @NotNull String command, final @NotNull String arguments) {
426436
return MiniMessage.miniMessage().deserialize(
@@ -1358,6 +1368,17 @@ public int invoicePerPage() {
13581368
);
13591369
}
13601370

1371+
// messages.invoice.notify
1372+
public @NotNull Optional<@NotNull Component> messagesInvoiceNotify(final int unpaid) {
1373+
final @NotNull String message = Objects.requireNonNull(config.getString("messages.invoice.notify"));
1374+
if (message.isBlank()) return Optional.empty();
1375+
return Optional.of(MiniMessage.miniMessage().deserialize(
1376+
message
1377+
.replace("<unpaid>", String.valueOf(unpaid)),
1378+
Formatter.choice("unpaid-choice", unpaid)
1379+
));
1380+
}
1381+
13611382
// messages.update-available
13621383
public @NotNull Component messagesUpdateAvailable(final @NotNull String version) {
13631384
return MiniMessage.miniMessage().deserialize(

src/main/resources/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ invoice:
259259
# Number of invoices to return per page
260260
per-page: 10
261261

262+
# Notifications for unpaid invoices (see messages.invoice.notify)
263+
notify:
264+
# Send message when a player joins
265+
join: true
266+
# Periodically send message while player is online
267+
# Interval between messages in seconds
268+
# Set to 0 or negative to disable
269+
interval: 300
270+
262271
# Messages
263272
messages:
264273
# Command usage message
@@ -583,6 +592,14 @@ messages:
583592
# Same placeholders as details
584593
footer: "<hover:show_text:'Click to see the previous page'><click:run_command:<cmd-prev>><green>← Previous</green></click></hover> <gray>Page <page></gray> <hover:show_text:'Click to see the next page'><click:run_command:<cmd-next>><green>Next →</green></click></hover>"
585594

595+
# You have unpaid invoices
596+
# Sent periodically and on login (as configured in invoice.notify)
597+
# Set to empty string to disable
598+
# Placeholders:
599+
# <unpaid> - number of unpaid invoices></yellow>."
600+
# <unpaid-choice> - choice placeholder for unpaid invoices; see https://docs.advntr.dev/minimessage/dynamic-replacements.html#insert-a-choice
601+
notify: "<click:run_command:/invoice list><hover:show_text:'Click to view unpaid invoices'><yellow>(!) You have <gray><unpaid></gray> unpaid invoice<unpaid-choice:'0<s'>. <gray>Click to view.</gray></yellow></hover></click>"
602+
586603
# New version available
587604
# Placeholders:
588605
# <version> - New version

0 commit comments

Comments
 (0)