Skip to content

Commit

Permalink
Slightly More Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
CADIndie committed Apr 17, 2024
1 parent 49a9357 commit e6f3436
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
9 changes: 6 additions & 3 deletions src/main/java/pojlib/account/MinecraftAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import pojlib.util.Constants;
import pojlib.util.GsonUtils;
import pojlib.util.Logger;

public class MinecraftAccount {

Expand All @@ -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
Expand All @@ -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;
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/pojlib/instance/InstanceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 1 addition & 27 deletions src/main/java/pojlib/util/DownloadUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<String> getCompatibleVersions(String tag) {
ArrayList<String> 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;
}
}

0 comments on commit e6f3436

Please sign in to comment.