Prevent execution of commands with missing parameters

This commit is contained in:
Zixxl 2015-07-01 12:04:55 +02:00
parent 1e879fc711
commit 0929891f38
2 changed files with 20 additions and 0 deletions

View file

@ -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<IGrinderEntry> result = new LinkedList<IGrinderEntry>();

View file

@ -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<IInscriberRecipe> result = new LinkedList<IInscriberRecipe>();