public static CraftShapedRecipe fromBukkitRecipe(ShapedRecipe recipe) { if (recipe instanceof CraftShapedRecipe) { return (CraftShapedRecipe) recipe; } CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getResult()); String[] shape = recipe.getShape(); ret.shape(shape); Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap(); for (char c : ingredientMap.keySet()) { ItemStack stack = ingredientMap.get(c); if (stack != null) { ret.setIngredient(c, stack.getType(), stack.getDurability()); } } return ret; }
@EventHandler public void onCraft(CraftItemEvent e) { Player p = (Player) e.getWhoClicked(); if(e.getRecipe() instanceof ShapedRecipe) { ShapedRecipe sr = (ShapedRecipe) e.getRecipe(); if(Bukkit.getBukkitVersion().contains("1.11")) { for(BagBase bb : Util.getBags()) { if(((ShapedRecipe)bb.getRecipe()).getShape().equals(sr.getShape())) { if(!hasPermission(new Permission("bag.craft." + bb.getName(), PermissionDefault.TRUE), p)) e.setCancelled(true); } } } else if(sr.getKey().getNamespace().startsWith("bag_")) { if(!hasPermission(new Permission("bag.craft." + sr.getKey().getKey(), PermissionDefault.TRUE), p)) e.setCancelled(true); } } }
public static CraftShapedRecipe fromBukkitRecipe(ShapedRecipe recipe) { if (recipe instanceof CraftShapedRecipe) { return (CraftShapedRecipe) recipe; } CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getKey(), recipe.getResult()); String[] shape = recipe.getShape(); ret.shape(shape); Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap(); for (char c : ingredientMap.keySet()) { ItemStack stack = ingredientMap.get(c); if (stack != null) { ret.setIngredient(c, stack.getType(), stack.getDurability()); } } return ret; }
/** * Shapes a recipe from an {@link EnhancedItem} {@link Recipe} and registers it * * @param recipe The recipe to shape and register */ public static void registerShapedRecipe(Recipe recipe) { String top = recipe.getTop(); String mid = recipe.getMid(); String bot = recipe.getBot(); ItemStack itemStack = EnhancedItemUtil.createItem(recipe.getOutput(), null); ShapedRecipe shapedRecipe = new ShapedRecipe(itemStack); shapedRecipe.shape(top, mid, bot); shapedRecipe = recipe.shapeRecipe(shapedRecipe); EnhancedItems.getInstance().getServer().addRecipe(shapedRecipe); EnhancedItems.getInstance().addRecipe(recipe); }
public void registerRecipes() { Bukkit.resetRecipes(); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.BEETROOT_SOUP)).shape(new String[] {"rrr", "rrr", " b "}).setIngredient('r', MaterialList.BEETROOT).setIngredient('b', org.bukkit.Material.BOWL)); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.END_BRICKS)).shape(new String[] {"ee", "ee"}).setIngredient('e', org.bukkit.Material.ENDER_STONE)); //Purpur block recipes addRecipe(new FurnaceRecipe(new ItemStack(MaterialList.CHORUS_FRUIT_POPPED), MaterialList.CHORUS_FRUIT)); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.PURPUR_BLOCK, 4)).shape(new String[] {"pp", "pp"}).setIngredient('p', MaterialList.CHORUS_FRUIT_POPPED)); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.PURPUR_STAIRS, 4)).shape(new String[] {"p ", "pp ", "ppp"}).setIngredient('p', MaterialList.PURPUR_BLOCK)); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.PURPUR_STAIRS, 4)).shape(new String[] {" p", " pp", "ppp"}).setIngredient('p', MaterialList.PURPUR_BLOCK)); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.PURPUR_SLAB, 6)).shape(new String[] {"ppp"}).setIngredient('p', MaterialList.PURPUR_BLOCK)); addRecipe(new ShapedRecipe(new ItemStack(MaterialList.PURPUR_PILLAR)).shape(new String[] {"s", "s"}).setIngredient('s', MaterialList.PURPUR_SLAB)); //Arrows addRecipe(new ShapedRecipe(new ItemStack(MaterialList.SPECTRAL_ARROW, 2)).shape(new String[] {" d ", "dad", " d "}).setIngredient('d', org.bukkit.Material.GLOWSTONE_DUST).setIngredient('a', org.bukkit.Material.ARROW)); }
public RecipeManager(SCG plugin ){ this.plugin = plugin; ItemStack ender = new ItemStack(Material.ENDER_STONE); ShapedRecipe enderRecipe = new ShapedRecipe(ender); enderRecipe.shape("*S*","SPS","*S*"); enderRecipe.setIngredient('*', Material.REDSTONE); enderRecipe.setIngredient('S', Material.STONE); enderRecipe.setIngredient('P', Material.PISTON_BASE); Bukkit.addRecipe(enderRecipe); ItemStack enderChest = new ItemStack(Material.ENDER_CHEST); ShapedRecipe enderChestRecipe = new ShapedRecipe(enderChest); enderChestRecipe.shape("***","*P*","***"); enderChestRecipe.setIngredient('*', Material.OBSIDIAN); enderChestRecipe.setIngredient('P', Material.ENDER_PEARL); Bukkit.addRecipe(enderChestRecipe); // ItemStack obsidian = new ItemStack(Material.OBSIDIAN); // ShapedRecipe obsidianRecipe = new ShapedRecipe(obsidian); // obsidianRecipe.shape("***","***","***"); // obsidianRecipe.setIngredient('*', Material.COBBLESTONE); // Bukkit.addRecipe(obsidianRecipe); }
public void updateGoldenHead() { if (gA.mC.cLa) { List<ShapedRecipe> a = new ArrayList<>(); if (gA.mC.cLb) { if (!isRecipeEx(gG.get(0).getResult())) { gA.getServer().addRecipe(gG.get(0)); } } else { a.add(gG.get(0)); } if (gA.mC.cLc) { if (!isRecipeEx(gG.get(1).getResult())) { gA.getServer().addRecipe(gG.get(1)); } } else { a.add(gG.get(1)); } if (a.size() != 0) { removeGoldenHead(a); } } else { removeGoldenHead(gG); } }
@Override public Iterable<Recipe> getCraftingRecipes() { ArrayList<Recipe> recipes = new ArrayList<>(); ShapedRecipe baseRecipe = CraftingRecipes.shaped(makeItem(1), Material.STICK, Material.IRON_INGOT); recipes.add(CraftingRecipes.shaped(baseRecipe, "BBA", " ", " ")); recipes.add(CraftingRecipes.shaped(baseRecipe, " ", "BBA", " ")); recipes.add(CraftingRecipes.shaped(baseRecipe, " ", " ", "BBA")); recipes.add(CraftingRecipes.shaped(baseRecipe, "ABB", " ", " ")); recipes.add(CraftingRecipes.shaped(baseRecipe, " ", "ABB", " ")); recipes.add(CraftingRecipes.shaped(baseRecipe, " ", " ", "ABB")); return recipes; }
public static void removeRecipes(FileConfiguration cfg, HashMap<Integer, ConfigRemovedRecipes> removedRecipies){ List<Map<?, ?>> configMaterials = cfg.getMapList("removed_recipes"); for (Map<?, ?> b : configMaterials) { ConfigRemovedRecipes item = new ConfigRemovedRecipes(); item.type_id = (Integer)b.get("type_id"); item.data = (Integer)b.get("data"); removedRecipies.put(item.type_id, item); Iterator<Recipe> it = Bukkit.getServer().recipeIterator(); while (it.hasNext()) { Recipe recipe = it.next(); if (recipe instanceof ShapedRecipe) { ShapedRecipe shapedRecipe = (ShapedRecipe)recipe; if (ItemManager.getId(shapedRecipe.getResult()) == item.type_id && shapedRecipe.getResult().getDurability() == (short)item.data) { it.remove(); break; } } } } }
Transaction collect(ShapedRecipe recipe) { List<ItemStack> collected = new ArrayList<ItemStack>(rows * columns); String[] shape = recipe.getShape(); Map<Character, ItemStack> map = recipe.getIngredientMap(); for (String s : shape) INGREDIENTS: for (int i = 0; i < s.length(); i++) { ItemStack ingredient = map.get(s.charAt(i)); if (ingredient == null) continue; for (ItemStack item : collected) { if (ItemUtils.itemEqualsTypeAndData(item, ingredient)) { item.setAmount(item.getAmount() + ingredient.getAmount()); continue INGREDIENTS; } } collected.add(ingredient); } return new Transaction(collected, recipe.getResult()); }
@SuppressWarnings("deprecation") static void addRecipes() { /**Redstone Apple Recipe**/ ShapedRecipe redstoneApple = new ShapedRecipe(redstoneApple()); redstoneApple.shape("XXX", "XAX", "XXX"); redstoneApple.setIngredient('X', Material.REDSTONE); redstoneApple.setIngredient('A', Material.APPLE); Bukkit.getServer().addRecipe(redstoneApple); /**Redstone Activator Recipe**/ ShapedRecipe Activator = new ShapedRecipe(redstoneActivator()); Activator.shape("XXX", "XXX", "XXX"); Activator.setIngredient('X', Material.APPLE, (short) 1000); Bukkit.getServer().addRecipe(Activator); }
public void loadRecipes() { ItemStack stack = new ItemStack(Material.STONE, 1); ItemMeta meta = stack.getItemMeta(); meta.setDisplayName("crate"); stack.setItemMeta(meta); ShapedRecipe recipe1 = new ShapedRecipe(stack); recipe1.shape(new String[] { "AAA", "ABA", " A " }); recipe1.setIngredient('A', Material.IRON_INGOT); recipe1.setIngredient('B', Material.GOLD_INGOT); ShapedRecipe recipe2 = new ShapedRecipe(stack); recipe2.shape(new String[] { "AAA", "ACA", " A " }); recipe2.setIngredient('A', Material.IRON_INGOT); recipe2.setIngredient('C', Material.DIAMOND); Bukkit.addRecipe(recipe1); Bukkit.addRecipe(recipe2); }
/** * Add our recipes */ @Override protected void enableCallback() { //Make a recipe that will return a golden carrot when the right shape is made ShapedRecipe newGoldenCarrot = new ShapedRecipe(new ItemStack(Material.GOLDEN_CARROT, 1)); //8 gold ingots surrounding an apple newGoldenCarrot.shape("AAA", "ABA", "AAA"); newGoldenCarrot.setIngredient('A', Material.GOLD_INGOT); newGoldenCarrot.setIngredient('B', Material.CARROT_ITEM); Bukkit.addRecipe(newGoldenCarrot); //Make the recipe for glistering melons minus a set shape (glistering melon is speckled melon in code ShapelessRecipe newGlisteringMelon = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON, 1)); //1 gold ingot with a melon newGlisteringMelon.addIngredient(Material.GOLD_BLOCK); newGlisteringMelon.addIngredient(Material.MELON); Bukkit.addRecipe(newGlisteringMelon); }
@Override public Recipe getRecipe() { ShapedRecipe recipe = new ShapedRecipe(toItemStack()); ToughMachineFrame mf = new ToughMachineFrame(); IntegratedCircuit ic = new IntegratedCircuit(); registerCustomIngredients(mf, ic); recipe.shape("OCO", "DFP", "RGR"); recipe.setIngredient('O', Material.OBSIDIAN); recipe.setIngredient('C', ic.getMaterialData()); recipe.setIngredient('D', Material.DISPENSER); recipe.setIngredient('F', mf.getMaterialData()); recipe.setIngredient('P', Material.DIAMOND_PICKAXE); recipe.setIngredient('R', Material.REDSTONE); recipe.setIngredient('G', Material.GOLD_INGOT); return recipe; }
@SuppressWarnings("deprecation") private static void injectRecipes() { ShapedRecipe slimeBlock = new ShapedRecipe(new ItemStack( Material.getMaterial("slime"))).shape( new String[] { "###", "###", "###" }).setIngredient('#', Material.SLIME_BALL); Bukkit.getServer().addRecipe(slimeBlock); ShapelessRecipe deslimeBlock = new ShapelessRecipe(new ItemStack( Material.SLIME_BALL, 9)); deslimeBlock.addIngredient(Material.getMaterial("slime")); Bukkit.getServer().addRecipe(deslimeBlock); ShapedRecipe redSandStone = new ShapedRecipe(new ItemStack(Material.getMaterial("red_sandstone"))) .shape(new String[] { " ", "## ", "## " }).setIngredient('#', Material.SAND, 1); Bukkit.getServer().addRecipe(redSandStone); }
public void registerRecipe(){ ItemStack i = getPokeEgg(); ShapedRecipe pokeEgg = new ShapedRecipe(i); pokeEgg.shape("BAB", "DCD", "BAB"); pokeEgg.setIngredient('B', Material.WOOL); pokeEgg.setIngredient('A', Material.STRING); pokeEgg.setIngredient('D', Material.GOLD_NUGGET); pokeEgg.setIngredient('C', Material.EGG); Bukkit.addRecipe(pokeEgg); }
public PowerCrystal(ItemStack item, String id) { super(item, id); ShapedRecipe pcrysr = new ShapedRecipe(item); pcrysr.shape("=-=", "-#-", "=-="); pcrysr.setIngredient('#', Material.DIAMOND); pcrysr.setIngredient('-', Material.GOLD_INGOT); pcrysr.setIngredient('=', Material.REDSTONE); Bukkit.getServer().addRecipe(pcrysr); }
public static void initRecipes() { for(BagBase bb : Util.getBags()) { String prefix = "recipes." + bb.getName(); ShapedRecipe sr = bb.getStandardRecipe(); Map<Character, ItemStack> map = sr.getIngredientMap(); Material[] matArray = new Material[9]; setIf(prefix + ".1", map.get(sr.getShape()[0].charAt(0)).getType().toString()); setIf(prefix + ".2", map.get(sr.getShape()[0].charAt(1)).getType().toString()); setIf(prefix + ".3", map.get(sr.getShape()[0].charAt(2)).getType().toString()); setIf(prefix + ".4", map.get(sr.getShape()[1].charAt(0)).getType().toString()); setIf(prefix + ".5", map.get(sr.getShape()[1].charAt(1)).getType().toString()); setIf(prefix + ".6", map.get(sr.getShape()[1].charAt(2)).getType().toString()); setIf(prefix + ".7", map.get(sr.getShape()[2].charAt(0)).getType().toString()); setIf(prefix + ".8", map.get(sr.getShape()[2].charAt(1)).getType().toString()); setIf(prefix + ".9", map.get(sr.getShape()[2].charAt(2)).getType().toString()); } try { Bags2.recipes.save(Bags2.recipesFile); } catch (IOException e) { e.printStackTrace(); } }
@Override public Recipe getRecipe() { ShapedRecipe r = new ShapedRecipe(baseItem); r.shape(" x", " y ", "x "); r.setIngredient('x', Material.REDSTONE); r.setIngredient('y', Material.STICK); return r; }
private void addIronDurabilityRecipe() { ItemStack chestStack = new ItemStack(Material.IRON_CHESTPLATE, 1); chestStack.setDurability((short)-IronChestplateAugmentedDurability); ShapedRecipe chestRecipe = new ShapedRecipe( chestStack ); chestRecipe.shape("LLL","LIL","LLL"); chestRecipe.setIngredient('L', Material.LEATHER); chestRecipe.setIngredient('I', Material.IRON_CHESTPLATE); getServer().addRecipe(chestRecipe); ItemStack leggingsStack = new ItemStack(Material.IRON_LEGGINGS, 1); leggingsStack.setDurability((short)-IronLeggingsAugmentedDurability); ShapedRecipe leggingsRecipe = new ShapedRecipe( leggingsStack ); leggingsRecipe.shape("LLL","LIL","LLL"); leggingsRecipe.setIngredient('L', Material.LEATHER); leggingsRecipe.setIngredient('I', Material.IRON_LEGGINGS); getServer().addRecipe(leggingsRecipe); ItemStack bootsStack = new ItemStack(Material.IRON_BOOTS, 1); bootsStack.setDurability((short)-IronBootsAugmentedDurability); ShapedRecipe bootsRecipe = new ShapedRecipe( bootsStack ); bootsRecipe.shape("LLL","LIL","LLL"); bootsRecipe.setIngredient('L', Material.LEATHER); bootsRecipe.setIngredient('I', Material.IRON_BOOTS); getServer().addRecipe(bootsRecipe); ItemStack helmetStack = new ItemStack(Material.IRON_HELMET, 1); helmetStack.setDurability((short)-IronHelmetAugmentedDurability); ShapedRecipe helmetRecipe = new ShapedRecipe( helmetStack ); helmetRecipe.shape("LLL","LIL","LLL"); helmetRecipe.setIngredient('L', Material.LEATHER); helmetRecipe.setIngredient('I', Material.IRON_HELMET); getServer().addRecipe(helmetRecipe); }
public static void addRecipe() { if(Config.getConfig().getBoolean("Features.CraftableOpGapple")) { ShapedRecipe recipe = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1)); recipe.shape("ggg", "gag", "ggg"); recipe.setIngredient('g', Material.GOLD_BLOCK); recipe.setIngredient('a', Material.APPLE); Bukkit.addRecipe(recipe); } }
@Override public void onEnable() { if (Settings.isAutoUpdateEnabled()) { new Updater(this, 88505, getFile(), Updater.UpdateType.DEFAULT, true); } try { MetricsLite metrics = new MetricsLite(this); metrics.start(); } catch (IOException e) { getLogger().info("Failed to submit statistics to MCStats!"); } instance = this; // Register the event listener getServer().getPluginManager().registerEvents(new EnderBowListener(), this); // Register the command getCommand("enderbow").setExecutor(new EnderBowCommand()); // Create the recipe ShapedRecipe enderBowRecipe = new ShapedRecipe(getEnderBow()); enderBowRecipe.shape("eee", "ebe", "eee"); enderBowRecipe.setIngredient('e', Material.ENDER_PEARL); enderBowRecipe.setIngredient('b', Material.BOW); // Add the recipe getServer().addRecipe(enderBowRecipe); }
public void setRecipes() { this.DiamondHammerRecipe = new ShapedRecipe(this.DiamondHammer); this.DiamondHammerRecipe.shape(new String[] { "mmm", "mim", "mmm" }); this.DiamondHammerRecipe.setIngredient('m', Material.DIAMOND_BLOCK); this.DiamondHammerRecipe.setIngredient('i', Material.DIAMOND_PICKAXE); }
public void setRecipes() { this.DiamondExcavatorRecipe = new ShapedRecipe(this.DiamondExcavator); this.DiamondExcavatorRecipe.shape(new String[] { "mmm", "mim", "mmm" }); this.DiamondExcavatorRecipe.setIngredient('m', Material.DIAMOND_BLOCK); this.DiamondExcavatorRecipe.setIngredient('i', Material.DIAMOND_SPADE); }
public static <T> T accept(Recipe recipe, RecipeVisitor<T> visitor) { if (recipe instanceof ShapedRecipe) { ShapedRecipe shapedRecipe = (ShapedRecipe) recipe; return visitor.visit(shapedRecipe); } else if (recipe instanceof ShapelessRecipe) { ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe; return visitor.visit(shapelessRecipe); } else if (recipe instanceof FurnaceRecipe) { FurnaceRecipe furnaceRecipe = (FurnaceRecipe) recipe; return visitor.visit(furnaceRecipe); } return visitor.visitOther(recipe); }