Skip to content

Commit

Permalink
Fixed account selection being reset (or not reset) sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jan 10, 2023
1 parent 4a78b4b commit 8d10f99
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/raphimc/viaproxy/ui/ViaProxyUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class ViaProxyUI extends JFrame {

private final JTabbedPane contentPane = new JTabbedPane();
private final List<AUITab> tabs = new ArrayList<>();
private final GeneralTab generalTab = new GeneralTab(this);
private final AccountsTab accountsTab = new AccountsTab(this);
public final GeneralTab generalTab = new GeneralTab(this);
public final AccountsTab accountsTab = new AccountsTab(this);

private ImageIcon icon;

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/net/raphimc/viaproxy/ui/impl/AccountsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import net.raphimc.viaproxy.ui.popups.AddAccountPopup;

import javax.swing.*;
import java.awt.event.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.concurrent.TimeoutException;

public class AccountsTab extends AUITab {
Expand Down Expand Up @@ -213,8 +216,8 @@ private void addAccount(final StepMCProfile.MCProfile account) {
else model.addElement(account.name() + " (Microsoft)");
}

private void markSelected(final int index) {
if (index == -1) {
public void markSelected(final int index) {
if (index < 0 || index >= this.accountsList.getModel().getSize()) {
Options.MC_ACCOUNT = null;
return;
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,15 @@ private void start() {
Options.PROTOCOL_VERSION = serverVersion;
Options.BETACRAFT_AUTH = betaCraftAuth;

if (authMethod == 2) Options.OPENAUTHMOD_AUTH = true;
if (authMethod != 1) {
Options.MC_ACCOUNT = null;
} else if (Options.MC_ACCOUNT == null) {
this.frame.accountsTab.markSelected(0);
}

if (authMethod == 2) {
Options.OPENAUTHMOD_AUTH = true;
}
} catch (Throwable e) {
SwingUtilities.invokeLater(() -> {
this.frame.showError("Invalid server address!");
Expand Down

0 comments on commit 8d10f99

Please sign in to comment.