mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-07-02 10:43:51 +00:00
Implement player based toggle for pay confirmation prompts. Fixes #1032
This commit adds a new `/payconfirmtoggle` command with `/payconfirmon` and `/payconfirmoff` as well.
This commit is contained in:
parent
442d97a1b1
commit
5f83766dc1
|
@ -174,6 +174,10 @@ public interface IUser {
|
||||||
boolean isAcceptingPay();
|
boolean isAcceptingPay();
|
||||||
|
|
||||||
void setAcceptingPay(boolean acceptingPay);
|
void setAcceptingPay(boolean acceptingPay);
|
||||||
|
|
||||||
|
boolean isPromptingPayConfirm();
|
||||||
|
|
||||||
|
void setPromptingPayConfirm(boolean prompt);
|
||||||
|
|
||||||
Map<User, BigDecimal> getConfirmingPayments();
|
Map<User, BigDecimal> getConfirmingPayments();
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||||
lastAccountName = _getLastAccountName();
|
lastAccountName = _getLastAccountName();
|
||||||
commandCooldowns = _getCommandCooldowns();
|
commandCooldowns = _getCommandCooldowns();
|
||||||
acceptingPay = _getAcceptingPay();
|
acceptingPay = _getAcceptingPay();
|
||||||
|
confirmPay = _getConfirmPay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal money;
|
private BigDecimal money;
|
||||||
|
@ -896,6 +897,22 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean confirmPay = true; // players accept pay by default
|
||||||
|
|
||||||
|
public boolean _getConfirmPay() {
|
||||||
|
return config.getBoolean("confirm-pay", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPromptingPayConfirm() {
|
||||||
|
return confirmPay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPromptingPayConfirm(boolean prompt) {
|
||||||
|
this.confirmPay = prompt;
|
||||||
|
config.setProperty("confirm-pay", prompt);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getConfigUUID() {
|
public UUID getConfigUUID() {
|
||||||
return config.uuid;
|
return config.uuid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class Commandpay extends EssentialsLoopCommand {
|
||||||
sender.sendMessage(tl("notAcceptingPay", player.getDisplayName()));
|
sender.sendMessage(tl("notAcceptingPay", player.getDisplayName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated.
|
if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated.
|
||||||
// Used to reset confirmations and inform to confirm when a new pay command has been inserted.
|
// Used to reset confirmations and inform to confirm when a new pay command has been inserted.
|
||||||
if (!informToConfirm) {
|
if (!informToConfirm) {
|
||||||
// User hasnt been asked to confirm payment to this player, reset all confirmed payments and ask to confirm again.
|
// User hasnt been asked to confirm payment to this player, reset all confirmed payments and ask to confirm again.
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
public class Commandpayconfirmtoggle extends EssentialsCommand {
|
||||||
|
|
||||||
|
public Commandpayconfirmtoggle() {
|
||||||
|
super("payconfirmtoggle");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||||
|
boolean confirmingPay = !user.isPromptingPayConfirm();
|
||||||
|
if (commandLabel.contains("payconfirmon")) {
|
||||||
|
confirmingPay = true;
|
||||||
|
} else if (commandLabel.contains("payconfirmoff")) {
|
||||||
|
confirmingPay = false;
|
||||||
|
}
|
||||||
|
user.setPromptingPayConfirm(confirmingPay);
|
||||||
|
if (confirmingPay) {
|
||||||
|
user.sendMessage(tl("payConfirmToggleOn"));
|
||||||
|
} else {
|
||||||
|
user.sendMessage(tl("payConfirmToggleOff"));
|
||||||
|
}
|
||||||
|
user.getConfirmingPayments().clear(); // Clear any outstanding confirmations.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -310,6 +310,8 @@ onlyPlayers=\u00a74Only in-game players can use \u00a7c{0}\u00a74.
|
||||||
onlySunStorm=\u00a74/weather only supports sun/storm.
|
onlySunStorm=\u00a74/weather only supports sun/storm.
|
||||||
orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait...
|
orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait...
|
||||||
oversizedTempban=\u00a74You may not ban a player for this period of time.
|
oversizedTempban=\u00a74You may not ban a player for this period of time.
|
||||||
|
payConfirmToggleOn=\u00a76You will now be prompted to confirm payments.
|
||||||
|
payConfirmToggleOff=\u00a76You will no longer be prompted to confirm payments.
|
||||||
payToggleOn=\u00a76You are now accepting payments.
|
payToggleOn=\u00a76You are now accepting payments.
|
||||||
payToggleOff=\u00a76You are no longer accepting payments.
|
payToggleOff=\u00a76You are no longer accepting payments.
|
||||||
payMustBePositive=\u00a74Amount to pay must be positive.
|
payMustBePositive=\u00a74Amount to pay must be positive.
|
||||||
|
|
|
@ -283,6 +283,10 @@ commands:
|
||||||
description: Toggles whether you are accepting payments.
|
description: Toggles whether you are accepting payments.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
aliases: [epaytoggle, payoff, epayoff, payon, epayon]
|
aliases: [epaytoggle, payoff, epayoff, payon, epayon]
|
||||||
|
payconfirmtoggle:
|
||||||
|
description: Toggles whether you are prompted to confirm payments.
|
||||||
|
usage: /<command>
|
||||||
|
aliases: [epayconfirmtoggle, payconfirmoff, epayconfirmoff, payconfirmon, epayconfirmon, payconfirm, epayconfirm]
|
||||||
ping:
|
ping:
|
||||||
description: Pong!
|
description: Pong!
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
|
Loading…
Reference in a new issue