From 0929891f38b73e5e25bb2a96b5ade70b20edc430 Mon Sep 17 00:00:00 2001 From: Zixxl Date: Wed, 1 Jul 2015 12:04:55 +0200 Subject: [PATCH] Prevent execution of commands with missing parameters --- .../java/modtweaker2/mods/appeng/handlers/Grind.java | 10 ++++++++++ .../modtweaker2/mods/appeng/handlers/Inscriber.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java b/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java index cb03265..90f18b7 100644 --- a/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java +++ b/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java @@ -31,6 +31,11 @@ public class Grind { @ZenMethod public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) { + if(input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Grind.name)); + return; + } + // Create recipe IGrinderEntry recipe; @@ -75,6 +80,11 @@ public class Grind { @ZenMethod public static void removeRecipe(IIngredient output) { + if(output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Grind.name)); + return; + } + // Get list of existing recipes, matching with parameter LinkedList result = new LinkedList(); diff --git a/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java b/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java index e871951..9eaf18f 100644 --- a/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java +++ b/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java @@ -33,6 +33,11 @@ public class Inscriber { @ZenMethod public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, String type) { + if(imprintable == null || out == null || (!type.equals("Press") || !type.equals("Inscribe"))) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name)); + return; + } + // Create recipe IInscriberRecipe recipe = new InscriberRecipe(ArrayUtils.toArrayList(toStacks(imprintable)), toStack(out), toStack(plateA), toStack(plateB), InscriberProcessType.valueOf(type)); @@ -95,6 +100,11 @@ public class Inscriber { @ZenMethod public static void removeRecipe(IIngredient output) { + if(output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name)); + return; + } + // Get list of existing recipes, matching with parameter LinkedList result = new LinkedList();