geforkt von Mirrors/Paper
Avoid usages of RecipeChoice#getItemStack() (#8453)
Replaces some internal usages of this method with RecipeChoice#test(ItemStack) and deprecates every other method still utilizing this legacy method.
Dieser Commit ist enthalten in:
Ursprung
254a07415d
Commit
11281d0789
@ -3,7 +3,10 @@ From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 28 Jan 2014 19:13:57 -0500
|
||||
Subject: [PATCH] Add ItemStack Recipe API helper methods
|
||||
|
||||
Allows using ExactChoice Recipes with easier methodss
|
||||
Allows using ExactChoice Recipes with easier methods
|
||||
|
||||
Redirects some of upstream's APIs to these new methods to avoid
|
||||
usage of magic values and the deprecated RecipeChoice#getItemStack
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
@ -55,8 +58,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public ShapelessRecipe removeIngredient(int count, @NotNull ItemStack item) {
|
||||
+ Iterator<RecipeChoice> iterator = ingredients.iterator();
|
||||
+ while (count > 0 && iterator.hasNext()) {
|
||||
+ ItemStack stack = iterator.next().getItemStack();
|
||||
+ if (stack.equals(item)) {
|
||||
+ RecipeChoice choice = iterator.next();
|
||||
+ if (choice.test(item)) {
|
||||
+ iterator.remove();
|
||||
+ count--;
|
||||
+ }
|
||||
@ -68,3 +71,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
/**
|
||||
* Removes an ingredient from the list.
|
||||
*
|
||||
@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
*/
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(@NotNull Material ingredient) {
|
||||
- return removeIngredient(ingredient, 0);
|
||||
+ return removeIngredient(new ItemStack(ingredient)); // Paper - avoid using deprecated methods (magic values; RecipeChoice#getItemStack)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
*/
|
||||
@NotNull
|
||||
public ShapelessRecipe removeIngredient(int count, @NotNull Material ingredient) {
|
||||
- return removeIngredient(count, ingredient, 0);
|
||||
+ return removeIngredient(count, new ItemStack(ingredient)); // Paper - avoid using deprecated methods (magic values; RecipeChoice#getItemStack)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -524,6 +524,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public MaterialData getTypeAndData(int x, int y, int z);
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/inventory/CookingRecipe.java b/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/CookingRecipe.java
|
||||
@@ -0,0 +0,0 @@ public abstract class CookingRecipe<T extends CookingRecipe> implements Recipe,
|
||||
* Get the input material.
|
||||
*
|
||||
* @return The input material.
|
||||
+ * @deprecated Use {@link #getInputChoice()} instead for more complete data.
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@NotNull
|
||||
public ItemStack getInput() {
|
||||
return this.ingredient.getItemStack();
|
||||
diff --git a/src/main/java/org/bukkit/inventory/CraftingInventory.java b/src/main/java/org/bukkit/inventory/CraftingInventory.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/CraftingInventory.java
|
||||
@ -730,6 +744,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public ShapedRecipe setIngredient(char key, @NotNull MaterialData ingredient) {
|
||||
return setIngredient(key, ingredient.getItemType(), ingredient.getData());
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
* Get a copy of the ingredients map.
|
||||
*
|
||||
* @return The mapping of character to ingredients.
|
||||
+ * @deprecated Use {@link #getChoiceMap()} instead for more complete data.
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@NotNull
|
||||
public Map<Character, ItemStack> getIngredientMap() {
|
||||
HashMap<Character, ItemStack> result = new HashMap<Character, ItemStack>();
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
||||
@ -778,6 +802,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public ShapelessRecipe removeIngredient(int count, @NotNull MaterialData ingredient) {
|
||||
return removeIngredient(count, ingredient.getItemType(), ingredient.getData());
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
* Get the list of ingredients used for this recipe.
|
||||
*
|
||||
* @return The input list
|
||||
+ * @deprecated Use {@link #getChoiceList()} instead for more complete data.
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@NotNull
|
||||
public List<ItemStack> getIngredientList() {
|
||||
ArrayList<ItemStack> result = new ArrayList<ItemStack>(ingredients.size());
|
||||
diff --git a/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java b/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java
|
||||
@@ -0,0 +0,0 @@ public class StonecuttingRecipe implements Recipe, Keyed {
|
||||
* Get the input material.
|
||||
*
|
||||
* @return The input material.
|
||||
+ * @deprecated Use {@link #getInputChoice()} instead for more complete data.
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@NotNull
|
||||
public ItemStack getInput() {
|
||||
return this.ingredient.getItemStack();
|
||||
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren