mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
Invalid recipes no longer throw an exception and are just ignored
(meaning they won't affect loading/appear in game. They will still error in the log)
This commit is contained in:
parent
a8cf3f5190
commit
49f61f69b5
@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -28,15 +27,23 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
||||
this.output.setAmount(output.getInteger("MMOITEMS_CRAFTED_AMOUNT"));
|
||||
|
||||
if (shapeless) {
|
||||
Validate.isTrue(recipe.size() >= 9, "Recipe does not contain 9 ingredients");
|
||||
if (recipe.size() != 9) {
|
||||
MMOItems.plugin.getLogger().warning("Invalid shapeless recipe for '" + output.getType().getId() + "."
|
||||
+ output.getString("MMOITEMS_ITEM_ID") + "'");
|
||||
recipe = Arrays.asList("AIR", "AIR", "AIR", "AIR", "AIR", "AIR", "AIR", "AIR", "AIR");
|
||||
}
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack stack = MMOItems.plugin.parseStack(recipe.get(i));
|
||||
if (stack == null || stack.getType() == Material.AIR)
|
||||
continue;
|
||||
ingredients.put(i, WorkbenchIngredient.getAutomatically(stack));
|
||||
}
|
||||
} else {
|
||||
if (recipe.size() != 3) {
|
||||
MMOItems.plugin.getLogger().warning("Invalid shaped recipe for '" + output.getType().getId() + "."
|
||||
+ output.getString("MMOITEMS_ITEM_ID") + "'");
|
||||
recipe = Arrays.asList("AIR AIR AIR", "AIR AIR AIR", "AIR AIR AIR");
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
List<String> line = Arrays.asList(recipe.get(i / 3).split("\\ "));
|
||||
while (line.size() < 3)
|
||||
@ -45,7 +52,8 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
||||
ItemStack stack = MMOItems.plugin.parseStack(line.get(i % 3));
|
||||
if (stack == null || stack.getType() == Material.AIR)
|
||||
ingredients.put(i, new AirIngredient());
|
||||
else ingredients.put(i, WorkbenchIngredient.getAutomatically(stack));
|
||||
else
|
||||
ingredients.put(i, WorkbenchIngredient.getAutomatically(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user