Change default username to 'Dev', add ability to replace '#' with randomized numbers
This commit is contained in:
parent
8408539f1c
commit
42c27b8845
1 changed files with 21 additions and 2 deletions
|
@ -31,6 +31,9 @@ import java.lang.reflect.Field;
|
|||
import java.net.Proxy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public class LaunchTesting
|
||||
|
@ -68,7 +71,18 @@ public class LaunchTesting
|
|||
|
||||
if (!lst.hasValue("accessToken")) {
|
||||
if (!login(lst)) {
|
||||
lst.putLazy("username", "Test");
|
||||
String username = lst.get("username");
|
||||
if (username != null) { // Replace '#' placeholders with random numbers
|
||||
Matcher m = Pattern.compile("#+").matcher(username);
|
||||
StringBuffer replaced = new StringBuffer();
|
||||
while (m.find()) {
|
||||
m.appendReplacement(replaced, getRandomNumbers(m.group().length()));
|
||||
}
|
||||
m.appendTail(replaced);
|
||||
lst.put("username", replaced.toString());
|
||||
} else {
|
||||
lst.putLazy("username", "Dev");
|
||||
}
|
||||
lst.put("accessToken", "DONT_CRASH");
|
||||
lst.put("userProperties", "{}");
|
||||
}
|
||||
|
@ -85,6 +99,11 @@ public class LaunchTesting
|
|||
Thread.sleep(10000);// Why do we have this? -Lex 03/06/19
|
||||
}
|
||||
|
||||
private static String getRandomNumbers(int length)
|
||||
{ // Generate a time-based random number, to mimic how n.m.client.Main works
|
||||
return Long.toString(System.nanoTime() % (int) Math.pow(10, length));
|
||||
}
|
||||
|
||||
private static void hackNatives()
|
||||
{
|
||||
String paths = System.getProperty("java.library.path");
|
||||
|
|
Loading…
Reference in a new issue