[Bleeding] Recipe API improvements and fixes. Addresses BUKKIT-738 and BUKKIT-624

Add a recipe iterator to make it possible to retrieve and remove recipes (BUKKIT-738), and updated the recipe classes to not clip the data to 127 (BUKKIT-624)
This commit is contained in:
Celtic Minstrel
2011-07-23 23:16:14 -04:00
committed by EvilSeph
parent 84ecdb5439
commit 326091c130
10 changed files with 227 additions and 33 deletions

View File

@@ -8,13 +8,13 @@ import java.util.List;
public class CraftingManager {
private static final CraftingManager a = new CraftingManager();
private List b = new ArrayList();
public List b = new ArrayList(); // CraftBukkit - private -> public
public static final CraftingManager getInstance() {
return a;
}
private CraftingManager() {
public CraftingManager() { // CraftBukkit - private -> public
(new RecipesTools()).a(this);
(new RecipesWeapons()).a(this);
(new RecipeIngots()).a(this);
@@ -91,10 +91,17 @@ public class CraftingManager {
this.registerShapedRecipe(new ItemStack(Item.BED, 1), new Object[] { "###", "XXX", Character.valueOf('#'), Block.WOOL, Character.valueOf('X'), Block.WOOD});
this.registerShapedRecipe(new ItemStack(Block.ENCHANTMENT_TABLE, 1), new Object[] { " B ", "D#D", "###", Character.valueOf('#'), Block.OBSIDIAN, Character.valueOf('B'), Item.BOOK, Character.valueOf('D'), Item.DIAMOND});
this.registerShapelessRecipe(new ItemStack(Item.EYE_OF_ENDER, 1), new Object[] { Item.ENDER_PEARL, Item.BLAZE_POWDER});
Collections.sort(this.b, new RecipeSorter(this));
//Collections.sort(this.b, new RecipeSorter(this)); // CraftBukkit - removed; see below
this.sort(); // CraftBukkit - moved sort to a separate method
System.out.println(this.b.size() + " recipes");
}
// CraftBukkit start
public void sort() {
Collections.sort(this.b, new RecipeSorter(this));
}
// CraftBukkit end
public void registerShapedRecipe(ItemStack itemstack, Object... aobject) { // CraftBukkit - default -> public
String s = "";
int i = 0;