1
1
package com .pistacium .modcheck ;
2
2
3
+ import com .google .gson .Gson ;
4
+ import com .google .gson .GsonBuilder ;
3
5
import com .google .gson .JsonElement ;
4
6
import com .google .gson .JsonParser ;
5
- import com .pistacium .modcheck .mod .ModData ;
6
- import com .pistacium .modcheck .mod .version . ModVersion ;
7
+ import com .pistacium .modcheck .mod .MCVersion ;
8
+ import com .pistacium .modcheck .mod .ModInfo ;
7
9
import com .pistacium .modcheck .util .ModCheckStatus ;
8
10
import com .pistacium .modcheck .util .ModCheckUtils ;
9
11
@@ -24,40 +26,40 @@ public static void setStatus(ModCheckStatus status) {
24
26
FRAME_INSTANCE .getProgressBar ().setString (status .getDescription ());
25
27
}
26
28
29
+ public static final Gson GSON = new GsonBuilder ().serializeNulls ().create ();
27
30
public static final ExecutorService THREAD_EXECUTOR = Executors .newSingleThreadExecutor ();
28
31
29
- public static ModCheckFrame FRAME_INSTANCE ;
32
+ public static ModCheckFrameForm FRAME_INSTANCE ;
30
33
31
- public static final ArrayList <ModVersion > AVAILABLE_VERSIONS = new ArrayList <>();
32
-
33
- public static final ArrayList <ModData > AVAILABLE_MODS = new ArrayList <>();
34
+ public static final ArrayList <MCVersion > AVAILABLE_VERSIONS = new ArrayList <>();
34
35
36
+ public static final ArrayList <ModInfo > AVAILABLE_MODS = new ArrayList <>();
35
37
36
38
public static void main (String [] args ) {
37
39
THREAD_EXECUTOR .submit (() -> {
38
40
try {
39
- FRAME_INSTANCE = new ModCheckFrame ();
41
+ FRAME_INSTANCE = new ModCheckFrameForm ();
40
42
41
43
// Get available versions
42
44
setStatus (ModCheckStatus .LOADING_AVAILABLE_VERSIONS );
43
- JsonElement availableElement = JsonParser .parseString (Objects .requireNonNull (ModCheckUtils .getUrlRequest ("https://redlime.github.io/MCSRMods/mod_versions .json" )));
45
+ JsonElement availableElement = JsonParser .parseString (Objects .requireNonNull (ModCheckUtils .getUrlRequest ("https://redlime.github.io/MCSRMods/meta/v4/mc_versions .json" )));
44
46
FRAME_INSTANCE .getProgressBar ().setValue (30 );
45
47
for (JsonElement jsonElement : availableElement .getAsJsonArray ()) {
46
- AVAILABLE_VERSIONS .add (ModVersion . of (jsonElement . getAsString () ));
48
+ AVAILABLE_VERSIONS .add (GSON . fromJson (jsonElement , MCVersion . class ));
47
49
}
48
50
49
51
// Get mod list
50
52
setStatus (ModCheckStatus .LOADING_MOD_LIST );
51
- JsonElement modElement = JsonParser .parseString (Objects .requireNonNull (ModCheckUtils .getUrlRequest ("https://redlime.github.io/MCSRMods/meta/v3/mods .json" )));
53
+ JsonElement modElement = JsonParser .parseString (Objects .requireNonNull (ModCheckUtils .getUrlRequest ("https://redlime.github.io/MCSRMods/meta/v4/files .json" )));
52
54
FRAME_INSTANCE .getProgressBar ().setValue (60 );
53
55
54
56
setStatus (ModCheckStatus .LOADING_MOD_RESOURCE );
55
57
int count = 0 , maxCount = modElement .getAsJsonArray ().size ();
56
58
for (JsonElement jsonElement : modElement .getAsJsonArray ()) {
57
59
try {
58
60
FRAME_INSTANCE .getProgressBar ().setString ("Loading information of " +jsonElement .getAsJsonObject ().get ("name" ));
59
- ModData modData = new ModData (jsonElement . getAsJsonObject () );
60
- AVAILABLE_MODS .add (modData );
61
+ ModInfo modInfo = GSON . fromJson (jsonElement , ModInfo . class );
62
+ if ( Objects . equals ( modInfo . getType (), "fabric_mod" )) AVAILABLE_MODS .add (modInfo );
61
63
} catch (Throwable e ) {
62
64
StringWriter sw = new StringWriter ();
63
65
PrintWriter pw = new PrintWriter (sw );
0 commit comments