add warning message

This commit is contained in:
OP
2020-06-09 15:40:57 -04:00
parent 1b28ca0734
commit 232bae0242
3 changed files with 54 additions and 10 deletions

View File

@@ -359,4 +359,12 @@ public interface OpenOSRSConfig extends Config
hidden = true
)
void setExternalRepositories(String val);
@ConfigItem(
keyName = "warning",
name = "",
description = "",
hidden = true
)
default boolean warning(){return true;}
}

View File

@@ -349,6 +349,17 @@ public class ExternalPluginManager
openOSRSConfig.setExternalRepositories(config.toString());
}
public void setWarning(boolean val)
{
configManager.setConfiguration("openosrs", "warning", val);
}
public boolean getWarning()
{
return openOSRSConfig.warning();
}
/**
* This method is a fail safe to ensure that no duplicate

View File

@@ -1,8 +1,6 @@
package net.runelite.client.plugins.openosrs.externals;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
@@ -10,13 +8,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.ExternalPluginManager;
@@ -95,6 +87,22 @@ public class ExternalPluginManagerPanel extends PluginPanel
@Override
public void mousePressed(MouseEvent mouseEvent)
{
if(externalPluginManager.getWarning()) {
JCheckBox checkbox = new JCheckBox("Don't show again.");
Object[] options = {"Okay, I accept the risk", "Never mind, turn back", checkbox};
int answer = JOptionPane.showOptionDialog(new JFrame(),
"Adding plugins from unverified sources may put your account, or personal information at risk! \n",
"Account security warning",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[0]);
if(answer == 1) return;
if(checkbox.isSelected()) externalPluginManager.setWarning(false);
}
JTextField owner = new JTextField();
JTextField name = new JTextField();
Object[] message = {
@@ -146,6 +154,23 @@ public class ExternalPluginManagerPanel extends PluginPanel
@Override
public void mousePressed(MouseEvent mouseEvent)
{
if(externalPluginManager.getWarning()) {
JCheckBox checkbox = new JCheckBox("Don't show again.");
Object[] options = {"Okay, I accept the risk", "Never mind, turn back", checkbox};
int answer = JOptionPane.showOptionDialog(new JFrame(),
"Adding plugins from unverified sources may put your account, or personal information at risk! \n",
"Account security warning",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[0]);
if(answer == 1) return;
if(checkbox.isSelected()) externalPluginManager.setWarning(false);
}
JTextField id = new JTextField();
JTextField url = new JTextField();
Object[] message = {