Merge pull request #342 from Abextm/warn-on-disable
client: add ConfigItem.warnOnDisable and warnOnEnable
This commit is contained in:
@@ -44,4 +44,8 @@ public @interface ConfigItem
|
|||||||
boolean hidden() default false;
|
boolean hidden() default false;
|
||||||
|
|
||||||
String confirmationWarining() default "";
|
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",
|
description = "Enable loading of external plugins",
|
||||||
confirmationWarining = "WARNING: Using untrusted third party plugins is a SECURITY RISK\n"
|
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"
|
+ " 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()
|
default boolean enablePlugins()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,14 +104,16 @@ public class ConfigPanel extends PluginPanel
|
|||||||
if (component instanceof JCheckBox)
|
if (component instanceof JCheckBox)
|
||||||
{
|
{
|
||||||
JCheckBox checkbox = (JCheckBox) component;
|
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(),
|
int value = JOptionPane.showOptionDialog(component, configItem.confirmationWarining(),
|
||||||
"Are you sure?", YES_NO_OPTION, WARNING_MESSAGE,
|
"Are you sure?", YES_NO_OPTION, WARNING_MESSAGE,
|
||||||
null, new String[] { "Yes", "No" }, "No");
|
null, new String[] { "Yes", "No" }, "No");
|
||||||
if (value != YES_OPTION)
|
if (value != YES_OPTION)
|
||||||
{
|
{
|
||||||
checkbox.setSelected(false);
|
checkbox.setSelected(originalState);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user