Skip to content

Commit

Permalink
Fixed problem reading mod version with dict values
Browse files Browse the repository at this point in the history
  • Loading branch information
jnxyp committed Oct 6, 2021
1 parent faa24c7 commit 5af83d6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions config.exe4j
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<exe4j version="8.0" transformSequenceNumber="3">
<directoryPresets config="D:/Game/Starsector" />
<application name="Fossic-CrashReporter" distributionSourceDir="D:/Game/Starsector/Starsector 0.95 RC15" />
<executable name="Fossic-CrashReporter" wrapperType="embed" executableDir="." executableMode="gui" singleInstance="true" dpiAware="true">
<versionInfo include="true" legalCopyright="© 2021 Durian Software Studio " internalName="Demo" companyName="Durian Software Studio" productVersion="1.0.5" />
</executable>
<java mainClass="net.jnxyp.fossic.crashreporter.Main" preferredVM="client" minVersion="1.7">
<searchSequence>
<directory location="./jre" />
<registry />
<envVar name="JAVA_HOME" />
<envVar name="JDK_HOME" />
</searchSequence>
<classPath>
<archive location="D:/My File/Projects/Fossic-CrashReporter/out/artifacts/Fossic_CrashReporter_jar/Fossic-CrashReporter.jar" failOnError="false" />
</classPath>
</java>
</exe4j>
4 changes: 3 additions & 1 deletion src/net/jnxyp/fossic/crashreporter/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public final class Config {
public static final String PROGRAM_NAME = "远行星号 报错信息收集工具";
public static final String PROGRAM_VERSION = "1.0.4";
public static final String PROGRAM_VERSION = "1.0.5";

public static final Pattern JSON_COMMENTS_PATTERN = Pattern.compile("#.*$", Pattern.MULTILINE);

Expand All @@ -35,6 +35,8 @@ public final class Config {
public static final Charset MOD_INFO_CHARSET = StandardCharsets.UTF_8;
public static final Charset ENABLED_MOD_LIST_CHARSET = StandardCharsets.UTF_8;

// public static final int UI_FONT_SIZE = 18;

private Config() {
}

Expand Down
1 change: 0 additions & 1 deletion src/net/jnxyp/fossic/crashreporter/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package net.jnxyp.fossic.crashreporter;

import java.nio.file.Paths;

public class Main {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean accept(File pathname) {
enabledModIds.add(array.getString(i));
}
} catch (IOException e) {
throw new InfoCollectionPartialFailureException(this, String.format("在读取已启用Mod列表文件 %s 时发生错误", enabledModListFile.toPath().toString()), e);
throw new InfoCollectionPartialFailureException(this, String.format("在读取已启用Mod列表文件 %s 时发生错误", enabledModListFile.toPath()), e);
}

for (ModInfo info : mods) {
Expand Down Expand Up @@ -95,10 +95,18 @@ public ModInfo(String id, String name, String version, String gameVersion, boole
public static ModInfo fromModInfoFile(File modInfoFile) throws IOException {
String modInfoString = Util.readFile(modInfoFile, Config.MOD_INFO_CHARSET);
JSONObject dict = Util.parseJson(modInfoString);
Object versionObj = dict.get("version");
String version = "";
if (versionObj instanceof String) {
version = (String) versionObj;
} else if (versionObj instanceof JSONObject) {
JSONObject v = (JSONObject) versionObj;
version = String.format("%d.%d.%d", v.getInt("major"), v.getInt("minor"), v.getInt("patch"));
}
return new ModInfo(
dict.getString("id"),
dict.getString("name"),
dict.getString("version"),
version,
dict.getString("gameVersion"),
false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ public String getName() {
public String getRawInfo() throws InfoCollectionPartialFailureException {
String javaVersion = System.getProperty("java.version");
String javaPath = System.getProperty("java.home");
StringBuilder builder = new StringBuilder();

builder.append(getWarning(javaVersion, javaPath))
.append(String.format("Java版本:\t`%s`\n\n", javaVersion))
.append(String.format("Java路径:\t%s\n\n", javaPath))
.append(String.format("虚拟机参数:\t%s", getVmparams()));
return builder.toString();
return getWarning(javaVersion, javaPath) +
String.format("Java版本:\t`%s`\n\n", javaVersion) +
String.format("Java路径:\t%s\n\n", javaPath) +
String.format("虚拟机参数:\t%s", getVmparams());
}

protected String getVmparams() throws InfoCollectionPartialFailureException {
Expand Down

0 comments on commit 5af83d6

Please sign in to comment.