From 5a8675ee3ab51894a6b64c6b3f6a2b7c4d625a31 Mon Sep 17 00:00:00 2001 From: TabulateJarl8 Date: Tue, 8 Jun 2021 15:17:56 -0400 Subject: [PATCH] increase timeout and fix server console delays --- pom.xml | 2 +- src/main/java/modpackSwitcher/Main.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 46b7c2e..3aebb3c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.tabulate.modpackSwitcher switcher - 1.0 + 1.1 switcher http://tabulatejarl8.github.io diff --git a/src/main/java/modpackSwitcher/Main.java b/src/main/java/modpackSwitcher/Main.java index b048fce..d421a02 100644 --- a/src/main/java/modpackSwitcher/Main.java +++ b/src/main/java/modpackSwitcher/Main.java @@ -145,7 +145,7 @@ public boolean accept(File file, String s) { // Print out modpack choices - System.out.println("Select a pack. Last used pack will be started in 5 seconds."); + System.out.println("Select a pack. Last used pack will be started in 10 seconds."); for (int i = 0; i < (modpacks.length); i++) { System.out.print((i + 1) + ". " + modpacks[i]); @@ -157,7 +157,9 @@ public boolean accept(File file, String s) { } System.out.println(); - stringChoice = getModpackSelectionWithTimeout(5, lastUsedPack, modpacks, ansi); + System.out.println("Which modpack? [1-" + modpacks.length + "] "); + + stringChoice = getModpackSelectionWithTimeout(10, "> ", lastUsedPack, modpacks, ansi); choice = Integer.parseInt(stringChoice); // Write last used modpack if changed @@ -251,7 +253,7 @@ public int writeFile(String directoryName, String fileName, String value){ } } - public String getModpackSelectionWithTimeout(int delay, int defaultChoice, String[] modpacks, boolean ansi){ + public String getModpackSelectionWithTimeout(int delay, String message, int defaultChoice, String[] modpacks, boolean ansi){ defaultChoice++; Callable k = new Callable() { @Override @@ -264,7 +266,7 @@ public Integer call() { boolean valid; ExecutorService l = Executors.newFixedThreadPool(1); Future g; - System.out.print("Which modpack? [1-" + modpacks.length + "] "); + System.out.print(message); g = l.submit(k); done: while (System.currentTimeMillis() - start < delay * 1000L) { do { @@ -285,7 +287,7 @@ public Integer call() { g = l.submit(k); valid = false; // Reset timer - System.out.print("Which modpack? [1-" + modpacks.length + "] "); + System.out.print(message); start = System.currentTimeMillis(); } } @@ -309,4 +311,4 @@ class Fore { public static String CYAN = "\u001b[36m"; public static String WHITE = "\u001b[37m"; public static String RESET = "\u001b[0m"; -} \ No newline at end of file +}