|
26 | 26 | import org.bukkit.inventory.InventoryHolder; |
27 | 27 | import org.bukkit.inventory.ItemStack; |
28 | 28 | import org.bukkit.inventory.Recipe; |
| 29 | +import org.bukkit.inventory.RecipeChoice; |
29 | 30 | import org.bukkit.inventory.ShapedRecipe; |
30 | 31 | import org.bukkit.inventory.ShapelessRecipe; |
| 32 | +import org.bukkit.inventory.TransmuteRecipe; |
| 33 | +import org.bukkit.inventory.RecipeChoice.ExactChoice; |
| 34 | +import org.bukkit.inventory.RecipeChoice.MaterialChoice; |
31 | 35 | import org.bukkit.inventory.meta.Damageable; |
32 | 36 | import org.bukkit.inventory.meta.ItemMeta; |
33 | 37 | import org.royaldev.royalcommands.MessageColor; |
@@ -97,6 +101,28 @@ private void scheduleUsesTask(final Player p, final ItemStack is) { |
97 | 101 | i.setItem(slot, this.syncDurabilities(ingredients.get(slot - 1), is)); |
98 | 102 | } |
99 | 103 | i.setItem(0, sr.getResult()); |
| 104 | + } else if (r instanceof TransmuteRecipe) { |
| 105 | + final TransmuteRecipe tr = (TransmuteRecipe) r; |
| 106 | + if (!tr.getInput().test(is) && !tr.getMaterial().test(is)) continue; |
| 107 | + RecipeChoice in1 = tr.getInput(); |
| 108 | + RecipeChoice in2 = tr.getMaterial(); |
| 109 | + i = this.plugin.getServer().createInventory(new UsesHolder(), InventoryType.WORKBENCH); |
| 110 | + final List<ItemStack> ingredients = new ArrayList<>(); |
| 111 | + if (in1 instanceof ExactChoice) { |
| 112 | + ingredients.add(((ExactChoice) in1).getItemStack()); |
| 113 | + } else if (in1 instanceof MaterialChoice) { |
| 114 | + ingredients.add(((MaterialChoice) in1).getItemStack()); |
| 115 | + } |
| 116 | + if (in2 instanceof ExactChoice) { |
| 117 | + ingredients.add(((ExactChoice) in2).getItemStack()); |
| 118 | + } else if (in2 instanceof MaterialChoice) { |
| 119 | + ingredients.add(((MaterialChoice) in2).getItemStack()); |
| 120 | + } |
| 121 | + for (int slot = 1; slot <= ingredients.size(); slot++) { |
| 122 | + if (slot > ingredients.size()) continue; |
| 123 | + i.setItem(slot, this.syncDurabilities(ingredients.get(slot - 1), is)); |
| 124 | + } |
| 125 | + i.setItem(0, tr.getResult()); |
100 | 126 | } else if (r instanceof FurnaceRecipe) { |
101 | 127 | final FurnaceRecipe fr = (FurnaceRecipe) r; |
102 | 128 | if (!this.itemStackEquals(fr.getInput(), is)) continue; |
|
0 commit comments