From f7662d5c9249b90936349d3da43bb0bab089e59e Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 17 Aug 2018 20:40:48 +1000 Subject: SPIGOT-4283: Allow setting recipe groups --- .../java/org/bukkit/inventory/FurnaceRecipe.java | 23 +++++++++++++++++++++ .../java/org/bukkit/inventory/ShapedRecipe.java | 23 +++++++++++++++++++++ .../java/org/bukkit/inventory/ShapelessRecipe.java | 24 ++++++++++++++++++++++ 3 files changed, 70 insertions(+) (limited to 'src') diff --git a/src/main/java/org/bukkit/inventory/FurnaceRecipe.java b/src/main/java/org/bukkit/inventory/FurnaceRecipe.java index 93696606..75ad4be8 100644 --- a/src/main/java/org/bukkit/inventory/FurnaceRecipe.java +++ b/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/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java index d9af7155..398ac245 100644 --- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/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/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java index ca5c09b8..0c340c84 100644 --- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +++ b/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; + } } -- cgit v1.2.3