Upload files to "src/openonyx/connection"
This commit is contained in:
1 parent
62ff8edf42
commit
c03ad74bbd
5 files changed
+474
No files matched your search
@@ -0,0 +1,135 @@
|
||||
package openonyx.connection;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.util.Session;
|
||||
import openonyx.connection.internal.AuthException;
|
||||
|
||||
public abstract class Account {
|
||||
protected String i;
|
||||
private final AccountType accountType;
|
||||
protected long H;
|
||||
protected UUID uuid;
|
||||
|
||||
protected static long L(JsonObject jsonObject, String string, long l) {
|
||||
JsonElement jsonElement;
|
||||
return (jsonElement = jsonObject.get(string)) != null && jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isNumber()
|
||||
? jsonElement.getAsLong()
|
||||
: l;
|
||||
}
|
||||
|
||||
protected Account(AccountType accountType, String string) {
|
||||
this.accountType = accountTypex;
|
||||
this.i = string;
|
||||
this.H = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String D() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public abstract void L() throws AuthException;
|
||||
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public String d() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String L() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static String L(JsonObject jsonObject, String string) {
|
||||
JsonElement jsonElement;
|
||||
return (jsonElement = jsonObject.get(string)) != null && jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isString()
|
||||
? jsonElement.getAsString()
|
||||
: null;
|
||||
}
|
||||
|
||||
public long d() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public abstract Session L() throws AuthException;
|
||||
|
||||
public final JsonObject L() {
|
||||
Account account1 = this;
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("type", account1.accountType.d());
|
||||
jsonObject.addProperty("name", account1.i);
|
||||
jsonObject.addProperty("addedAt", account1.H);
|
||||
if (account1.uuid != null) {
|
||||
jsonObject.addProperty("uuid", account1.uuid.toString());
|
||||
}
|
||||
|
||||
account1.d(jsonObject);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
protected abstract void d(JsonObject jsonObject);
|
||||
|
||||
protected static boolean L(JsonObject jsonObject, String string, boolean bl) {
|
||||
JsonElement jsonElement;
|
||||
return (jsonElement = jsonObject.get(string)) != null && jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isBoolean()
|
||||
? jsonElement.getAsBoolean()
|
||||
: bl;
|
||||
}
|
||||
|
||||
public long L() {
|
||||
return this.H;
|
||||
}
|
||||
|
||||
public static Account L(JsonObject jsonObject) {
|
||||
JsonObject jsonObject1 = jsonObject;
|
||||
AccountType accountTypex;
|
||||
if ((accountTypex = AccountType.L(L(jsonObject1, "type"))) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String string;
|
||||
if ((string = L(jsonObject1, "name")) != null && !string.isBlank()) {
|
||||
JsonObject jsonObject2;
|
||||
label37: {
|
||||
account = switch (accountTypex) {
|
||||
case OFFLINE -> new OfflineAccount(string);
|
||||
case ACCESS_TOKEN -> new TokenAccount(string);
|
||||
case MICROSOFT -> new MicrosoftAccount(string);
|
||||
};
|
||||
String string1;
|
||||
label36:
|
||||
if ((string1 = L(jsonObject1, "uuid")) != null) {
|
||||
try {
|
||||
account.uuid = UUID.fromString(string1);
|
||||
} catch (IllegalArgumentException illegalArgumentException) {
|
||||
break label36;
|
||||
}
|
||||
|
||||
jsonObject2 = jsonObject1;
|
||||
break label37;
|
||||
}
|
||||
|
||||
jsonObject2 = jsonObject1;
|
||||
}
|
||||
|
||||
JsonElement jsonElement;
|
||||
if ((jsonElement = jsonObject2.get("addedAt")) != null && jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isNumber()) {
|
||||
account.H = jsonElement.getAsLong();
|
||||
}
|
||||
|
||||
account.L(jsonObject1);
|
||||
return account;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void L(JsonObject jsonObject);
|
||||
|
||||
public AccountType getAccountType() {
|
||||
return this.accountType;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user