This commit is contained in:
FOlkvangrField 2025-08-20 21:46:59 +08:00
parent a0451b46a5
commit b4b471e5c3
4 changed files with 112 additions and 114 deletions

View File

@ -1,9 +1,8 @@
package com.hbm.config;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -148,7 +147,7 @@ public class CustomMachineConfigJSON {
public static void readConfig(File config) {
try {
JsonObject json = gson.fromJson(new FileReader(config), JsonObject.class);
JsonObject json = gson.fromJson(new InputStreamReader(Files.newInputStream(config.toPath()), StandardCharsets.UTF_8), JsonObject.class);
JsonArray machines = json.get("machines").getAsJsonArray();
for(int i = 0; i < machines.size(); i++) {

View File

@ -1,9 +1,8 @@
package com.hbm.inventory.fluid;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -797,7 +796,7 @@ public class Fluids {
private static void readCustomFluids(File file) {
try {
JsonObject json = gson.fromJson(new FileReader(file), JsonObject.class);
JsonObject json = gson.fromJson(new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8), JsonObject.class);
for(Entry<String, JsonElement> entry : json.entrySet()) {

View File

@ -52,13 +52,13 @@ public class GuiQMAW extends GuiScreen {
protected void parseQMAW(QuickManualAndWiki qmaw) {
LanguageManager lang = Minecraft.getMinecraft().getLanguageManager();
this.title = qmaw.title.get(lang.getCurrentLanguage());
this.title = qmaw.title.get(lang.getCurrentLanguage().getLanguageCode());
if(title == null) this.title = qmaw.title.get(EN_US);
if(title == null) this.title = "Missing Localization!";
this.icon = qmaw.icon;
String toParse = qmaw.contents.get(lang.getCurrentLanguage());
String toParse = qmaw.contents.get(lang.getCurrentLanguage().getLanguageCode());
if(toParse == null) toParse = qmaw.contents.get(EN_US);
if(toParse == null) toParse = "Missing Localization!";
toParse = "" + toParse; // strings are reference types, no?

View File

@ -1,9 +1,8 @@
package com.hbm.qmaw;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@ -131,7 +130,7 @@ public class QMAWLoader implements IResourceManagerReloadListener {
String name = entry.getName();
if(name.startsWith("assets/hbm/manual/") && name.endsWith(".json")) {
InputStream fileStream = zip.getInputStream(entry);
InputStreamReader reader = new InputStreamReader(fileStream);
InputStreamReader reader = new InputStreamReader(fileStream, StandardCharsets.UTF_8);
try {
JsonObject obj = (JsonObject) parser.parse(reader);
String manName = name.replace("assets/hbm/manual/", "");
@ -167,7 +166,8 @@ public class QMAWLoader implements IResourceManagerReloadListener {
String name = file.getName();
if(file.isFile() && name.endsWith(".json")) {
try {
FileReader reader = new FileReader(file);
//FileReader reader = new FileReader(file);
InputStreamReader reader = new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);
JsonObject obj = (JsonObject) parser.parse(reader);
registerJson(name, obj);
logFoundManual(name);