mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Clean up Reader/Writer handling to use a specified charset (#4872)
This commit is contained in:
1 parent
d0566ebadc
commit
97a2143fc2
7 files changed
+29
-23
No files matched your search
@@ -24,12 +24,17 @@ import static org.lwjgl.opengl.GL12.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Semaphore;
|
||||
@@ -149,7 +154,7 @@ public class SplashProgress
|
||||
parent.mkdirs();
|
||||
|
||||
config = new Properties();
|
||||
try (FileReader r = new FileReader(configFile))
|
||||
try (Reader r = new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))
|
||||
{
|
||||
config.load(r);
|
||||
}
|
||||
@@ -184,7 +189,7 @@ public class SplashProgress
|
||||
|
||||
File miscPackFile = new File(Minecraft.getMinecraft().mcDataDir, getString("resourcePackPath", "resources"));
|
||||
|
||||
try (FileWriter w = new FileWriter(configFile))
|
||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))
|
||||
{
|
||||
config.store(w, "Splash screen properties");
|
||||
}
|
||||
@@ -707,7 +712,7 @@ public class SplashProgress
|
||||
enabled = false;
|
||||
config.setProperty("enabled", "false");
|
||||
|
||||
try (FileWriter w = new FileWriter(configFile))
|
||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))
|
||||
{
|
||||
config.store(w, "Splash screen properties");
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@
|
||||
package net.minecraftforge.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
@@ -32,10 +35,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.classloading.FMLForgePlugin;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
@@ -657,7 +658,7 @@ public class Loader
|
||||
FMLLog.log.trace("Found a mod state file {}", forcedModFile.getName());
|
||||
try
|
||||
{
|
||||
forcedModListProperties.load(new FileReader(forcedModFile));
|
||||
forcedModListProperties.load(new InputStreamReader(new FileInputStream(forcedModFile), StandardCharsets.UTF_8));
|
||||
FMLLog.log.trace("Loaded states for {} mods from file", forcedModListProperties.size());
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -960,9 +961,9 @@ public class Loader
|
||||
try
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.load(new FileReader(forcedModFile));
|
||||
props.load(new InputStreamReader(new FileInputStream(forcedModFile), StandardCharsets.UTF_8));
|
||||
props.put(modId, "false");
|
||||
props.store(new FileWriter(forcedModFile), null);
|
||||
props.store(new OutputStreamWriter(new FileOutputStream(forcedModFile), StandardCharsets.UTF_8), null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -991,7 +992,7 @@ public class Loader
|
||||
JsonElement injectedDeps;
|
||||
try
|
||||
{
|
||||
injectedDeps = parser.parse(new FileReader(injectedDepFile));
|
||||
injectedDeps = parser.parse(new InputStreamReader(new FileInputStream(injectedDepFile), StandardCharsets.UTF_8));
|
||||
for (JsonElement el : injectedDeps.getAsJsonArray())
|
||||
{
|
||||
JsonObject jo = el.getAsJsonObject();
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.fml.common;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
|
||||
@@ -53,7 +54,7 @@ public class MetadataCollection
|
||||
return new MetadataCollection();
|
||||
}
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(inputStream);
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||
try
|
||||
{
|
||||
MetadataCollection collection;
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ package net.minecraftforge.fml.common.discovery.json;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class JsonAnnotationLoader
|
||||
|
||||
public static Multimap<String, ASMData> loadJson(InputStream data, ModCandidate candidate, ASMDataTable table)
|
||||
{
|
||||
Map<String, ASMInfo> map = GSON.fromJson(new InputStreamReader(data), INFO_TABLE);
|
||||
Map<String, ASMInfo> map = GSON.fromJson(new InputStreamReader(data, StandardCharsets.UTF_8), INFO_TABLE);
|
||||
Multimap<String, ASMData> ret = HashMultimap.create();
|
||||
|
||||
for (Entry<String, ASMInfo> entry : map.entrySet())
|
||||
|
||||
Reference in new issue
Block a user