mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 08:05:34 -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.*;
|
import org.lwjgl.opengl.*;
|
||||||
|
|
||||||
public class AndroidLWJGLKeycode {
|
public class AndroidLWJGLKeycode {
|
||||||
|
// Fix double letters on MC 1.9 and above
|
||||||
public static boolean isBackspaceAfterChar;
|
public static boolean isBackspaceAfterChar;
|
||||||
private static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
private static final ArrayMap<Integer, Integer> androidToLwjglMap;
|
||||||
private static String[] androidKeyNameArray;
|
private static String[] androidKeyNameArray;
|
||||||
static {
|
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>();
|
androidToLwjglMap = new ArrayMap<Integer, Integer>();
|
||||||
|
|
||||||
// 0-9 keys
|
// 0-9 keys
|
||||||
@ -162,7 +166,9 @@ public class AndroidLWJGLKeycode {
|
|||||||
for (Map.Entry<Integer, Integer> perKey : androidToLwjglMap.entrySet()) {
|
for (Map.Entry<Integer, Integer> perKey : androidToLwjglMap.entrySet()) {
|
||||||
if (perKey.getKey() == i) {
|
if (perKey.getKey() == i) {
|
||||||
if (i == KeyEvent.KEYCODE_BACK && (keyEvent.getSource() == InputDevice.SOURCE_MOUSE)) {
|
if (i == KeyEvent.KEYCODE_BACK && (keyEvent.getSource() == InputDevice.SOURCE_MOUSE)) {
|
||||||
// mainActivity.sendMo
|
// Right mouse detection
|
||||||
|
mainActivity.sendMouseButton(1, true);
|
||||||
|
mainActivity.sendMouseButton(1, false);
|
||||||
} else {
|
} else {
|
||||||
mainActivity.sendKeyPress(perKey.getValue(), isDown);
|
mainActivity.sendKeyPress(perKey.getValue(), isDown);
|
||||||
}
|
}
|
||||||
|
@ -6,65 +6,10 @@ public class FakeAccount
|
|||||||
{
|
{
|
||||||
public static String[] generate()
|
public static String[] generate()
|
||||||
{
|
{
|
||||||
|
// Unneccessary for generate random string, smaller code.
|
||||||
String[] arr = {
|
String[] arr = {
|
||||||
UUID.randomUUID().toString(),
|
"0", "0"
|
||||||
new RandomString(32).nextString()
|
|
||||||
};
|
};
|
||||||
return arr;
|
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) {
|
public static String toString(MCProfile.Builder builder) {
|
||||||
//System.out.println("TOSTRING THE VER = " + builder.getVersion());
|
|
||||||
|
|
||||||
return
|
return
|
||||||
builder.getClientID() + ":" +
|
builder.getClientID() + ":" +
|
||||||
builder.getProfileID() + ":" +
|
builder.getProfileID() + ":" +
|
||||||
builder.getAccessToken() + ":" +
|
builder.getAccessToken() + ":" +
|
||||||
builder.getUsername() + ":" +
|
builder.getUsername() + ":" +
|
||||||
builder.getVersion() + ":" +
|
builder.getVersion() + ":" +
|
||||||
Boolean.toString(builder.isAccount());
|
Boolean.toString(builder.isMojangAccount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder implements Serializable
|
public static class Builder implements Serializable
|
||||||
@ -114,13 +112,12 @@ public class MCProfile
|
|||||||
public Builder()
|
public Builder()
|
||||||
{
|
{
|
||||||
fullArgs = emptyBuilder;
|
fullArgs = emptyBuilder;
|
||||||
String[] fakeTokens = FakeAccount.generate();
|
setClientID("0");
|
||||||
setClientID(fakeTokens[0]);
|
setProfileID("00000000-0000-0000-0000-000000000000");
|
||||||
setProfileID(FakeAccount.generate()[0].replace("-", ""));
|
setAccessToken("0");
|
||||||
setAccessToken(fakeTokens[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAccount()
|
public boolean isMojangAccount()
|
||||||
{
|
{
|
||||||
return isAccount;
|
return isAccount;
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ public class PojavLoginActivity extends MineActivity
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(MCProfile.load(path).isAccount()){
|
if(MCProfile.load(path).isMojangAccount()){
|
||||||
MCProfile.updateTokens(PojavLoginActivity.this, path, new RefreshListener(){
|
MCProfile.updateTokens(PojavLoginActivity.this, path, new RefreshListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -356,13 +356,11 @@ public final class Tools
|
|||||||
} else {
|
} else {
|
||||||
JMinecraftVersionList.Version inheritsVer = new Gson().fromJson(read(versnDir + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json"), JMinecraftVersionList.Version.class);
|
JMinecraftVersionList.Version inheritsVer = new Gson().fromJson(read(versnDir + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json"), JMinecraftVersionList.Version.class);
|
||||||
|
|
||||||
inheritsVer.id = customVer.id;
|
insertSafety(inheritsVer, customVer,
|
||||||
inheritsVer.mainClass = customVer.mainClass;
|
"assetIndex", "assets",
|
||||||
inheritsVer.minecraftArguments = customVer.minecraftArguments;
|
"id", "mainClass", "minecraftArguments",
|
||||||
inheritsVer.optifineLib = customVer.optifineLib;
|
"optifineLib", "releaseTime", "time", "type"
|
||||||
inheritsVer.releaseTime = customVer.releaseTime;
|
);
|
||||||
inheritsVer.time = customVer.time;
|
|
||||||
inheritsVer.type = customVer.type;
|
|
||||||
|
|
||||||
List<DependentLibrary> libList = new ArrayList<DependentLibrary>(Arrays.asList(inheritsVer.libraries));
|
List<DependentLibrary> libList = new ArrayList<DependentLibrary>(Arrays.asList(inheritsVer.libraries));
|
||||||
try {
|
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 {
|
public static String convertStream(InputStream inputStream, Charset charset) throws IOException {
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user