diff --git a/src/com/dre/brewery/api/BreweryApi.java b/src/com/dre/brewery/api/BreweryApi.java index b6c8494..6b0c3a4 100644 --- a/src/com/dre/brewery/api/BreweryApi.java +++ b/src/com/dre/brewery/api/BreweryApi.java @@ -253,6 +253,16 @@ public class BreweryApi { return BRecipe.get(name); } + /** + * Get a BRecipe by _one of_ its names. + *
May be any of the quality names, or the optional config id. + *
Returns null if recipe with that name does not exist + */ + @Nullable + public static BRecipe getRecipeMatch(String name) { + return BRecipe.getMatching(name); + } + /** * Add a New Recipe. *
Brews can be made out of this Recipe.
diff --git a/src/com/dre/brewery/listeners/CommandListener.java b/src/com/dre/brewery/listeners/CommandListener.java
index 59f5c66..b68a183 100644
--- a/src/com/dre/brewery/listeners/CommandListener.java
+++ b/src/com/dre/brewery/listeners/CommandListener.java
@@ -492,7 +492,7 @@ public class CommandListener implements CommandExecutor {
BRecipe nonDistill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), false);
P.p.log("&lWould prefer Recipe: " + (nonDistill == null ? "none" : nonDistill.getRecipeName()) + " and Distill-Recipe: " + (distill == null ? "none" : distill.getRecipeName()));
} else {
- BRecipe recipe = BRecipe.get(recipeName);
+ BRecipe recipe = BRecipe.getMatching(recipeName);
if (recipe == null) {
P.p.msg(player, "Could not find Recipe " + recipeName);
return;
@@ -665,19 +665,14 @@ public class CommandListener implements CommandExecutor {
} else {
name = args[1];
}
+ name = name.replaceAll("\"", "");
if (player.getInventory().firstEmpty() == -1) {
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "1"));
return;
}
- BRecipe recipe = null;
- for (BRecipe r : BRecipe.getAllRecipes()) {
- if (r.hasName(name)) {
- recipe = r;
- break;
- }
- }
+ BRecipe recipe = BRecipe.getMatching(name);
if (recipe != null) {
ItemStack item = recipe.create(quality);
if (item != null) {
diff --git a/src/com/dre/brewery/recipe/BRecipe.java b/src/com/dre/brewery/recipe/BRecipe.java
index d0e151e..2259775 100644
--- a/src/com/dre/brewery/recipe/BRecipe.java
+++ b/src/com/dre/brewery/recipe/BRecipe.java
@@ -32,6 +32,7 @@ public class BRecipe {
// info
private String[] name;
private boolean saveInData; // If this recipe should be saved in data and loaded again when the server restarts. Applicable to non-config recipes
+ private String optionalID; // ID that might be given by the config
// brewing
private List