Merge branch 'SupaHam-default-confirm-command-prompt' into 2.x

This commit is contained in:
Trent Hensler 2018-03-26 00:37:08 -07:00
commit 7d7c58fa7c
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> getDefaultEnabledConfirmCommands();
boolean isConfirmCommandEnabledByDefault(String commandName);
}

View File

@ -532,6 +532,7 @@ public class Settings implements net.ess3.api.ISettings {
npcsInBalanceRanking = _isNpcsInBalanceRanking();
currencyFormat = _getCurrencyFormat();
unprotectedSigns = _getUnprotectedSign();
defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands();
}
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> defaultEnabledConfirmCommands;
private List<String> _getDefaultEnabledConfirmCommands() {
List<String> commands = config.getStringList("default-enabled-confirm-commands");
for (int i = 0; i < commands.size(); i++) {
commands.set(i, commands.get(i).toLowerCase());
}
return commands;
}
@Override
public List<String> getDefaultEnabledConfirmCommands() {
return defaultEnabledConfirmCommands;
}
@Override
public boolean isConfirmCommandEnabledByDefault(String commandName) {
return getDefaultEnabledConfirmCommands().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 enabled by default.
# This is empty by default, for the latest list of valid commands see the latest source config.yml.
default-enabled-confirm-commands:
#- pay
#- clearinventory
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #