mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-21 11:45:16 +01:00
Added basic sanity check to offline mode username
This commit is contained in:
parent
c956ed7917
commit
c520774841
@ -3,8 +3,8 @@ package net.raphimc.viaproxy.ui;
|
|||||||
import com.formdev.flatlaf.FlatDarkLaf;
|
import com.formdev.flatlaf.FlatDarkLaf;
|
||||||
import net.lenni0451.reflect.stream.RStream;
|
import net.lenni0451.reflect.stream.RStream;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
|
import net.raphimc.viaproxy.ui.impl.AccountsTab;
|
||||||
import net.raphimc.viaproxy.ui.impl.GeneralTab;
|
import net.raphimc.viaproxy.ui.impl.GeneralTab;
|
||||||
import net.raphimc.viaproxy.ui.impl.OnlineModeTab;
|
|
||||||
import net.raphimc.viaproxy.util.logging.Logger;
|
import net.raphimc.viaproxy.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@ -18,7 +18,7 @@ public class ViaProxyUI extends JFrame {
|
|||||||
private final JTabbedPane contentPane = new JTabbedPane();
|
private final JTabbedPane contentPane = new JTabbedPane();
|
||||||
private final List<AUITab> tabs = new ArrayList<>();
|
private final List<AUITab> tabs = new ArrayList<>();
|
||||||
private final GeneralTab generalTab = new GeneralTab(this);
|
private final GeneralTab generalTab = new GeneralTab(this);
|
||||||
private final OnlineModeTab onlineModeTab = new OnlineModeTab(this);
|
private final AccountsTab accountsTab = new AccountsTab(this);
|
||||||
|
|
||||||
private ImageIcon icon;
|
private ImageIcon icon;
|
||||||
|
|
||||||
|
@ -9,13 +9,10 @@ import net.raphimc.viaproxy.ui.ViaProxyUI;
|
|||||||
import net.raphimc.viaproxy.ui.popups.AddAccountPopup;
|
import net.raphimc.viaproxy.ui.popups.AddAccountPopup;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.*;
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class OnlineModeTab extends AUITab {
|
public class AccountsTab extends AUITab {
|
||||||
|
|
||||||
private JList<String> accountsList;
|
private JList<String> accountsList;
|
||||||
private JButton addMicrosoftAccountButton;
|
private JButton addMicrosoftAccountButton;
|
||||||
@ -23,7 +20,7 @@ public class OnlineModeTab extends AUITab {
|
|||||||
private AddAccountPopup addAccountPopup;
|
private AddAccountPopup addAccountPopup;
|
||||||
private Thread addThread;
|
private Thread addThread;
|
||||||
|
|
||||||
public OnlineModeTab(final ViaProxyUI frame) {
|
public AccountsTab(final ViaProxyUI frame) {
|
||||||
super(frame, "Accounts");
|
super(frame, "Accounts");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +142,7 @@ public class OnlineModeTab extends AUITab {
|
|||||||
addOfflineAccountButton.setBounds(10, 300, 230, 20);
|
addOfflineAccountButton.setBounds(10, 300, 230, 20);
|
||||||
addOfflineAccountButton.addActionListener(event -> {
|
addOfflineAccountButton.addActionListener(event -> {
|
||||||
String username = JOptionPane.showInputDialog(this.frame, "Enter your offline mode Username:", "Add Offline Account", JOptionPane.PLAIN_MESSAGE);
|
String username = JOptionPane.showInputDialog(this.frame, "Enter your offline mode Username:", "Add Offline Account", JOptionPane.PLAIN_MESSAGE);
|
||||||
if (username != null) {
|
if (username != null && !username.trim().isEmpty()) {
|
||||||
StepMCProfile.MCProfile account = ViaProxy.saveManager.accountsSave.addOfflineAccount(username);
|
StepMCProfile.MCProfile account = ViaProxy.saveManager.accountsSave.addOfflineAccount(username);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.saveManager.save();
|
||||||
this.addAccount(account);
|
this.addAccount(account);
|
Loading…
Reference in New Issue
Block a user