From e6f34363d5e982849b16650308193bf1a10c7cf5 Mon Sep 17 00:00:00 2001 From: Darien Johnson <84008186+CADIndie@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:50:08 -0400 Subject: [PATCH] Slightly More Logging --- .../java/pojlib/account/MinecraftAccount.java | 9 ++++-- .../java/pojlib/instance/InstanceHandler.java | 6 ---- src/main/java/pojlib/util/DownloadUtils.java | 28 +------------------ 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/main/java/pojlib/account/MinecraftAccount.java b/src/main/java/pojlib/account/MinecraftAccount.java index 14ecd45a..fabe9f44 100644 --- a/src/main/java/pojlib/account/MinecraftAccount.java +++ b/src/main/java/pojlib/account/MinecraftAccount.java @@ -16,6 +16,7 @@ import pojlib.util.Constants; import pojlib.util.GsonUtils; +import pojlib.util.Logger; public class MinecraftAccount { @@ -37,7 +38,9 @@ public static MinecraftAccount login(String gameDir, String[] response) throws I public static boolean logout(Activity activity) { File accountFile = new File(activity.getFilesDir() + "/accounts/account.json"); - return accountFile.delete(); + File accountCache = new File(Constants.USER_HOME + "/cache_data"); + + return accountFile.delete() && accountCache.delete(); } //Try this before using login - the account will have been saved to disk if previously logged in @@ -54,16 +57,16 @@ public static MinecraftAccount load(String path, @Nullable String newToken, @Nul GsonUtils.objectToJsonFile(path + "/account.json", acc); return acc; } catch (IOException | JSONException e) { + Logger.getInstance().appendToLog("Unable to load account! | " + e); return null; } } public static String getSkinFaceUrl(MinecraftAccount account) { - //TODO: Log this to latestlog.txt for Support staff try { return Constants.MINOTAR_URL + "/helm/" + account.uuid; } catch (NullPointerException e) { - System.out.println("Username not set! Please set your username at Minecraft.net and try again."); + Logger.getInstance().appendToLog("Username likely not set! Please set your username at Minecraft.net and try again. | " + e); return null; } } diff --git a/src/main/java/pojlib/instance/InstanceHandler.java b/src/main/java/pojlib/instance/InstanceHandler.java index c857083b..a5c0cb64 100644 --- a/src/main/java/pojlib/instance/InstanceHandler.java +++ b/src/main/java/pojlib/instance/InstanceHandler.java @@ -79,12 +79,6 @@ public static MinecraftInstances.Instance create(Activity activity, MinecraftIns modLoaderVersionInfo = QuiltMeta.getVersionInfo(quiltVersion, minecraftVersion); break; } - case Forge: - case NeoForge: - { - System.out.println("Error!: You cannot use Forge or NeoForge with QuestCraft!"); - break; - } } VersionInfo minecraftVersionInfo = MinecraftMeta.getVersionInfo(minecraftVersion); diff --git a/src/main/java/pojlib/util/DownloadUtils.java b/src/main/java/pojlib/util/DownloadUtils.java index 88a08609..ad561e02 100644 --- a/src/main/java/pojlib/util/DownloadUtils.java +++ b/src/main/java/pojlib/util/DownloadUtils.java @@ -1,9 +1,5 @@ package pojlib.util; -import android.content.res.AssetManager; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; @@ -14,17 +10,10 @@ import java.net.HttpURLConnection; import java.net.URL; import java.nio.file.Files; -import java.util.ArrayList; import java.util.Objects; -import static pojlib.util.FileUtil.read; -import static pojlib.util.GsonUtils.GLOBAL_GSON; - public class DownloadUtils { - public static AssetManager assetManager; - - private static void download(URL url, OutputStream os) throws IOException { final int MAX_RETRIES = 3; int attempts = 0; @@ -96,23 +85,8 @@ public static boolean compareSHA1(File f, String sourceSHA) { else return true; // fake match }catch (IOException e) { - System.out.println("Fake-matching a hash due to a read error: " + e); + Logger.getInstance().appendToLog("Fake-matching a hash due to a read error: " + e); return true; } } - - public static ArrayList getCompatibleVersions(String tag) { - ArrayList versions = new ArrayList<>(); - try { - InputStream stream = assetManager.open("jsons/modmanager.json"); - JsonObject versionsJson = GLOBAL_GSON.fromJson(read(stream), JsonObject.class); - - for (JsonElement version : versionsJson.get("compatible_versions").getAsJsonObject().getAsJsonArray(tag)) { - versions.add(version.getAsString()); - } - } catch (IOException e) { - e.printStackTrace(); - } - return versions; - } }