Add default toggle for confirm commands in config.yml.

This commit is contained in:
Ali Moghnieh 2018-01-28 16:47:17 +00:00
parent 752565b8f1
commit 1ef1cd98db
No known key found for this signature in database
GPG Key ID: F09D3A1BAF2E6D70
4 changed files with 41 additions and 10 deletions

View File

@ -302,4 +302,8 @@ public interface ISettings extends IConf {
int getMotdDelay();
boolean isDirectHatAllowed();
}
List<String> getDefaultDisabledConfirmCommands();
boolean isConfirmCommandEnabledByDefault(String commandName);
}

View File

@ -532,6 +532,7 @@ public class Settings implements net.ess3.api.ISettings {
npcsInBalanceRanking = _isNpcsInBalanceRanking();
currencyFormat = _getCurrencyFormat();
unprotectedSigns = _getUnprotectedSign();
defaultDisabledConfirmCommands = _getDefaultDisabledConfirmCommands();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@ -1418,4 +1419,24 @@ public class Settings implements net.ess3.api.ISettings {
public boolean isDirectHatAllowed() {
return config.getBoolean("allow-direct-hat", true);
}
}
private List<String> defaultDisabledConfirmCommands;
private List<String> _getDefaultDisabledConfirmCommands() {
List<String> commands = config.getStringList("default-disabled-confirm-commands");
for (int i = 0; i < commands.size(); i++) {
commands.set(i, commands.get(i).toLowerCase());
}
return commands;
}
@Override
public List<String> getDefaultDisabledConfirmCommands() {
return defaultDisabledConfirmCommands;
}
@Override
public boolean isConfirmCommandEnabledByDefault(String commandName) {
return !getDefaultDisabledConfirmCommands().contains(commandName.toLowerCase());
}
}

View File

@ -898,14 +898,14 @@ public abstract class UserData extends PlayerExtension implements IConf {
save();
}
private boolean confirmPay = false; // players deny pay confirmation by default
private Boolean confirmPay;
public boolean _getConfirmPay() {
return config.getBoolean("confirm-pay", false);
private Boolean _getConfirmPay() {
return (Boolean) config.get("confirm-pay");
}
public boolean isPromptingPayConfirm() {
return confirmPay;
return confirmPay != null ? confirmPay : ess.getSettings().isConfirmCommandEnabledByDefault("pay");
}
public void setPromptingPayConfirm(boolean prompt) {
@ -914,14 +914,14 @@ public abstract class UserData extends PlayerExtension implements IConf {
save();
}
private boolean confirmClear = false; // players deny clear confirmation by default
private Boolean confirmClear;
public boolean _getConfirmClear() {
return config.getBoolean("confirm-clear", false);
private Boolean _getConfirmClear() {
return (Boolean) config.get("confirm-clear");
}
public boolean isPromptingClearConfirm() {
return confirmClear;
return confirmClear != null ? confirmClear : ess.getSettings().isConfirmCommandEnabledByDefault("clearinventory");
}
public void setPromptingClearConfirm(boolean prompt) {

View File

@ -516,6 +516,12 @@ allow-bulk-buy-sell: true
# This has no effect if the MOTD command or permission are disabled.
delay-motd: 0
# A list of commands that should have their complementary confirm commands disabled by default.
# This is empty by default, for the latest list of valid commands see the latest source config.yml.
default-disabled-confirm-commands:
#- pay
#- clearinventory
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #