runelite-client: add ConfigItem.warnOnDisable and warnOnEnable to configure when confirmationWarning is shown
This commit is contained in:
@@ -44,4 +44,8 @@ public @interface ConfigItem
|
||||
boolean hidden() default false;
|
||||
|
||||
String confirmationWarining() default "";
|
||||
|
||||
boolean warnOnEnable() default false;
|
||||
|
||||
boolean warnOnDisable() default false;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public interface RuneLiteConfig extends Config
|
||||
description = "Enable loading of external plugins",
|
||||
confirmationWarining = "WARNING: Using untrusted third party plugins is a SECURITY RISK\n"
|
||||
+ " and can result in loss of YOUR ACCOUNT, and compromise the security\n"
|
||||
+ "of your computer. Are you sure you want to do this?"
|
||||
+ "of your computer. Are you sure you want to do this?",
|
||||
warnOnEnable = true
|
||||
)
|
||||
default boolean enablePlugins()
|
||||
{
|
||||
|
||||
@@ -104,14 +104,16 @@ public class ConfigPanel extends PluginPanel
|
||||
if (component instanceof JCheckBox)
|
||||
{
|
||||
JCheckBox checkbox = (JCheckBox) component;
|
||||
if (checkbox.isSelected() && !configItem.confirmationWarining().isEmpty())
|
||||
boolean originalState = !checkbox.isSelected();
|
||||
boolean config = originalState ? configItem.warnOnDisable() : configItem.warnOnEnable();
|
||||
if (!configItem.confirmationWarining().isEmpty() && config)
|
||||
{
|
||||
int value = JOptionPane.showOptionDialog(component, configItem.confirmationWarining(),
|
||||
"Are you sure?", YES_NO_OPTION, WARNING_MESSAGE,
|
||||
null, new String[] { "Yes", "No" }, "No");
|
||||
if (value != YES_OPTION)
|
||||
{
|
||||
checkbox.setSelected(false);
|
||||
checkbox.setSelected(originalState);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user