|
27 | 27 | import org.bukkit.inventory.InventoryView; |
28 | 28 | import org.bukkit.inventory.ItemStack; |
29 | 29 | import org.bukkit.inventory.Recipe; |
| 30 | +import org.bukkit.inventory.RecipeChoice; |
| 31 | +import org.bukkit.inventory.RecipeChoice.ExactChoice; |
| 32 | +import org.bukkit.inventory.RecipeChoice.MaterialChoice; |
30 | 33 | import org.bukkit.inventory.ShapedRecipe; |
31 | 34 | import org.bukkit.inventory.ShapelessRecipe; |
| 35 | +import org.bukkit.inventory.TransmuteRecipe; |
32 | 36 | import org.bukkit.inventory.meta.Damageable; |
33 | 37 | import org.royaldev.royalcommands.MessageColor; |
34 | 38 | import org.royaldev.royalcommands.RUtils; |
@@ -85,6 +89,28 @@ private void scheduleRecipeTask(final Player p, ItemStack is) { |
85 | 89 | i.setItem(slot, ingredients.get(slot - 1)); |
86 | 90 | } |
87 | 91 | i.setItem(0, sr.getResult()); |
| 92 | + } else if (r instanceof TransmuteRecipe) { |
| 93 | + final TransmuteRecipe tr = (TransmuteRecipe) r; |
| 94 | + if (!tr.getInput().test(is) && !tr.getMaterial().test(is)) continue; |
| 95 | + RecipeChoice in1 = tr.getInput(); |
| 96 | + RecipeChoice in2 = tr.getMaterial(); |
| 97 | + i = this.plugin.getServer().createInventory(new RecipeHolder(), InventoryType.WORKBENCH); |
| 98 | + final List<ItemStack> ingredients = new ArrayList<>(); |
| 99 | + if (in1 instanceof ExactChoice) { |
| 100 | + ingredients.add(((ExactChoice) in1).getItemStack()); |
| 101 | + } else if (in1 instanceof MaterialChoice) { |
| 102 | + ingredients.add(((MaterialChoice) in1).getItemStack()); |
| 103 | + } |
| 104 | + if (in2 instanceof ExactChoice) { |
| 105 | + ingredients.add(((ExactChoice) in2).getItemStack()); |
| 106 | + } else if (in2 instanceof MaterialChoice) { |
| 107 | + ingredients.add(((MaterialChoice) in2).getItemStack()); |
| 108 | + } |
| 109 | + for (int slot = 1; slot <= ingredients.size(); slot++) { |
| 110 | + if (slot > ingredients.size()) continue; |
| 111 | + i.setItem(slot, ingredients.get(slot - 1)); |
| 112 | + } |
| 113 | + i.setItem(0, tr.getResult()); |
88 | 114 | } else if (r instanceof FurnaceRecipe) { |
89 | 115 | i = this.plugin.getServer().createInventory(new RecipeHolder(), InventoryType.FURNACE); |
90 | 116 | final FurnaceRecipe fr = (FurnaceRecipe) r; |
|
0 commit comments