From 9d24d601e2461a32cf1ae9c01949b40a6af0fcea Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 17 Aug 2018 20:40:48 +1000 Subject: [PATCH] SPIGOT-4283: Allow setting recipe groups By: md_5 --- .../org/bukkit/inventory/FurnaceRecipe.java | 23 ++++++++++++++++++ .../org/bukkit/inventory/ShapedRecipe.java | 23 ++++++++++++++++++ .../org/bukkit/inventory/ShapelessRecipe.java | 24 +++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java index 9369660658..75ad4be86d 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java @@ -15,6 +15,7 @@ public class FurnaceRecipe implements Recipe, Keyed { private ItemStack ingredient; private float experience; private int cookingTime; + private String group = ""; @Deprecated public FurnaceRecipe(ItemStack result, Material source) { @@ -152,4 +153,26 @@ public class FurnaceRecipe implements Recipe, Keyed { public NamespacedKey getKey() { return key; } + + /** + * Get the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @return recipe group. An empty string denotes no group. May not be null. + */ + public String getGroup() { + return group; + } + + /** + * Set the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @param group recipe group. An empty string denotes no group. May not be + * null. + */ + public void setGroup(String group) { + Preconditions.checkArgument(group != null, "group"); + this.group = group; + } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java index d9af715502..398ac2454d 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -19,6 +19,7 @@ public class ShapedRecipe implements Recipe, Keyed { private final ItemStack output; private String[] rows; private Map ingredients = new HashMap(); + private String group = ""; @Deprecated public ShapedRecipe(ItemStack result) { @@ -168,4 +169,26 @@ public class ShapedRecipe implements Recipe, Keyed { public NamespacedKey getKey() { return key; } + + /** + * Get the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @return recipe group. An empty string denotes no group. May not be null. + */ + public String getGroup() { + return group; + } + + /** + * Set the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @param group recipe group. An empty string denotes no group. May not be + * null. + */ + public void setGroup(String group) { + Preconditions.checkArgument(group != null, "group"); + this.group = group; + } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java index ca5c09b868..0c340c84ea 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java @@ -1,5 +1,6 @@ package org.bukkit.inventory; +import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -19,6 +20,7 @@ public class ShapelessRecipe implements Recipe, Keyed { private final NamespacedKey key; private final ItemStack output; private final List ingredients = new ArrayList(); + private String group = ""; @Deprecated public ShapelessRecipe(ItemStack result) { @@ -239,4 +241,26 @@ public class ShapelessRecipe implements Recipe, Keyed { public NamespacedKey getKey() { return key; } + + /** + * Get the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @return recipe group. An empty string denotes no group. May not be null. + */ + public String getGroup() { + return group; + } + + /** + * Set the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @param group recipe group. An empty string denotes no group. May not be + * null. + */ + public void setGroup(String group) { + Preconditions.checkArgument(group != null, "group"); + this.group = group; + } }