Skip to content

Commit

Permalink
More changes to allow Geyser to cooperate better with bad internet (G…
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy authored Feb 21, 2021
1 parent b782826 commit f480fbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ private static void downloadLocale(String locale) {
}
}
} catch (IOException ignored) { }

if (clientJarInfo == null) {
// Likely failed to download
GeyserConnector.getInstance().getLogger().debug("Skipping en_US hash check as client jar is null.");
return;
}
targetHash = clientJarInfo.getSha1();
} else {
curHash = byteArrayToHexString(FileUtils.calculateSHA1(localeFile));
Expand All @@ -168,9 +174,13 @@ private static void downloadLocale(String locale) {
return;
}

// Get the hash and download the locale
String hash = ASSET_MAP.get("minecraft/lang/" + locale + ".json").getHash();
WebUtils.downloadFile("https://resources.download.minecraft.net/" + hash.substring(0, 2) + "/" + hash, localeFile.toString());
try {
// Get the hash and download the locale
String hash = ASSET_MAP.get("minecraft/lang/" + locale + ".json").getHash();
WebUtils.downloadFile("https://resources.download.minecraft.net/" + hash.substring(0, 2) + "/" + hash, localeFile.toString());
} catch (Exception e) {
GeyserConnector.getInstance().getLogger().error("Unable to download locale file hash", e);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public static void downloadFile(String reqURL, String fileLocation) {
}

public static String post(String reqURL, String postContent) throws IOException {
URL url = null;
url = new URL(reqURL);
URL url = new URL(reqURL);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/plain");
Expand Down

0 comments on commit f480fbf

Please sign in to comment.