private void updateIfNecessary(LoginUtil loginUtil, LoginUI loginUI) {
   UpdateUtil updateUtil =
       new UpdateUtil(
           loginUtil.getLatestVersion(), username, loginUtil.getDownloadTicket(), loginUI);
   if (updateUtil.updateDarkMod()) restart();
   updateUtil.updateMinecraft();
 }
 public boolean handleLoginWithoutUI(String username, String password) {
   LoginUtil loginUtil = new LoginUtil();
   if (password != null) {
     loginUtil.login(username, password);
     if (!loginUtil.isLoggedIn()) return false;
     this.username = loginUtil.getUsername();
     this.password = loginUtil.getPassword();
     sessionID = loginUtil.getSessionID();
     updateIfNecessary(loginUtil, null);
   } else {
     loginUtil.playOffline(username);
     this.username = username;
   }
   return true;
 }
 public LoginUI handleLoginWithUI() {
   DarkMod darkMod = DarkMod.getInstance();
   DarkModUI ui = darkMod.getUI();
   LoginUI loginUI = new LoginUI();
   ui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   ui.remove(ui.getCanvas());
   ui.add(loginUI, "Center");
   ui.pack();
   LoginUtil loginUtil = loginUI.getLoginUtil();
   while (!loginUtil.isLoggedIn() && !loginUtil.isPlayingOffline()) {
     loginUI.authenticate();
     try {
       Thread.sleep(500);
     } catch (InterruptedException exception) {
       exception.printStackTrace();
     }
   }
   username = loginUtil.getUsername();
   password = loginUtil.getPassword();
   sessionID = loginUtil.getSessionID();
   if (loginUtil.isLoggedIn() && loginUI.isCheckForUpdatesSelected())
     updateIfNecessary(loginUtil, loginUI);
   return loginUI;
 }