mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
More cleanup + make it more convenient to obtain the current profile
This commit is contained in:
parent
a6a5675b9c
commit
28cbbaca61
@ -57,11 +57,9 @@ public class JRE17Util {
|
||||
return true;
|
||||
|
||||
LauncherProfiles.update();
|
||||
MinecraftProfile minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, ""));
|
||||
MinecraftProfile minecraftProfile = LauncherProfiles.getCurrentProfile();
|
||||
|
||||
String selectedRuntime = null;
|
||||
if (minecraftProfile.javaDir != null && minecraftProfile.javaDir.startsWith(Tools.LAUNCHERPROFILES_RTPREFIX))
|
||||
selectedRuntime = minecraftProfile.javaDir.substring(Tools.LAUNCHERPROFILES_RTPREFIX.length());
|
||||
String selectedRuntime = Tools.pickRuntime(minecraftProfile);
|
||||
|
||||
Runtime runtime = selectedRuntime != null ? MultiRTUtils.read(selectedRuntime) : MultiRTUtils.read(LauncherPreferences.PREF_DEFAULT_RUNTIME);
|
||||
if (runtime.javaVersion >= versionInfo.javaVersion.majorVersion) return true;
|
||||
|
@ -77,8 +77,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mProfile = PojavProfile.getCurrentProfileContent(this, null);
|
||||
if(LauncherProfiles.mainProfileJson == null) LauncherProfiles.update();
|
||||
minecraftProfile = LauncherProfiles.mainProfileJson.profiles.get(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,""));
|
||||
minecraftProfile = LauncherProfiles.getCurrentProfile();
|
||||
MCOptionUtils.load(Tools.getGameDirPath(minecraftProfile).getAbsolutePath());
|
||||
GameService.startService(this);
|
||||
initLayout(R.layout.activity_basemain);
|
||||
|
@ -34,7 +34,9 @@ public class PojavApplication extends Application {
|
||||
try {
|
||||
// Write to file, since some devices may not able to show error
|
||||
File crashHome = crashFile.getParentFile();
|
||||
if(crashHome != null) crashHome.mkdirs();
|
||||
if(crashHome != null && !crashHome.exists() && !crashHome.mkdirs()) {
|
||||
throw new IOException("Failed to create crash log home");
|
||||
}
|
||||
PrintStream crashStream = new PrintStream(crashFile);
|
||||
crashStream.append("PojavLauncher crash report\n");
|
||||
crashStream.append(" - Time: ").append(DateFormat.getDateTimeInstance().format(new Date())).append("\n");
|
||||
@ -50,8 +52,6 @@ public class PojavApplication extends Application {
|
||||
}
|
||||
|
||||
FatalErrorActivity.showError(PojavApplication.this, crashFile.getAbsolutePath(), storagePermAllowed, th);
|
||||
// android.os.Process.killProcess(android.os.Process.myPid());
|
||||
|
||||
MainActivity.fullyExit();
|
||||
});
|
||||
|
||||
@ -60,12 +60,7 @@ public class PojavApplication extends Application {
|
||||
Tools.APP_NAME = getResources().getString(R.string.app_short_name);
|
||||
|
||||
Tools.DIR_DATA = getDir("files", MODE_PRIVATE).getParent();
|
||||
//Tools.DIR_HOME_JRE = Tools.DIR_DATA + "/jre_runtime".replace("/data/user/0", "/data/data");
|
||||
Tools.DIR_ACCOUNT_OLD = Tools.DIR_DATA + "/Users";
|
||||
Tools.DIR_ACCOUNT_NEW = Tools.DIR_DATA + "/accounts";
|
||||
// Tools.FILE_ACCOUNT_JSON = getFilesDir().getAbsolutePath() + "/account_profiles.json";
|
||||
|
||||
|
||||
Tools.DEVICE_ARCHITECTURE = Architecture.getDeviceArchitecture();
|
||||
//Force x86 lib directory for Asus x86 based zenfones
|
||||
if(Architecture.isx86Device() && Architecture.is32BitsDevice()){
|
||||
|
@ -92,7 +92,6 @@ public final class Tools {
|
||||
|
||||
// New since 3.3.1
|
||||
public static String DIR_ACCOUNT_NEW;
|
||||
public static String DIR_ACCOUNT_OLD;
|
||||
public static String DIR_GAME_HOME = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher";
|
||||
public static String DIR_GAME_NEW;
|
||||
|
||||
|
@ -40,7 +40,6 @@ public class LocalLoginFragment extends Fragment {
|
||||
|
||||
/** @return Whether the mail (and password) text are eligible to make an auth request */
|
||||
private boolean checkEditText(){
|
||||
new File(Tools.DIR_ACCOUNT_OLD).mkdir();
|
||||
|
||||
String text = mUsernameEditText.getText().toString();
|
||||
|
||||
|
@ -145,7 +145,8 @@ public class MultiRTUtils {
|
||||
}
|
||||
|
||||
public static File getRuntimeHome(String name) {
|
||||
File dest = new File(RUNTIME_FOLDER,"/"+name);
|
||||
File dest = new File(RUNTIME_FOLDER, name);
|
||||
Log.i("MiltiRTUitls", "Dest exists? "+dest.exists());
|
||||
if((!dest.exists()) || MultiRTUtils.forceReread(name).versionString == null) throw new RuntimeException("Selected runtime is broken!");
|
||||
return dest;
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package net.kdt.pojavlaunch.value;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
@Keep
|
||||
public class ForgeInstallProfile {
|
||||
// ----- < 1.12.2 Forge Install Profile -----
|
||||
public ForgeInstallProperties install;
|
||||
public JMinecraftVersionList.Version versionInfo;
|
||||
|
||||
@Keep
|
||||
public static class ForgeInstallProperties {
|
||||
public String profileName;
|
||||
public String target;
|
||||
public String path;
|
||||
public String version;
|
||||
public String filePath; // universal file .jar
|
||||
public String minecraft; // target Minecraft version
|
||||
}
|
||||
|
||||
// ----- 1.12.2+ Forge Install Profile -----
|
||||
public String version;
|
||||
public String json;
|
||||
public String path;
|
||||
public String minecraft; // target Minecraft version
|
||||
}
|
@ -2,7 +2,10 @@ package net.kdt.pojavlaunch.value.launcherprofiles;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.kdt.pojavlaunch.Tools;
|
||||
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -36,6 +39,14 @@ public class LauncherProfiles {
|
||||
}
|
||||
}
|
||||
|
||||
public static @NonNull MinecraftProfile getCurrentProfile() {
|
||||
if(mainProfileJson == null) LauncherProfiles.update();
|
||||
String defaultProfileName = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, "");
|
||||
MinecraftProfile profile = mainProfileJson.profiles.get(defaultProfileName);
|
||||
if(profile == null) throw new RuntimeException("The current profile stopped existing :(");
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* For all keys to be UUIDs, effectively isolating profile created by installers
|
||||
* This avoids certain profiles to be erased by the installer
|
||||
|
Loading…
x
Reference in New Issue
Block a user