Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
更新下载链接
Browse files Browse the repository at this point in the history
  • Loading branch information
wohaopa committed May 8, 2023
1 parent 371b72e commit d3d6e27
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -36,17 +37,17 @@ public class Main {
libDir = new File(userDir, "lib");
File configFile = new File(userDir + "/config.properties");
if (!configFile.exists()) {
config.setProperty("download-url", "http://127.0.0.1/ZeroPointLaunch/Library/");
config.setProperty("download-url", "http://127.0.0.1/ZeroPointLaunch/");
config.setProperty("check-libraries", "true");
config.setProperty("check-update", "true");
try {
config.store(new FileOutputStream(configFile), null);
config.store(Files.newOutputStream(configFile.toPath()), null);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
try {
config.load(new FileInputStream(configFile));
config.load(Files.newInputStream(configFile.toPath()));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -55,7 +56,7 @@ public class Main {

public static void main(String[] args) {

zpLaunch=config.getProperty("download-url","http://127.0.0.1/ZeroPointLaunch/Library/");
zpLaunch = config.getProperty("download-url", "http://127.0.0.1/ZeroPointLaunch/") + "Library/";

if (config.getProperty("check-update", "false").equals("true")) {
File newCore = new File(libDir, "ZeroPointLaunch-Core-new.jar");
Expand Down Expand Up @@ -90,7 +91,7 @@ public static void main(String[] args) {
method.setAccessible(true);
method.invoke(null, (Object) args);
} catch (ClassNotFoundException e) {
System.out.println("无法加载核心类:com.github.wohaopa.zeropointlanuch.main.Main,可能缺少ZeroPointLaunch-Core.jar");
System.out.println("无法加载核心类:com.github.wohaopa.zeropointlanuch.main.Main,请重新启动!或者可能缺少ZeroPointLaunch-Core.jar");
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
System.out.println("无法加载main方法,请重新下载!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class Core {

public static final String launcherVersion = "内部测试版本";
public static final String launcherVersion = "0.0.1";
public static boolean dirToolsInit = false;

public static void initDirTools(File rootDir) {
Expand Down
31 changes: 25 additions & 6 deletions src/main/java/com/github/wohaopa/zeropointlanuch/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,26 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.concurrent.ExecutionException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cn.hutool.json.JSONObject;

import com.github.wohaopa.zeropointlanuch.api.Core;
import com.github.wohaopa.zeropointlanuch.core.DirTools;
import com.github.wohaopa.zeropointlanuch.core.Log;
import com.github.wohaopa.zeropointlanuch.core.utils.DownloadUtil;
import com.github.wohaopa.zeropointlanuch.core.utils.JsonUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Main {

private static final String DOWNLOAD_VERSION_URL = "http://127.0.0.1//ZeroPointLaunch//";
public static Map<String, ICommand> commands = new HashMap<>();
public static File workDir;

Expand All @@ -64,15 +66,18 @@ public static void main(String[] args) {

private static void init() {

// String rootDirStr = System.getProperty("zpl.rootdir");
String rootDirStr = "D:\\DevProject\\JavaProject\\ZeroPointLaunch\\Wrapper\\build\\libs\\.GTNH";
String rootDirStr = System.getProperty("zpl.rootdir");
// String rootDirStr =
// "D:\\DevProject\\JavaProject\\ZeroPointLaunch\\Wrapper\\build\\libs\\.GTNH";

if (rootDirStr == null) {
rootDirStr = System.getProperty("user.dir") + "/.GTNH";
}
workDir = new File(rootDirStr);
Core.initDirTools(workDir); // 目录工具初始化

if (!Core.launcherVersion.equals("内部测试版本")) {
if (!System.getProperty("zpl.skipUpdate")
.equals("true") && !Core.launcherVersion.equals("内部测试版本")) {
check_update();
}

Expand All @@ -81,6 +86,20 @@ private static void init() {
}

private static void check_update() {

File configProperties = new File(workDir.getParentFile(), "config.properties");
if (!configProperties.exists()) return;
Properties properties = new Properties();

try {
properties.load(Files.newInputStream(configProperties.toPath()));
} catch (IOException e) {
Log.info("无法加载config.properties,跳过更新检查。");
return;
}

String DOWNLOAD_VERSION_URL = properties.getProperty("download-url");

Logger updateLog = LogManager.getLogger("Update");
Runnable runnable = () -> {
File versionFile = new File(DirTools.tmpDir, "version.json");
Expand Down

0 comments on commit d3d6e27

Please sign in to comment.