log stacktrace when default config fails to copy
This commit is contained in:
@@ -3,6 +3,7 @@ package mods.betterfoliage.client;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -47,7 +48,12 @@ public class BlockMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load(File file, ResourceLocation defaults) {
|
public void load(File file, ResourceLocation defaults) {
|
||||||
if (!file.exists()) Utils.copyFromTextResource(defaults, file);
|
if (!file.exists()) try {
|
||||||
|
Utils.copyFromTextResource(defaults, file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
BetterFoliage.log.error(String.format("Error copying default resource: %s", defaults.toString()));
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,14 +8,15 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
|
|
||||||
import mods.betterfoliage.loader.DeobfHelper;
|
import mods.betterfoliage.loader.DeobfHelper;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.IResource;
|
import net.minecraft.client.resources.IResource;
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
|
|
||||||
@@ -91,9 +92,9 @@ public class Utils {
|
|||||||
/** Copy a text file from a resource to the filesystem
|
/** Copy a text file from a resource to the filesystem
|
||||||
* @param resourceLocation resource location of text file
|
* @param resourceLocation resource location of text file
|
||||||
* @param target target file
|
* @param target target file
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void copyFromTextResource(ResourceLocation resourceLocation, File target) {
|
public static void copyFromTextResource(ResourceLocation resourceLocation, File target) throws IOException {
|
||||||
try {
|
|
||||||
IResource defaults = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
IResource defaults = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(defaults.getInputStream(), Charsets.UTF_8));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(defaults.getInputStream(), Charsets.UTF_8));
|
||||||
FileWriter writer = new FileWriter(target);
|
FileWriter writer = new FileWriter(target);
|
||||||
@@ -103,9 +104,8 @@ public class Utils {
|
|||||||
writer.write(line + System.lineSeparator());
|
writer.write(line + System.lineSeparator());
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch(IOException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user