1
1
package me .dreamvoid .miraimc .internal ;
2
2
3
- import com .google .gson .Gson ;
4
-
5
3
import java .io .BufferedReader ;
6
4
import java .io .IOException ;
7
5
import java .io .InputStream ;
8
6
import java .io .InputStreamReader ;
9
7
import java .net .HttpURLConnection ;
10
8
import java .net .URL ;
11
9
import java .nio .charset .StandardCharsets ;
12
- import java .util .HashMap ;
13
10
14
11
public class PluginUpdate {
15
- public static String getVersion () throws IOException {
16
- URL url = new URL ("https://api.github.com/repos/DreamVoid/MiraiMC/releases/latest" );
12
+ private final String latestRelease ;
13
+ private final int latestReleaseNo ;
14
+ private final String latestPreRelease ;
15
+ private final int latestPreReleaseNo ;
16
+
17
+ public PluginUpdate () throws IOException {
18
+ URL url = new URL ("https://raw.githubusercontent.com/DreamVoid/MiraiMC/main/version" );
17
19
StringBuilder sb = new StringBuilder ();
18
20
HttpURLConnection httpUrlConn = (HttpURLConnection ) url .openConnection ();
19
21
@@ -34,7 +36,30 @@ public static String getVersion() throws IOException {
34
36
input .close ();
35
37
httpUrlConn .disconnect ();
36
38
37
- HashMap datax = new Gson ().fromJson (sb .toString (),HashMap .class );
38
- return (String ) datax .get ("name" );
39
+ String [] version = sb .toString ().split (";" );
40
+
41
+ String [] release = version [0 ].split (":" );
42
+ latestRelease = release [0 ];
43
+ latestReleaseNo = Integer .parseInt (release [1 ]);
44
+
45
+ String [] preRelease = version [1 ].split (":" );
46
+ latestPreRelease = preRelease [0 ];
47
+ latestPreReleaseNo = Integer .parseInt (preRelease [1 ]);
48
+ }
49
+
50
+ public String getLatestRelease () {
51
+ return latestRelease ;
52
+ }
53
+
54
+ public int getLatestReleaseNo () {
55
+ return latestReleaseNo ;
56
+ }
57
+
58
+ public String getLatestPreRelease () {
59
+ return latestPreRelease ;
60
+ }
61
+
62
+ public int getLatestPreReleaseNo () {
63
+ return latestPreReleaseNo ;
39
64
}
40
65
}
0 commit comments