From 70de83827d2bae90597fbf758a17525353dcad1a Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Fri, 8 Jan 2021 15:35:00 -0500 Subject: [PATCH] Allow paying offline users via /pay (#3625) Closes #3577. --- .../com/earth2me/essentials/commands/Commandpay.java | 12 +++++++++++- Essentials/src/main/resources/messages.properties | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java index be83eefec..7d8ffed0e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java @@ -43,8 +43,18 @@ public class Commandpay extends EssentialsLoopCommand { throw new Exception(tl("minimumPayAmount", NumberUtil.displayCurrencyExactly(ess.getSettings().getMinimumPayAmount(), ess))); } final AtomicBoolean informToConfirm = new AtomicBoolean(false); - loopOnlinePlayersConsumer(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], player -> { + final boolean canPayOffline = user.isAuthorized("essentials.pay.offline"); + if (!canPayOffline && args[0].equals("**")) { + user.sendMessage(tl("payOffline")); + return; + } + loopOfflinePlayersConsumer(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], player -> { try { + if (player.getBase() != null && !player.getBase().isOnline() && !canPayOffline) { + user.sendMessage(tl("payOffline")); + return; + } + if (!player.isAcceptingPay() || (ess.getSettings().isPayExcludesIgnoreList() && player.isIgnoredPlayer(user))) { user.sendMessage(tl("notAcceptingPay", player.getDisplayName())); return; diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 6c9a9b190..a7eaef9a4 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -567,6 +567,7 @@ payConfirmToggleOn=\u00a76You will now be prompted to confirm payments. payDisabledFor=\u00a76Disabled accepting payments for \u00a7c{0}\u00a76. payEnabledFor=\u00a76Enabled accepting payments for \u00a7c{0}\u00a76. payMustBePositive=\u00a74Amount to pay must be positive. +payOffline=\u00a74You cannot pay offline users. payToggleOff=\u00a76You are no longer accepting payments. payToggleOn=\u00a76You are now accepting payments. payconfirmtoggleCommandDescription=Toggles whether you are prompted to confirm payments.