From 6494950dc1bb0f158b5b8ddc6f824e6584a15159 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Mon, 12 Oct 2020 12:36:49 +0700 Subject: [PATCH] Some changes - Fix crashing if custom_env.txt not exists. - Update README.md --- README.md | 1 + .../main/java/net/kdt/pojavlaunch/JREUtils.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 20941e061..47f394950 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Android CI](https://github.com/PojavLauncherTeam/PojavLauncher/workflows/Android%20CI/badge.svg)](https://github.com/PojavLauncherTeam/PojavLauncher/actions) +[![Crowdin](https://badges.crowdin.net/pojavlauncher/localized.svg)](https://crowdin.com/project/pojavlauncher) # PojavLauncher A Minecraft: Java Edition launcher for Android based from Boardwalk. This branch is intended to support 1.13+ diff --git a/app/src/main/java/net/kdt/pojavlaunch/JREUtils.java b/app/src/main/java/net/kdt/pojavlaunch/JREUtils.java index cc4d1bdf4..c461ea24f 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/JREUtils.java +++ b/app/src/main/java/net/kdt/pojavlaunch/JREUtils.java @@ -123,14 +123,17 @@ public class JREUtils setEnvironment(launchType, "AWTSTUB_WIDTH", Integer.toString(CallbackBridge.windowWidth)); setEnvironment(launchType, "AWTSTUB_HEIGHT", Integer.toString(CallbackBridge.windowHeight)); - BufferedReader reader = new BufferedReader(new FileReader(new File(Tools.MAIN_PATH, "custom_env.txt"))); - String line; - while ((line = reader.readLine()) != null) { - // Not use split() as only split first one - int index = line.indexOf("="); - setEnvironment(launchType, line.substring(0, index), line.substring(index + 1)); + File customEnvFile = new File(Tools.MAIN_PATH, "custom_env.txt"); + if (customEnvFile.exists() && customEnvFile.isFile()) { + BufferedReader reader = new BufferedReader(new FileReader(customEnvFile)); + String line; + while ((line = reader.readLine()) != null) { + // Not use split() as only split first one + int index = line.indexOf("="); + setEnvironment(launchType, line.substring(0, index), line.substring(index + 1)); + } + reader.close(); } - reader.close(); // REGAL_GL_EXTENSIONS