public static void init() { placedCobblex = new ArrayList<>(); item = new ItemBuilder(Material.MOSSY_COBBLESTONE) .setName(ChatUtil.fixColors("&e&lCobblex")) .setLore(ChatUtil.fixColors("&ePostaw, a nastepnie rozwal aby otrzymac itemy!")) .toItemStack(); Bukkit.addRecipe( new ShapedRecipe(item).shape("ccc", "ccc", "ccc").setIngredient('c', Material.COBBLESTONE)); }
public void resetRecipe(boolean removeOld) { if (removeOld) { Iterator<Recipe> it = Bukkit.recipeIterator(); while (it.hasNext()) { Recipe recipe = it.next(); RPGItem rpgitem = ItemManager.toRPGItem(recipe.getResult()); if (rpgitem == null) continue; if (rpgitem.getID() == getID()) { it.remove(); } } } if (hasRecipe) { Set<ItemStack> iSet = new HashSet<ItemStack>(); for (ItemStack m : recipe) { iSet.add(m); } ItemStack[] iList = iSet.toArray(new ItemStack[iSet.size()]); item.setItemMeta(getLocaleMeta("en_GB")); ShapedRecipe shapedRecipe = new ShapedRecipe(item); int i = 0; Map<ItemStack, Character> iMap = new HashMap<ItemStack, Character>(); for (ItemStack m : iList) { iMap.put(m, (char) (65 + i)); i++; } iMap.put(null, ' '); StringBuilder out = new StringBuilder(); for (ItemStack m : recipe) { out.append(iMap.get(m)); } String shape = out.toString(); shapedRecipe.shape(shape.substring(0, 3), shape.substring(3, 6), shape.substring(6, 9)); for (Entry<ItemStack, Character> e : iMap.entrySet()) { if (e.getKey() != null) { shapedRecipe.setIngredient( e.getValue(), e.getKey().getType(), e.getKey().getDurability()); } } Bukkit.addRecipe(shapedRecipe); } }