mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-11 04:46:18 -04:00
Fix messy name of installed modpack game
This commit is contained in:
parent
1c346c97a8
commit
44ac3bc900
@ -19,6 +19,10 @@ package org.jackhuang.hmcl.setting;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
|
import org.jackhuang.hmcl.util.InvocationDispatcher;
|
||||||
|
import org.jackhuang.hmcl.util.Lang;
|
||||||
|
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||||
|
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -27,10 +31,6 @@ import java.nio.file.Paths;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.util.InvocationDispatcher;
|
|
||||||
import org.jackhuang.hmcl.util.Lang;
|
|
||||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static org.jackhuang.hmcl.util.Logging.LOG;
|
import static org.jackhuang.hmcl.util.Logging.LOG;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public final class ConfigHolder {
|
|||||||
private static Config loadConfig() throws IOException {
|
private static Config loadConfig() throws IOException {
|
||||||
if (Files.exists(configLocation)) {
|
if (Files.exists(configLocation)) {
|
||||||
try {
|
try {
|
||||||
String content = new String(Files.readAllBytes(configLocation), UTF_8);
|
String content = FileUtils.readText(configLocation);
|
||||||
Config deserialized = Config.fromJson(content);
|
Config deserialized = Config.fromJson(content);
|
||||||
if (deserialized == null) {
|
if (deserialized == null) {
|
||||||
LOG.info("Config is empty");
|
LOG.info("Config is empty");
|
||||||
|
@ -29,6 +29,7 @@ import org.jackhuang.hmcl.ui.Controllers;
|
|||||||
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
||||||
import org.jackhuang.hmcl.ui.construct.MessageBox;
|
import org.jackhuang.hmcl.ui.construct.MessageBox;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
|
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||||
import org.jackhuang.hmcl.util.io.JarUtils;
|
import org.jackhuang.hmcl.util.io.JarUtils;
|
||||||
import org.jackhuang.hmcl.util.platform.JavaVersion;
|
import org.jackhuang.hmcl.util.platform.JavaVersion;
|
||||||
|
|
||||||
@ -45,7 +46,6 @@ import java.util.logging.Level;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.checkFxUserThread;
|
import static org.jackhuang.hmcl.ui.FXUtils.checkFxUserThread;
|
||||||
import static org.jackhuang.hmcl.util.Lang.thread;
|
import static org.jackhuang.hmcl.util.Lang.thread;
|
||||||
import static org.jackhuang.hmcl.util.Logging.LOG;
|
import static org.jackhuang.hmcl.util.Logging.LOG;
|
||||||
@ -242,7 +242,7 @@ public final class UpdateHandler {
|
|||||||
Path hmclVersionJson = Metadata.HMCL_DIRECTORY.resolve("hmclver.json");
|
Path hmclVersionJson = Metadata.HMCL_DIRECTORY.resolve("hmclver.json");
|
||||||
if (Files.isRegularFile(hmclVersionJson)) {
|
if (Files.isRegularFile(hmclVersionJson)) {
|
||||||
try {
|
try {
|
||||||
Map<?, ?> content = new Gson().fromJson(new String(Files.readAllBytes(hmclVersionJson), UTF_8), Map.class);
|
Map<?, ?> content = new Gson().fromJson(FileUtils.readText(hmclVersionJson), Map.class);
|
||||||
Object ver = content.get("ver");
|
Object ver = content.get("ver");
|
||||||
if (ver instanceof String && ((String) ver).startsWith("3.")) {
|
if (ver instanceof String && ((String) ver).startsWith("3.")) {
|
||||||
Files.delete(hmclVersionJson);
|
Files.delete(hmclVersionJson);
|
||||||
|
@ -20,7 +20,6 @@ package org.jackhuang.hmcl.util.io;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.spi.FileSystemProvider;
|
import java.nio.file.spi.FileSystemProvider;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -88,7 +87,7 @@ public final class CompressingUtils {
|
|||||||
*/
|
*/
|
||||||
public static String readTextZipEntry(File zipFile, String name) throws IOException {
|
public static String readTextZipEntry(File zipFile, String name) throws IOException {
|
||||||
try (FileSystem fs = createReadOnlyZipFileSystem(zipFile.toPath())) {
|
try (FileSystem fs = createReadOnlyZipFileSystem(zipFile.toPath())) {
|
||||||
return new String(Files.readAllBytes(fs.getPath(name)));
|
return FileUtils.readText(fs.getPath(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user