mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-14 12:11:25 +01:00
Add minimum-pay-amount setting to limit how little you can /pay someone.
Add 'minimumPayAmount' translatable message. Create NumberUtil#displayCurrencyExactly(BigDecimal, IEssentials).
This commit is contained in:
parent
fc8ee7f25f
commit
0a876c33a7
@ -229,4 +229,6 @@ public interface ISettings extends IConf {
|
|||||||
boolean isDropItemsIfFull();
|
boolean isDropItemsIfFull();
|
||||||
|
|
||||||
boolean isLastMessageReplyRecipient();
|
boolean isLastMessageReplyRecipient();
|
||||||
|
|
||||||
|
BigDecimal getMinimumPayAmount();
|
||||||
}
|
}
|
||||||
|
@ -1121,4 +1121,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
@Override public boolean isLastMessageReplyRecipient() {
|
@Override public boolean isLastMessageReplyRecipient() {
|
||||||
return config.getBoolean("last-message-reply-recipient", false);
|
return config.getBoolean("last-message-reply-recipient", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public BigDecimal getMinimumPayAmount() {
|
||||||
|
return new BigDecimal(config.getString("minimum-pay-amount", "0.001"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.earth2me.essentials.ChargeException;
|
|||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
|
|
||||||
import net.ess3.api.MaxMoneyException;
|
import net.ess3.api.MaxMoneyException;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
@ -32,6 +34,9 @@ public class Commandpay extends EssentialsLoopCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
amount = new BigDecimal(stringAmount);
|
amount = new BigDecimal(stringAmount);
|
||||||
|
if (amount.compareTo(ess.getSettings().getMinimumPayAmount()) < 0) { // Check if amount is less than minimum-pay-amount
|
||||||
|
throw new Exception(tl("minimumPayAmount", NumberUtil.displayCurrencyExactly(ess.getSettings().getMinimumPayAmount(), ess)));
|
||||||
|
}
|
||||||
loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args);
|
loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ public class NumberUtil {
|
|||||||
return tl("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
|
return tl("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String displayCurrencyExactly(final BigDecimal value, final IEssentials ess) {
|
||||||
|
return tl("currency", ess.getSettings().getCurrencySymbol(), value.toPlainString());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInt(final String sInt) {
|
public static boolean isInt(final String sInt) {
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(sInt);
|
Integer.parseInt(sInt);
|
||||||
|
@ -536,6 +536,9 @@ economy-log-enabled: false
|
|||||||
# Default is false.
|
# Default is false.
|
||||||
use-bukkit-permissions: false
|
use-bukkit-permissions: false
|
||||||
|
|
||||||
|
# Minimum acceptable amount to be used in /pay.
|
||||||
|
minimum-pay-amount: 0.001
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | EssentialsHelp | #
|
# | EssentialsHelp | #
|
||||||
|
@ -570,3 +570,4 @@ msgDisabledFor=\u00a76Receiving messages \u00a7cdisabled \u00a76for \u00a7c{0}\u
|
|||||||
msgEnabled=\u00a76Receiving messages \u00a7cenabled\u00a76.
|
msgEnabled=\u00a76Receiving messages \u00a7cenabled\u00a76.
|
||||||
msgEnabledFor=\u00a76Receiving messages \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
|
msgEnabledFor=\u00a76Receiving messages \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
|
||||||
msgIgnore=\u00a7c{0} \u00a74has messages disabled.
|
msgIgnore=\u00a7c{0} \u00a74has messages disabled.
|
||||||
|
minimumPayAmount=\u00a7cThe minimum amount you can pay is {0}.
|
||||||
|
Loading…
Reference in New Issue
Block a user