diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java index ed78ed665f..75a0819842 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilePanel.java @@ -67,7 +67,7 @@ class ProfilePanel extends JPanel private final String loginText; private String password = null; - ProfilePanel(final Client client, final String data, final ProfilesConfig config, final ProfilesPanel parent) + ProfilePanel(final Client client, final String data, final ProfilesPlugin plugin, final ProfilesPanel parent) { String[] parts = data.split(":"); this.loginText = parts[1]; @@ -144,7 +144,7 @@ class ProfilePanel extends JPanel if (SwingUtilities.isLeftMouseButton(e) && client.getGameState() == GameState.LOGIN_SCREEN) { client.setUsername(loginText); - if (config.rememberPassword() && password != null) + if (plugin.isRememberPassword() && password != null) { client.setPassword(password); } @@ -163,7 +163,7 @@ class ProfilePanel extends JPanel if (SwingUtilities.isLeftMouseButton(e) && client.getGameState() == GameState.LOGIN_SCREEN) { client.setUsername(loginText); - if (config.rememberPassword() && password != null) + if (plugin.isRememberPassword() && password != null) { client.setPassword(password); } @@ -171,16 +171,19 @@ class ProfilePanel extends JPanel } }); - JLabel login = new JLabel(); - login.setText(config.isStreamerMode() ? "Hidden email" : loginText); - login.setBorder(null); - login.setPreferredSize(new Dimension(0, 24)); - login.setForeground(Color.WHITE); - login.setBorder(new EmptyBorder(0, 8, 0, 0)); - - bottomContainer.add(login, BorderLayout.CENTER); + if (plugin.isDisplayEmailAddress()) + { + JLabel login = new JLabel(); + login.setText(plugin.isStreamerMode() ? "Hidden email" : loginText); + login.setBorder(null); + login.setPreferredSize(new Dimension(0, 24)); + login.setForeground(Color.WHITE); + login.setBorder(new EmptyBorder(0, 8, 0, 0)); + bottomContainer.add(login, BorderLayout.CENTER); + add(bottomContainer, BorderLayout.CENTER); + } add(labelWrapper, BorderLayout.NORTH); - add(bottomContainer, BorderLayout.CENTER); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesConfig.java index 347e96bd42..7e7a22da15 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesConfig.java @@ -70,19 +70,34 @@ public interface ProfilesConfig extends Config @ConfigItem( keyName = "rememberPassword", name = "Remember Password", - description = "Remembers passwords for accounts" + description = "Remembers passwords for accounts", + position = 0 ) default boolean rememberPassword() { return true; } + @ConfigItem( + keyName = "displayEmailAddress", + name = "Display email field", + description = "Displays the email address field", + position = 1 + ) + default boolean displayEmailAddress() + { + return false; + } + @ConfigItem( keyName = "streamerMode", name = "Hide email addresses", - description = "Hides your account emails" + description = "Hides your account emails", + position = 2, + hidden = true, + unhide = "displayEmailAddress" ) - default boolean isStreamerMode() + default boolean streamerMode() { return false; } @@ -90,7 +105,8 @@ public interface ProfilesConfig extends Config @ConfigItem( keyName = "switchPanel", name = "Auto-open Panel", - description = "Automatically switch to the account switcher panel on the login screen" + description = "Automatically switch to the account switcher panel on the login screen", + position = 3 ) default boolean switchPanel() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java index 00ddbac501..970cd2b7b4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java @@ -85,6 +85,8 @@ class ProfilesPanel extends PluginPanel @Inject private ProfilesConfig profilesConfig; + @Inject ProfilesPlugin profilesPlugin; + private final JPasswordField txtDecryptPassword = new JPasswordField(UNLOCK_PASSWORD); private final JTextField txtAccountLabel = new JTextField(ACCOUNT_LABEL); private final JPasswordField txtAccountLogin = new JPasswordField(ACCOUNT_USERNAME); @@ -221,7 +223,7 @@ class ProfilesPanel extends PluginPanel if (ACCOUNT_USERNAME.equals(String.valueOf(txtAccountLogin.getPassword()))) { txtAccountLogin.setText(""); - if (profilesConfig.isStreamerMode()) + if (profilesPlugin.isStreamerMode()) { txtAccountLogin.setEchoChar('*'); } @@ -278,7 +280,7 @@ class ProfilesPanel extends PluginPanel return; } String data; - if (profilesConfig.rememberPassword() && txtPasswordLogin.getPassword() != null) + if (profilesPlugin.isRememberPassword() && txtPasswordLogin.getPassword() != null) { data = labelText + ":" + loginText + ":" + passwordText; } @@ -357,7 +359,7 @@ class ProfilesPanel extends PluginPanel accountPanel.add(txtAccountLabel); accountPanel.add(txtAccountLogin); - if (profilesConfig.rememberPassword()) + if (profilesPlugin.isRememberPassword()) { accountPanel.add(txtPasswordLogin); } @@ -401,7 +403,7 @@ class ProfilesPanel extends PluginPanel add(profilesPanel, BorderLayout.SOUTH); } - private void redrawProfiles() throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchPaddingException + void redrawProfiles() throws InvalidKeySpecException, NoSuchAlgorithmException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchPaddingException { profilesPanel.removeAll(); addAccounts(getProfileData()); @@ -412,7 +414,7 @@ class ProfilesPanel extends PluginPanel private void addAccount(String data) { - ProfilePanel profile = new ProfilePanel(client, data, profilesConfig, this); + ProfilePanel profile = new ProfilePanel(client, data, profilesPlugin, this); profilesPanel.add(profile); revalidate(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java index 448354f896..0c05298d2f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPlugin.java @@ -29,6 +29,8 @@ import java.awt.image.BufferedImage; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.GameState; import net.runelite.api.events.GameStateChanged; import net.runelite.client.config.ConfigManager; @@ -62,7 +64,14 @@ public class ProfilesPlugin extends Plugin private ProfilesPanel panel; private NavigationButton navButton; + @Getter(AccessLevel.PACKAGE) private boolean switchToPanel; + @Getter(AccessLevel.PACKAGE) + private boolean streamerMode; + @Getter(AccessLevel.PACKAGE) + private boolean displayEmailAddress; + @Getter(AccessLevel.PACKAGE) + private boolean rememberPassword; @Provides @@ -124,9 +133,11 @@ public class ProfilesPlugin extends Plugin this.startUp(); updateConfig(); } - if (event.getGroup().equals("profiles") && event.getKey().equals("switchPanel")) + if (event.getGroup().equals("profiles") && !event.getKey().equals("rememberPassword")) { updateConfig(); + panel = injector.getInstance(ProfilesPanel.class); + panel.redrawProfiles(); } } @@ -140,9 +151,13 @@ public class ProfilesPlugin extends Plugin } } + private void updateConfig() { this.switchToPanel = config.switchPanel(); + this.rememberPassword = config.rememberPassword(); + this.streamerMode = config.streamerMode(); + this.displayEmailAddress = config.displayEmailAddress(); } }