Пример #1
0
 private static ModInfo getForgeModInfo(File f, ZipFile jar, ZipEntry entry) throws IOException {
   ModInfo i = new ModInfo();
   i.location = f;
   List<ModInfo> m =
       C.gson.fromJson(
           new InputStreamReader(jar.getInputStream(entry)),
           new TypeToken<List<ModInfo>>() {}.getType());
   if (m != null && m.size() > 0) {
     i = m.get(0);
     i.location = f;
   }
   return i;
 }
Пример #2
0
 private static ModInfo getLiteLoaderModInfo(File f, ZipFile jar, ZipEntry entry)
     throws IOException {
   ModInfo m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), ModInfo.class);
   if (m == null) m = new ModInfo();
   m.location = f;
   return m;
 }
Пример #3
0
 public static ModInfo readModInfo(File f) {
   ModInfo i = new ModInfo();
   i.location = f;
   try {
     try (ZipFile jar = new ZipFile(f)) {
       ZipEntry entry = jar.getEntry("mcmod.info");
       if (entry != null) return getForgeModInfo(f, jar, entry);
       entry = jar.getEntry("litemod.json");
       if (entry != null) return getLiteLoaderModInfo(f, jar, entry);
       return i;
     }
   } catch (IOException ex) {
     HMCLog.warn("File " + f + " is not a jar.", ex);
   } catch (JsonSyntaxException ignore) {
   }
   return i;
 }