mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-30 10:51:20 +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
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOItems</artifactId>
|
||||
<version>5.5.3-SNAPSHOT</version>
|
||||
<version>5.5.3-SNAPSHOT</version>
|
||||
<name>MMOItems</name>
|
||||
<description>A great item solution for your RPG server.</description>
|
||||
|
||||
|
@ -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;
|
||||
|
||||
@ -26,17 +25,25 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
||||
this.output = output.toItem();
|
||||
if (output.hasTag("MMOITEMS_CRAFTED_AMOUNT"))
|
||||
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 {
|
||||
} 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");
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,11 +71,11 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmpty() {
|
||||
return ingredients.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public boolean isShapeless() {
|
||||
return shapeless;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user