[Bleeding] Add ways to retrieve and delete crafting recipes and fixed some issues with the existing recipe API.

- New recipe iterator which enables deleting specific recipes
- Functions to delete all recipes or revert to vanilla recipe set
- Fixed the recipes API; you should now be able to define recipes that take brewed potions!
- Fetch all recipes that result in a specific item
This commit is contained in:
Celtic Minstrel
2011-07-23 23:18:58 -04:00
committed by EvilSeph
parent 870d10b077
commit 3604da1f55
6 changed files with 226 additions and 81 deletions

View File

@@ -8,7 +8,7 @@ import org.bukkit.material.MaterialData;
*/
public class FurnaceRecipe implements Recipe {
private ItemStack output;
private MaterialData ingredient;
private ItemStack ingredient;
/**
* Create a furnace recipe to craft the specified ItemStack.
@@ -17,10 +17,7 @@ public class FurnaceRecipe implements Recipe {
* @param source The input material.
*/
public FurnaceRecipe(ItemStack result, Material source) {
this(result, source.getNewData((byte) 0));
if (this.ingredient == null) {
setInput(new MaterialData(source));
}
this(result, source, 0);
}
/**
@@ -30,8 +27,19 @@ public class FurnaceRecipe implements Recipe {
* @param source The input material.
*/
public FurnaceRecipe(ItemStack result, MaterialData source) {
this.output = result;
this.ingredient = source;
this(result, source.getItemType(), source.getData());
}
/**
* Create a furnace recipe to craft the specified ItemStack.
*
* @param result The item you want the recipe to create.
* @param source The input material.
* @param data The data value. (Note: This is currently ignored by the CraftBukkit server.)
*/
public FurnaceRecipe(ItemStack result, Material source, int data) {
this.output = new ItemStack(result);
this.ingredient = new ItemStack(source, 1, (short) data);
}
/**
@@ -41,8 +49,7 @@ public class FurnaceRecipe implements Recipe {
* @return The changed recipe, so you can chain calls.
*/
public FurnaceRecipe setInput(MaterialData input) {
this.ingredient = input;
return this;
return setInput(input.getItemType(), input.getData());
}
/**
@@ -52,10 +59,18 @@ public class FurnaceRecipe implements Recipe {
* @return The changed recipe, so you can chain calls.
*/
public FurnaceRecipe setInput(Material input) {
setInput(input.getNewData((byte) 0));
if (this.ingredient == null) {
setInput(new MaterialData(input));
}
return setInput(input, 0);
}
/**
* Sets the input of this furnace recipe.
*
* @param input The input material.
* @param data The data value. (Note: This is currently ignored by the CraftBukkit server.)
* @return The changed recipe, so you can chain calls.
*/
public FurnaceRecipe setInput(Material input, int data) {
this.ingredient = new ItemStack(input, 1, (short) data);
return this;
}
@@ -64,8 +79,8 @@ public class FurnaceRecipe implements Recipe {
*
* @return The input material.
*/
public MaterialData getInput() {
return ingredient;
public ItemStack getInput() {
return this.ingredient.clone();
}
/**
@@ -74,6 +89,6 @@ public class FurnaceRecipe implements Recipe {
* @return The resulting stack.
*/
public ItemStack getResult() {
return output;
return output.clone();
}
}