summaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-09 19:54:42 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-09 19:54:42 +0200
commit4cc9804bc6095e7648b21803302443fb598eaf0a (patch)
tree67acfc1a02747b484ca3b24e4d64928fd45a5017 /src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
parented14e3945b6e52a96caeeef830fa91d4a93d629b (diff)
downloadOneConfigLoader-4cc9804bc6095e7648b21803302443fb598eaf0a.tar.gz
OneConfigLoader-4cc9804bc6095e7648b21803302443fb598eaf0a.tar.bz2
OneConfigLoader-4cc9804bc6095e7648b21803302443fb598eaf0a.zip
changes
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
index 3ce3527..d8622e2 100644
--- a/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfigloader/OneConfigLoader.java
@@ -29,33 +29,34 @@ public class OneConfigLoader implements IFMLLoadingPlugin {
if (!oneConfigDir.exists() && !oneConfigDir.mkdir())
throw new IllegalStateException("Could not create OneConfig dir!");
File oneConfigFile = new File(oneConfigDir, "OneConfig (1.8.9).jar");
- if (isInitialized(oneConfigFile)) return;
- JsonElement json = getRequest("https://polyfrost.cc/static/oneconfig-versions.json");
- if (json != null && json.isJsonObject()) {
- JsonObject jsonObject = json.getAsJsonObject();
- if (jsonObject.has("oneconfig") && jsonObject.getAsJsonObject("oneconfig").has("url")
- && jsonObject.getAsJsonObject("oneconfig").has("checksum")) {
- String checksum = jsonObject.getAsJsonObject("oneconfig").get("checksum").getAsString();
- String downloadUrl = jsonObject.getAsJsonObject("oneconfig").get("url").getAsString();
- if (!oneConfigFile.exists() || !checksum.equals(getChecksum(oneConfigFile))) {
- System.out.println("Updating OneConfig...");
- File newOneConfigFile = new File(oneConfigDir, "OneConfig-NEW (1.8.9).jar");
- downloadFile(downloadUrl, newOneConfigFile);
- if (newOneConfigFile.exists() && checksum.equals(getChecksum(newOneConfigFile))) {
- try {
- Files.move(newOneConfigFile.toPath(), oneConfigFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
- System.out.println("Updated OneConfig");
- } catch (IOException ignored) {
+ if (!isInitialized(oneConfigFile)) {
+ JsonElement json = getRequest("https://polyfrost.cc/static/oneconfig-versions.json");
+ if (json != null && json.isJsonObject()) {
+ JsonObject jsonObject = json.getAsJsonObject();
+ if (jsonObject.has("oneconfig") && jsonObject.getAsJsonObject("oneconfig").has("url")
+ && jsonObject.getAsJsonObject("oneconfig").has("checksum")) {
+ String checksum = jsonObject.getAsJsonObject("oneconfig").get("checksum").getAsString();
+ String downloadUrl = jsonObject.getAsJsonObject("oneconfig").get("url").getAsString();
+ if (!oneConfigFile.exists() || !checksum.equals(getChecksum(oneConfigFile))) {
+ System.out.println("Updating OneConfig...");
+ File newOneConfigFile = new File(oneConfigDir, "OneConfig-NEW (1.8.9).jar");
+ downloadFile(downloadUrl, newOneConfigFile);
+ if (newOneConfigFile.exists() && checksum.equals(getChecksum(newOneConfigFile))) {
+ try {
+ Files.move(newOneConfigFile.toPath(), oneConfigFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ System.out.println("Updated OneConfig");
+ } catch (IOException ignored) {
+ }
+ } else {
+ if (newOneConfigFile.exists()) newOneConfigFile.delete();
+ System.out.println("Failed to update OneConfig, trying to continue...");
}
- } else {
- if (newOneConfigFile.exists()) newOneConfigFile.delete();
- System.out.println("Failed to update OneConfig, trying to continue...");
}
}
}
+ if (!oneConfigFile.exists()) throw new IllegalStateException("OneConfig jar doesn't exist");
+ addToClasspath(oneConfigFile);
}
- if (!oneConfigFile.exists()) throw new IllegalStateException("OneConfig jar doesn't exist");
- addToClasspath(oneConfigFile);
try {
OneConfigTransformer = ((IFMLLoadingPlugin) Launch.classLoader.findClass("cc.polyfrost.oneconfig.lwjgl.plugin.LoadingPlugin").newInstance());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
@@ -137,7 +138,6 @@ public class OneConfigLoader implements IFMLLoadingPlugin {
for (byte b : digested) {
sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
}
- System.out.println(sb);
return sb.toString();
} catch (IOException | NoSuchAlgorithmException e) {
e.printStackTrace();
@@ -147,26 +147,26 @@ public class OneConfigLoader implements IFMLLoadingPlugin {
@Override
public String[] getASMTransformerClass() {
- return OneConfigTransformer.getASMTransformerClass();
+ return OneConfigTransformer == null ? null : OneConfigTransformer.getASMTransformerClass();
}
@Override
public String getModContainerClass() {
- return OneConfigTransformer.getModContainerClass();
+ return OneConfigTransformer == null ? null : OneConfigTransformer.getModContainerClass();
}
@Override
public String getSetupClass() {
- return OneConfigTransformer.getSetupClass();
+ return OneConfigTransformer == null ? null : OneConfigTransformer.getSetupClass();
}
@Override
public void injectData(Map<String, Object> data) {
- OneConfigTransformer.injectData(data);
+ if (OneConfigTransformer != null) OneConfigTransformer.injectData(data);
}
@Override
public String getAccessTransformerClass() {
- return OneConfigTransformer.getAccessTransformerClass();
+ return OneConfigTransformer == null ? null : OneConfigTransformer.getAccessTransformerClass();
}
}