mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 00:07:45 +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
@@ -76,7 +76,7 @@ public class BlockStateLoader
|
||||
byte[] data = IOUtils.toByteArray(reader, StandardCharsets.UTF_8);
|
||||
reader = new InputStreamReader(new ByteArrayInputStream(data), StandardCharsets.UTF_8);
|
||||
|
||||
Marker marker = GSON.fromJson(new String(data), Marker.class); // Read "forge_marker" to determine what to load.
|
||||
Marker marker = GSON.fromJson(new String(data, StandardCharsets.UTF_8), Marker.class); // Read "forge_marker" to determine what to load.
|
||||
|
||||
switch (marker.forge_marker)
|
||||
{
|
||||
|
||||
@@ -22,11 +22,13 @@ package net.minecraftforge.client.model.animation;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -35,9 +37,6 @@ import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Quat4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockPart;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -56,7 +55,6 @@ import net.minecraftforge.common.model.animation.JointClips;
|
||||
import net.minecraftforge.common.util.JsonUtils;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import java.util.Optional;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -557,7 +555,7 @@ public class ModelBlockAnimation
|
||||
{
|
||||
try (IResource resource = manager.getResource(armatureLocation))
|
||||
{
|
||||
ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), ModelBlockAnimation.class);
|
||||
ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), ModelBlockAnimation.class);
|
||||
//String json = mbaGson.toJson(mba);
|
||||
return mba;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ import net.minecraftforge.common.util.JsonUtils;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
@@ -60,6 +59,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -222,7 +222,7 @@ public final class AnimationStateMachine implements IAnimationStateMachine
|
||||
ParameterResolver parameterResolver = new ParameterResolver(customParameters);
|
||||
Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
|
||||
TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
|
||||
AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), AnimationStateMachine.class);
|
||||
AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), AnimationStateMachine.class);
|
||||
clipResolver.asm = asm;
|
||||
parameterResolver.asm = asm;
|
||||
asm.initialize();
|
||||
|
||||
@@ -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