mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 23:59:21 -04:00
Smaller code
This commit is contained in:
parent
0bad37c1fc
commit
4975eddb06
@ -7,11 +7,15 @@ import org.lwjgl.input.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
public class AndroidLWJGLKeycode {
|
||||
// Fix double letters on MC 1.9 and above
|
||||
public static boolean isBackspaceAfterChar;
|
||||
private static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
||||
private static String[] androidKeyNameArray;
|
||||
static {
|
||||
// Mapping Android Key to LWJGL Key from scratch
|
||||
// OOPS I waste my time to map this, but already have another.
|
||||
|
||||
|
||||
// Mapping Android Keycodes to LWJGL Keycodes
|
||||
androidToLwjglMap = new ArrayMap<Integer, Integer>();
|
||||
|
||||
// 0-9 keys
|
||||
@ -162,7 +166,9 @@ public class AndroidLWJGLKeycode {
|
||||
for (Map.Entry<Integer, Integer> perKey : androidToLwjglMap.entrySet()) {
|
||||
if (perKey.getKey() == i) {
|
||||
if (i == KeyEvent.KEYCODE_BACK && (keyEvent.getSource() == InputDevice.SOURCE_MOUSE)) {
|
||||
// mainActivity.sendMo
|
||||
// Right mouse detection
|
||||
mainActivity.sendMouseButton(1, true);
|
||||
mainActivity.sendMouseButton(1, false);
|
||||
} else {
|
||||
mainActivity.sendKeyPress(perKey.getValue(), isDown);
|
||||
}
|
||||
|
@ -6,65 +6,10 @@ public class FakeAccount
|
||||
{
|
||||
public static String[] generate()
|
||||
{
|
||||
// Unneccessary for generate random string, smaller code.
|
||||
String[] arr = {
|
||||
UUID.randomUUID().toString(),
|
||||
new RandomString(32).nextString()
|
||||
"0", "0"
|
||||
};
|
||||
return arr;
|
||||
}
|
||||
private static class RandomString {
|
||||
|
||||
/**
|
||||
* Generate a random string.
|
||||
*/
|
||||
public String nextString() {
|
||||
for (int idx = 0; idx < buf.length; ++idx)
|
||||
buf[idx] = symbols[random.nextInt(symbols.length)];
|
||||
return new String(buf);
|
||||
}
|
||||
|
||||
public static final String upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
public static final String lower = upper.toLowerCase(Locale.ROOT);
|
||||
|
||||
public static final String digits = "0123456789";
|
||||
|
||||
public static final String alphanum = upper + lower + digits;
|
||||
|
||||
private final Random random;
|
||||
|
||||
private final char[] symbols;
|
||||
|
||||
private final char[] buf;
|
||||
|
||||
public RandomString(int length, Random random, String symbols) {
|
||||
if (length < 1) throw new IllegalArgumentException();
|
||||
if (symbols.length() < 2) throw new IllegalArgumentException();
|
||||
this.random = Objects.requireNonNull(random);
|
||||
this.symbols = symbols.toCharArray();
|
||||
this.buf = new char[length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an alphanumeric string generator.
|
||||
*/
|
||||
public RandomString(int length, Random random) {
|
||||
this(length, random, alphanum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an alphanumeric strings from a secure generator.
|
||||
*/
|
||||
public RandomString(int length) {
|
||||
this(length, new SecureRandom());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create session identifiers.
|
||||
*/
|
||||
public RandomString() {
|
||||
this(21);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -95,15 +95,13 @@ public class MCProfile
|
||||
}
|
||||
|
||||
public static String toString(MCProfile.Builder builder) {
|
||||
//System.out.println("TOSTRING THE VER = " + builder.getVersion());
|
||||
|
||||
return
|
||||
builder.getClientID() + ":" +
|
||||
builder.getProfileID() + ":" +
|
||||
builder.getAccessToken() + ":" +
|
||||
builder.getUsername() + ":" +
|
||||
builder.getVersion() + ":" +
|
||||
Boolean.toString(builder.isAccount());
|
||||
Boolean.toString(builder.isMojangAccount());
|
||||
}
|
||||
|
||||
public static class Builder implements Serializable
|
||||
@ -114,13 +112,12 @@ public class MCProfile
|
||||
public Builder()
|
||||
{
|
||||
fullArgs = emptyBuilder;
|
||||
String[] fakeTokens = FakeAccount.generate();
|
||||
setClientID(fakeTokens[0]);
|
||||
setProfileID(FakeAccount.generate()[0].replace("-", ""));
|
||||
setAccessToken(fakeTokens[1]);
|
||||
setClientID("0");
|
||||
setProfileID("00000000-0000-0000-0000-000000000000");
|
||||
setAccessToken("0");
|
||||
}
|
||||
|
||||
public boolean isAccount()
|
||||
public boolean isMojangAccount()
|
||||
{
|
||||
return isAccount;
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ public class PojavLoginActivity extends MineActivity
|
||||
{
|
||||
try
|
||||
{
|
||||
if(MCProfile.load(path).isAccount()){
|
||||
if(MCProfile.load(path).isMojangAccount()){
|
||||
MCProfile.updateTokens(PojavLoginActivity.this, path, new RefreshListener(){
|
||||
|
||||
@Override
|
||||
|
@ -356,13 +356,11 @@ public final class Tools
|
||||
} else {
|
||||
JMinecraftVersionList.Version inheritsVer = new Gson().fromJson(read(versnDir + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json"), JMinecraftVersionList.Version.class);
|
||||
|
||||
inheritsVer.id = customVer.id;
|
||||
inheritsVer.mainClass = customVer.mainClass;
|
||||
inheritsVer.minecraftArguments = customVer.minecraftArguments;
|
||||
inheritsVer.optifineLib = customVer.optifineLib;
|
||||
inheritsVer.releaseTime = customVer.releaseTime;
|
||||
inheritsVer.time = customVer.time;
|
||||
inheritsVer.type = customVer.type;
|
||||
insertSafety(inheritsVer, customVer,
|
||||
"assetIndex", "assets",
|
||||
"id", "mainClass", "minecraftArguments",
|
||||
"optifineLib", "releaseTime", "time", "type"
|
||||
);
|
||||
|
||||
List<DependentLibrary> libList = new ArrayList<DependentLibrary>(Arrays.asList(inheritsVer.libraries));
|
||||
try {
|
||||
@ -380,6 +378,24 @@ public final class Tools
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent NullPointerException
|
||||
private static void insertSafety(JMinecraftVersionList.Version inheritsVer, JMinecraftVersionList.Version theVer, String... keyArr) {
|
||||
for (String key : keyArr) {
|
||||
Object value = null;
|
||||
try {
|
||||
Field fieldA = theVer.getClass().getDeclaredField(key);
|
||||
value = fieldA.get(theVer);
|
||||
if (value != null || ((value instanceof String) && !((String) value).isEmpty())) {
|
||||
Field fieldB = inheritsVer.getClass().getDeclaredField(key);
|
||||
fieldB.set(inheritsVer, value);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
System.err.println("Unable to insert " + key + "=" + value);
|
||||
th.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertStream(InputStream inputStream, Charset charset) throws IOException {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
Loading…
x
Reference in New Issue
Block a user