Catch Throwables when dumping recipes.

This commit is contained in:
Alex Bramley committed 2016-01-24 20:45:37 +00:00
1 parent 1dc4380a41
commit c49c3ce4da
1 file changed
+16 -1
@@ -36,6 +36,8 @@ import minetweaker.api.player.IPlayer;
import minetweaker.api.recipes.ICraftingRecipe;
import minetweaker.api.recipes.IFurnaceManager;
import minetweaker.api.recipes.IRecipeManager;
import minetweaker.api.recipes.ShapedRecipe;
import minetweaker.api.recipes.ShapelessRecipe;
import minetweaker.api.server.ICommandFunction;
import minetweaker.api.server.ICommandValidator;
import minetweaker.api.server.IServer;
@@ -204,7 +206,20 @@ public class MineTweakerImplementationAPI {
MineTweakerAPI.logCommand("Recipes:");
for (ICraftingRecipe recipe : MineTweakerAPI.recipes.getAll()) {
MineTweakerAPI.logCommand(recipe.toCommandString());
try {
MineTweakerAPI.logCommand(recipe.toCommandString());
} catch (Throwable ex) {
// Some recipes can result in an NPE :-(
if (recipe instanceof ShapedRecipe) {
ShapedRecipe shaped = (ShapedRecipe) recipe;
IItemStack out = shaped.getOutput();
MineTweakerAPI.logError("Could not dump recipe for " + out, ex);
} else if (recipe instanceof ShapelessRecipe) {
ShapelessRecipe shapeless = (ShapelessRecipe) recipe;
IItemStack out = shapeless.getOutput();
MineTweakerAPI.logError("Could not dump recipe for " + out, ex);
}
}
}
if (player != null) {