Skip to content

Commit

Permalink
chore: Added more logging information to MCVersionMappingCacheImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeGodSRC committed Jan 4, 2025
1 parent 49fd9c1 commit 7137394
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.gson.stream.JsonReader;
import io.fairyproject.Fairy;
import io.fairyproject.log.Log;
import io.fairyproject.util.exceptionally.SneakyThrowUtil;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;

Expand All @@ -13,6 +14,7 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
Expand Down Expand Up @@ -41,9 +43,21 @@ public JsonArray read() {

@Override
public @NotNull JsonArray load() throws IOException {
URLConnection urlConnection = new URL("https://raw.githubusercontent.com/PrismarineJS/minecraft-data/master/data/pc/common/protocolVersions.json").openConnection();
// load the output of the connection into a json array
return gson.fromJson(new JsonReader(new InputStreamReader(urlConnection.getInputStream())), JsonArray.class);
String url = "https://raw.githubusercontent.com/PrismarineJS/minecraft-data/master/data/pc/common/protocolVersions.json";

try {
URLConnection urlConnection = new URL(url).openConnection();
// load the output of the connection into a json array
return gson.fromJson(new JsonReader(new InputStreamReader(urlConnection.getInputStream())), JsonArray.class);
} catch (UnknownHostException e) {
io.fairyproject.log.Log.error("Unable to locate raw.githubusercontent.com, please check your internet connection.");
io.fairyproject.log.Log.error("If you are behind a proxy, please make sure to configure it properly.");
io.fairyproject.log.Log.error("If you are using a firewall, please make sure to whitelist the connection.");
io.fairyproject.log.Log.error("Fairy is trying to load " + url + " to get the latest protocol versions, please whitelist it at least once.");

SneakyThrowUtil.sneakyThrow(e);
return null;
}
}

@Override
Expand Down

0 comments on commit 7137394

Please sign in to comment.