mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Refactor: Remove old migrators
They are now not needed, partially due to google policy regarding storage
This commit is contained in:
parent
b98c012c29
commit
a896ffb273
@ -1,143 +0,0 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import java.io.*;;
|
||||
|
||||
/**
|
||||
* This account data format is deprecated.
|
||||
* The current account data format is JSON on net.kdt.pojavlaunch.value.MinecraftAccount.
|
||||
* This class remain for account data migrator only.
|
||||
* Methods for saving/exporting on this format are no longer available.
|
||||
*/
|
||||
@Deprecated
|
||||
public class MCProfile
|
||||
{
|
||||
private static String[] emptyBuilder = new String[]{
|
||||
"1.9", //Version
|
||||
"ProfileIDEmpty",
|
||||
"AccessToken",
|
||||
"AccessTokenEmpty",
|
||||
"Steve"
|
||||
};
|
||||
|
||||
public static MCProfile.Builder load(String pofFilePath) {
|
||||
try {
|
||||
String pofContent = Tools.read(pofFilePath);
|
||||
return parse(pofContent);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unable to load Profile " + pofFilePath, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static MCProfile.Builder parse(String content) {
|
||||
if (content == null || content.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MCProfile.Builder builder = new MCProfile.Builder();
|
||||
|
||||
String[] profileInfos = content.split(":");
|
||||
|
||||
String cltk = profileInfos[0];
|
||||
String prtk = profileInfos[1];
|
||||
String acct = profileInfos[2];
|
||||
String name = profileInfos[3];
|
||||
String vers = profileInfos[4];
|
||||
String isAc = profileInfos[5];
|
||||
|
||||
//System.out.println("parse THE VER = " + vers);
|
||||
|
||||
builder.setClientID(cltk);
|
||||
builder.setProfileID(prtk);
|
||||
builder.setAccessToken(acct);
|
||||
builder.setUsername(name);
|
||||
builder.setVersion(vers);
|
||||
builder.setIsMojangAccount(Boolean.parseBoolean(isAc));
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static MCProfile.Builder loadSafety(String pofFilePath) {
|
||||
try {
|
||||
return load(pofFilePath);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
// return new MCProfile.Builder();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder implements Serializable
|
||||
{
|
||||
private String[] fullArgs = new String[6];
|
||||
private boolean isMojangAccount = true;
|
||||
|
||||
public Builder()
|
||||
{
|
||||
fullArgs = emptyBuilder;
|
||||
setClientID("0");
|
||||
setProfileID("00000000-0000-0000-0000-000000000000");
|
||||
setAccessToken("0");
|
||||
}
|
||||
|
||||
public boolean isMojangAccount()
|
||||
{
|
||||
return isMojangAccount;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return fullArgs[0];
|
||||
}
|
||||
|
||||
public String getClientID()
|
||||
{
|
||||
return fullArgs[1];
|
||||
}
|
||||
|
||||
public String getProfileID()
|
||||
{
|
||||
return fullArgs[2];
|
||||
}
|
||||
|
||||
public String getAccessToken()
|
||||
{
|
||||
return fullArgs[3];
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return fullArgs[4];
|
||||
}
|
||||
|
||||
public void setIsMojangAccount(boolean value)
|
||||
{
|
||||
isMojangAccount = value;
|
||||
}
|
||||
|
||||
public void setVersion(String value)
|
||||
{
|
||||
fullArgs[0] = value;
|
||||
}
|
||||
|
||||
public void setClientID(String value)
|
||||
{
|
||||
fullArgs[1] = value;
|
||||
}
|
||||
|
||||
public void setProfileID(String value)
|
||||
{
|
||||
fullArgs[2] = value;
|
||||
}
|
||||
|
||||
public void setAccessToken(String value)
|
||||
{
|
||||
fullArgs[3] = value;
|
||||
}
|
||||
|
||||
public void setUsername(String value)
|
||||
{
|
||||
fullArgs[4] = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -315,17 +315,10 @@ public class PojavLoginActivity extends BaseActivity {
|
||||
}
|
||||
private void initMain() throws Throwable {
|
||||
mkdirs(Tools.DIR_ACCOUNT_NEW);
|
||||
PojavMigrator.migrateAccountData(this);
|
||||
|
||||
mkdirs(Tools.DIR_GAME_HOME);
|
||||
mkdirs(Tools.DIR_GAME_HOME + "/lwjgl3");
|
||||
mkdirs(Tools.DIR_GAME_HOME + "/config");
|
||||
if (!PojavMigrator.migrateGameDir()) {
|
||||
mkdirs(Tools.DIR_GAME_NEW);
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/mods");
|
||||
mkdirs(Tools.DIR_HOME_VERSION);
|
||||
mkdirs(Tools.DIR_HOME_LIBRARY);
|
||||
}
|
||||
|
||||
mkdirs(Tools.CTRLMAP_PATH);
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
import android.content.*;
|
||||
import java.io.*;
|
||||
import net.kdt.pojavlaunch.value.*;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public class PojavMigrator {
|
||||
public static void migrateAccountData(Context ctx) {
|
||||
File oldAccDir = new File(Tools.DIR_ACCOUNT_OLD);
|
||||
if (oldAccDir.exists() && oldAccDir.isDirectory()) {
|
||||
for (String account : oldAccDir.list()) {
|
||||
File oldAccFile = new File(oldAccDir, account);
|
||||
|
||||
try {
|
||||
MCProfile.Builder oldAccStruct = MCProfile.load(oldAccFile.getAbsolutePath());
|
||||
|
||||
MinecraftAccount newAccStruct = new MinecraftAccount();
|
||||
newAccStruct.accessToken = oldAccStruct.getAccessToken();
|
||||
newAccStruct.clientToken = oldAccStruct.getClientID();
|
||||
newAccStruct.isMicrosoft = false;
|
||||
newAccStruct.profileId = oldAccStruct.getProfileID();
|
||||
newAccStruct.selectedVersion = oldAccStruct.getVersion();
|
||||
newAccStruct.username = oldAccStruct.getUsername();
|
||||
newAccStruct.save();
|
||||
} catch (IOException e) {
|
||||
Tools.showError(ctx, e);
|
||||
}
|
||||
|
||||
oldAccFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean migrateGameDir() throws IOException {
|
||||
File oldGameDir = new File(Tools.DIR_GAME_OLD);
|
||||
|
||||
boolean moved = oldGameDir.exists() && oldGameDir.isDirectory();
|
||||
/*
|
||||
if (!migrateBugFix20201217() && moved) {
|
||||
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
|
||||
}
|
||||
*/
|
||||
if(moved) {
|
||||
oldGameDir.renameTo(new File(Tools.DIR_GAME_NEW + "/"));
|
||||
FileUtils.deleteDirectory(new File(Tools.DIR_GAME_NEW + "/lwjgl3"));
|
||||
}
|
||||
return moved;
|
||||
}
|
||||
|
||||
private static void command(String cmd) throws IOException, InterruptedException {
|
||||
Process p = Runtime.getRuntime().exec(cmd);
|
||||
int exitCode = p.waitFor();
|
||||
if (exitCode != 0) {
|
||||
throw new IOException("Exit code " + exitCode +
|
||||
", message:\n" + Tools.read(p.getErrorStream()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user