|
3 | 3 | import com.google.gson.Gson; |
4 | 4 | import com.google.gson.JsonObject; |
5 | 5 | import me.dreamvoid.miraimc.api.MiraiMC; |
| 6 | +import me.dreamvoid.universalpluginupdater.BuildConstants; |
6 | 7 | import org.jetbrains.annotations.NotNull; |
7 | 8 | import org.jetbrains.annotations.Nullable; |
8 | 9 |
|
|
17 | 18 | import java.util.logging.Logger; |
18 | 19 |
|
19 | 20 | public final class Utils { |
20 | | - private static final String version = "PROJECT.VERSION"; |
21 | | - |
22 | 21 | static { |
23 | 22 | Logger logger = Logger.getLogger("MiraiMC Preload Checker"); |
24 | 23 | // 此处放置插件自检代码 |
@@ -127,7 +126,7 @@ public static String get(String url) throws IOException { |
127 | 126 |
|
128 | 127 | connection.setDoInput(true); |
129 | 128 | connection.setRequestMethod("GET"); |
130 | | - connection.setRequestProperty("User-Agent", String.format("MiraiMC/%s (%s; Java %s)", version, System.getProperty("os.name"), Utils.getJavaVersion())); |
| 129 | + connection.setRequestProperty("User-Agent", String.format("MiraiMC/%s (%s; Java %s)", BuildConstants.VERSION, System.getProperty("os.name"), Utils.getJavaVersion())); |
131 | 130 | connection.setConnectTimeout(5000); |
132 | 131 | connection.setReadTimeout(10000); |
133 | 132 |
|
@@ -156,7 +155,7 @@ public static String post(JsonObject json, String url) throws IOException { |
156 | 155 |
|
157 | 156 | connection.setDoInput(true); |
158 | 157 | connection.setRequestMethod("POST"); |
159 | | - connection.setRequestProperty("User-Agent", String.format("MiraiMC/%s (%s; Java %s)", version, System.getProperty("os.name"), Utils.getJavaVersion())); |
| 158 | + connection.setRequestProperty("User-Agent", String.format("MiraiMC/%s (%s; Java %s)", BuildConstants.VERSION, System.getProperty("os.name"), Utils.getJavaVersion())); |
160 | 159 | connection.setRequestProperty("Content-Type", "application/json"); |
161 | 160 | connection.setRequestProperty("Authorization", "Basic YWRtaW46"); |
162 | 161 | connection.setConnectTimeout(5000); |
@@ -241,10 +240,21 @@ public static int getJavaVersion() { |
241 | 240 | } |
242 | 241 |
|
243 | 242 | /** |
244 | | - * 获取插件版本 |
| 243 | + * 获取插件版本名 |
245 | 244 | * @return 版本 |
246 | 245 | */ |
247 | 246 | public static String getVersion() { |
248 | | - return version; |
| 247 | + return BuildConstants.VERSION; |
| 248 | + } |
| 249 | + |
| 250 | + /** |
| 251 | + * 获取插件版本号 |
| 252 | + * |
| 253 | + * @return 版本号 |
| 254 | + */ |
| 255 | + public static int getVersionCode() { |
| 256 | + return Integer.parseInt(BuildConstants.VERSION_CODE); |
249 | 257 | } |
| 258 | + |
| 259 | + |
250 | 260 | } |
0 commit comments