Skip to content

Commit

Permalink
7.2.22
Browse files Browse the repository at this point in the history
Possible fix for SteamCMD 2FA issue
  • Loading branch information
Osiris-Team committed May 14, 2023
1 parent 9bc68bf commit 78caa00
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.osiris.autoplug.client</groupId>
<artifactId>autoplug-client</artifactId>
<version>7.2.21</version>
<version>7.2.22</version>
<packaging>jar</packaging>

<name>AutoPlug-Client</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;

import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;

import static com.osiris.betterthread.Constants.TERMINAL;

public class ThreadUserInput extends Thread {

public static CopyOnWriteArrayList<Consumer<String>> onReadLine = new CopyOnWriteArrayList<>();

public ThreadUserInput() {
setName("AutoPlug-UserInputListenerThread");
}
Expand All @@ -39,6 +44,9 @@ public void run() {
String user_input = null;
try {
user_input = lineReader.readLine();
for (Consumer<String> code : onReadLine) {
code.accept(user_input);
}

// Send to online console
if (Main.CON.CON_CONSOLE_SEND.isAlive())
Expand Down
32 changes: 27 additions & 5 deletions src/main/java/com/osiris/autoplug/client/utils/SteamCMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package com.osiris.autoplug.client.utils;

import com.osiris.autoplug.client.configs.UpdaterConfig;
import com.osiris.autoplug.client.console.ThreadUserInput;
import com.osiris.autoplug.client.tasks.updater.TaskDownload;
import com.osiris.autoplug.client.utils.io.AsyncReader;
import com.osiris.autoplug.client.utils.tasks.MyBThreadManager;
Expand All @@ -23,8 +24,12 @@

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;

import static com.osiris.jprocesses2.util.OS.isMac;
Expand Down Expand Up @@ -154,11 +159,28 @@ public boolean installOrUpdateServer(String appId, Consumer<String> onLog, Consu
AL.info("Paused task printing, login into Steam timed out (10 seconds).");
AL.info("Steam Guard key seems to be needed (check your email)!");
AL.info("Insert it below and press enter:");
String steamGuardKey = new Scanner(System.in).nextLine();
AL.info("Steam Guard key will be provided to SteamCMD.");
terminal.sendCommands(steamGuardKey);
AtomicReference<String> steamGuardKey = new AtomicReference<>();
Consumer<String> code = steamGuardKey::set;
ThreadUserInput.onReadLine.add(code);
while (steamGuardKey.get() == null) Thread.sleep(100);
String key = steamGuardKey.get();
AL.info("Steam Guard key " + key + " will be provided to SteamCMD...");
terminal.sendCommands(key);
Thread.sleep(10000);
if (isLoginSuccess.get()) break;
ThreadUserInput.onReadLine.remove(code);
if (isLoginSuccess.get()) {
AL.info("Success! Continuing task printing!");
try {
new Thread(() -> {
MyBThreadManager.lastCreatedPrinter.get().run(); // Since we cannot start a stopped thread again
}).start();
} catch (Exception e) {
AL.warn(e);
}
break;
} else {
AL.info("Failed! Please try again.");
}
}
terminal.sendCommands("force_install_dir \"" + gameInstallDir.getAbsolutePath() + "\"",
"app_update " + appId,
Expand Down

0 comments on commit 78caa00

Please sign in to comment.