|
1 | 1 | package com.pistacium.modcheck.util; |
2 | 2 |
|
3 | | -import com.google.gson.*; |
4 | | -import com.pistacium.modcheck.ModCheck; |
| 3 | +import com.google.gson.FieldNamingPolicy; |
| 4 | +import com.google.gson.Gson; |
| 5 | +import com.google.gson.GsonBuilder; |
5 | 6 |
|
6 | 7 | import java.io.*; |
7 | 8 | import java.net.HttpURLConnection; |
8 | 9 | import java.net.URL; |
9 | 10 | import java.nio.charset.StandardCharsets; |
10 | 11 | import java.util.HashMap; |
11 | | -import java.util.Objects; |
12 | | -import java.util.jar.JarEntry; |
13 | | -import java.util.jar.JarFile; |
14 | 12 |
|
15 | 13 | public class ModCheckUtils { |
16 | 14 | private static final HashMap<String, String> urlReqCache = new HashMap<>(); |
@@ -43,39 +41,6 @@ public static String getUrlRequest(String url) throws IllegalAccessException { |
43 | 41 | throw new IllegalAccessException("Couldn't loading url request data! check your internet status"); |
44 | 42 | } |
45 | 43 |
|
46 | | - public static JsonObject getFabricJsonFileInJar(File jarFile) { |
47 | | - try { |
48 | | - JarFile file = new JarFile(jarFile); |
49 | | - JarEntry entry = file.getJarEntry("fabric.mod.json"); |
50 | | - |
51 | | - int readBytes; |
52 | | - if (entry != null) { |
53 | | - InputStream is = file.getInputStream(entry); |
54 | | - StringBuilder jsonString = new StringBuilder(); |
55 | | - |
56 | | - while ((readBytes = is.read()) != -1) { |
57 | | - jsonString.append((char) readBytes); |
58 | | - } |
59 | | - |
60 | | - return JsonParser.parseString(jsonString.toString()).getAsJsonObject(); |
61 | | - } |
62 | | - } catch (IOException e) { |
63 | | - e.printStackTrace(); |
64 | | - } |
65 | | - return null; |
66 | | - } |
67 | | - |
68 | | - public static String getAPIUrl(String url, String type) { |
69 | | - if (Objects.equals(type, "github_releases")) { |
70 | | - return "https://me.redlimerl.com/mcsr/modcheck?type=github&target=" + url.split("/")[4] + "%2F" + url.split("/")[5]; |
71 | | - } |
72 | | - if (Objects.equals(type, "curseforge_files")) { |
73 | | - return "https://me.redlimerl.com/mcsr/modcheck?type=curseforge&target=" + url.split("/")[5]; |
74 | | - } |
75 | | - |
76 | | - return url; |
77 | | - } |
78 | | - |
79 | 44 | public static Config readConfig() { |
80 | 45 | Gson gson = new Gson(); |
81 | 46 | File file = new File("modcheck.json"); |
|
0 commit comments