#714: Added getRecipe() method to retrieve a Recipe by it's NamespacedKey

This commit is contained in:
jameslfc19 2020-07-22 18:14:58 +10:00 committed by md_5
parent 6b95d595cf
commit 8b831a9652
No known key found for this signature in database
GPG key ID: E8E901AC7C617C11

View file

@ -1208,6 +1208,13 @@ public final class CraftServer implements Server {
return results;
}
@Override
public Recipe getRecipe(NamespacedKey recipeKey) {
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
return getServer().getCraftingManager().a(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null);
}
@Override
public Iterator<Recipe> recipeIterator() {
return new RecipeIterator();