Delete brewing and crafting recipe

Discussion in 'Plugin Development' started by 0verFull, May 6, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    0verFull

    Hi guys and girls,
    How to delete brewing and crafting recipe ?
    Thanks you for any answer.
     
  2. Offline

    RawCode

    did you read any tutorials about subject.

    do you have any code?
     
  3. Offline

    Konato_K

    @0verFull You can remove crafting and furnace recipes with Server#recipeIterator and calling Iterator#remove in it, this doesn't work for brewing recipes and you will probably have to cancel the BrewItemEvent or so.
     
  4. Offline

    0verFull

    @Konato_K, can I have a example if I want to delete the bucket's recipe ?

    Oh thanks, I have find it and it work:

    Code:
    package t;
    
    import java.util.Iterator;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.event.Listener;
    import org.bukkit.inventory.Recipe;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class t extends JavaPlugin implements Listener{
       
        public void onEnable(){
            Bukkit.getPluginManager().registerEvents(this, this);
            removeCraftRecipe();
        }
       
        public static void removeCraftRecipe() {
            remove(Material.BUCKET);
        }
        public static void remove(Material m) {
    
            Iterator<Recipe> IR = Bukkit.getServer().recipeIterator();
            Recipe R;
            while (IR.hasNext()) {
                R = IR.next();
                if (R != null && R.getResult().getType() == m) {
                    IR.remove();
                }
            }
        }
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page