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.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -47,7 +48,12 @@ public class BlockMatcher {
|
||||
}
|
||||
|
||||
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;
|
||||
try {
|
||||
|
||||
@@ -8,14 +8,15 @@ import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import mods.betterfoliage.loader.DeobfHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
@@ -91,21 +92,20 @@ public class Utils {
|
||||
/** Copy a text file from a resource to the filesystem
|
||||
* @param resourceLocation resource location of text file
|
||||
* @param target target file
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copyFromTextResource(ResourceLocation resourceLocation, File target) {
|
||||
try {
|
||||
IResource defaults = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(defaults.getInputStream(), Charsets.UTF_8));
|
||||
FileWriter writer = new FileWriter(target);
|
||||
|
||||
String line = reader.readLine();
|
||||
while(line != null) {
|
||||
writer.write(line + System.lineSeparator());
|
||||
line = reader.readLine();
|
||||
}
|
||||
reader.close();
|
||||
writer.close();
|
||||
} catch(IOException e) {
|
||||
public static void copyFromTextResource(ResourceLocation resourceLocation, File target) throws IOException {
|
||||
IResource defaults = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(defaults.getInputStream(), Charsets.UTF_8));
|
||||
FileWriter writer = new FileWriter(target);
|
||||
|
||||
String line = reader.readLine();
|
||||
while(line != null) {
|
||||
writer.write(line + System.lineSeparator());
|
||||
line = reader.readLine();
|
||||
}
|
||||
|
||||
reader.close();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user