Advertisement
Guest User

CustomShapelessRecipe.java

a guest
Jul 5th, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. import org.bukkit.Material;
  2. import org.bukkit.inventory.ItemStack;
  3. import org.bukkit.inventory.ShapelessRecipe;
  4. import org.ourcraft.daskrr.smp.inventory.items.handler.ItemModifier.MArmor;
  5. import org.ourcraft.daskrr.smp.inventory.items.handler.ItemModifier.MWeapon;
  6.  
  7. public class CustomShapelessRecipe extends CustomRecipe
  8. {
  9.     public CustomShapelessRecipe(ItemStack result)
  10.     {
  11.         super (result);
  12.         this.recipe = new ShapelessRecipe(key(), result);
  13.     }
  14.    
  15.     public CustomShapelessRecipe(ShapelessRecipe recipe)
  16.     {
  17.         super (recipe.getResult());
  18.        
  19.         this.recipe = recipe;
  20.        
  21.         for (ItemStack is : recipe.getIngredientList())
  22.         {
  23.             if (is == null)
  24.                 continue;
  25.            
  26.             ItemStack ingredientFinal = new ItemStack(is);
  27.             if (!is.hasItemMeta())
  28.                 if (MWeapon.contains(is.getType().toString()))
  29.                     ingredientFinal = MWeapon.convertDefaultItem(new ItemStack(is));
  30.                 else if (MArmor.contains(is.getType().toString()))
  31.                     ingredientFinal = MArmor.convertDefaultItem(new ItemStack(is));
  32.                
  33.                
  34.             this.ingredients.add(ingredientFinal);
  35.         }
  36.     }
  37.    
  38.     public void addIngredient(Material ingredient)
  39.     {
  40.         ItemStack ingredientFinal;
  41.         if (MWeapon.contains(ingredient.toString()))
  42.             ingredientFinal = MWeapon.convertDefaultItem(new ItemStack(ingredient));
  43.         else if (MArmor.contains(ingredient.toString()))
  44.             ingredientFinal = MArmor.convertDefaultItem(new ItemStack(ingredient));
  45.         else
  46.             ingredientFinal = new ItemStack(ingredient);
  47.        
  48.         this.ingredients.add(new ItemStack(ingredientFinal));
  49.         ((ShapelessRecipe) recipe).addIngredient(ingredient);
  50.     }
  51.    
  52.     public void addIngredient(ItemStack it)
  53.     {
  54.         this.ingredients.add(it);
  55.         ((ShapelessRecipe) recipe).addIngredient(it.getType());
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement