diff --git a/src/main/java/com/skcraft/alicefixes/AliceTransformer.java b/src/main/java/com/skcraft/alicefixes/AliceTransformer.java index c74f400..196d9d2 100644 --- a/src/main/java/com/skcraft/alicefixes/AliceTransformer.java +++ b/src/main/java/com/skcraft/alicefixes/AliceTransformer.java @@ -12,6 +12,7 @@ import org.apache.commons.io.FileUtils; import java.io.File; +import java.io.IOException; import java.util.*; import java.util.logging.Level; @@ -43,8 +44,9 @@ public AliceTransformer() { } } } - } catch(Throwable t) { - t.printStackTrace(); + } catch(IOException e) { + FMLLog.log("AliceFixes", Level.WARNING, "%s", "Error while loading the patches file: " + e); + e.printStackTrace(); } } diff --git a/src/main/java/com/skcraft/alicefixes/Blacklist.java b/src/main/java/com/skcraft/alicefixes/Blacklist.java index d37498d..1cb28a1 100644 --- a/src/main/java/com/skcraft/alicefixes/Blacklist.java +++ b/src/main/java/com/skcraft/alicefixes/Blacklist.java @@ -2,14 +2,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import cpw.mods.fml.common.FMLLog; import org.apache.commons.io.FileUtils; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; +import java.io.*; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; public class Blacklist { @@ -28,8 +27,12 @@ public static void load(File configDir) { } br.close(); } - catch(Throwable t) { - t.printStackTrace(); + catch(FileNotFoundException e) { + FMLLog.log("AliceFixes", Level.WARNING, "%s", "Failed to find blacklists file!"); + } + catch(IOException e) { + FMLLog.log("AliceFixes", Level.WARNING, "%s", "Error while loading the blacklists file: " + e); + e.printStackTrace(); } } @@ -38,8 +41,9 @@ public static void save() { try { lists.setBlacklists(blacklists); FileUtils.writeStringToFile(config, gson.toJson(lists)); - } catch(Throwable t) { - t.printStackTrace(); + } catch(IOException e) { + FMLLog.log("AliceFixes", Level.WARNING, "%s", "Error saving the blacklists file: " + e); + e.printStackTrace(); } } diff --git a/src/main/java/com/skcraft/alicefixes/util/ASMHelper.java b/src/main/java/com/skcraft/alicefixes/util/ASMHelper.java index a528894..f1a5b25 100644 --- a/src/main/java/com/skcraft/alicefixes/util/ASMHelper.java +++ b/src/main/java/com/skcraft/alicefixes/util/ASMHelper.java @@ -2,6 +2,7 @@ import com.skcraft.alicefixes.AliceTransformer; import com.skcraft.alicefixes.Blacklist; +import cpw.mods.fml.common.FMLLog; import net.minecraft.entity.EntityLivingBase; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; @@ -12,6 +13,7 @@ import org.objectweb.asm.MethodVisitor; import java.lang.reflect.Method; +import java.util.logging.Level; import static org.objectweb.asm.Opcodes.*; @@ -89,8 +91,9 @@ private static boolean fireEvent(EntityLivingBase player, int x, int y, int z) { } breakEvt.setCancelled(true); } - } catch(Exception e) { - e.printStackTrace(); + } catch(Throwable t) { + FMLLog.log("AliceFixes", Level.SEVERE, "%s", "Error while firing Bukkit event: " + t); + t.printStackTrace(); } return true; }