Custom crafting with config

Discussion in 'Plugin Development' started by ArthurHoeke, Dec 11, 2014.

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

    ArthurHoeke

    Hello,
    I have some problems with a plugin im working on.
    I want to make for custom crafting that you can change the custom crafting item in the config.
    So the problem is, I have the part with the get item id from config but it just doesn't reconize the item.
    When I try to craft with the item id set in the config nothing happens..
    My code:
    Code:
     private void precipe() {
                    ItemStack item = new ItemStack(Material.BONE, 1);
                    Material material = Material.getMaterial(plugin.getConfig().getInt("customrecipe.item1.input"));
                    ShapelessRecipe precipe = new ShapelessRecipe(item);
                    precipe.addIngredient(1, material);
                    Bukkit.getServer().addRecipe(precipe);
            }
            public void loadConfiguration(){
                //See "Creating you're defaults"
                plugin.getConfig().options().copyDefaults(true); // NOTE: You do not have to use "plugin." if the class extends the java plugin
                //Save the config whenever you manipulate it
                String customitem1 = "customrecipe.item1.input";
                String customitem2 = "customrecipe.item1.output";
                String customitem3 = "customrecipe.item1.ihowmany";
                String customitem4 = "customrecipe.item1.ohowmany";
                        plugin.getConfig().addDefault(customitem1, (int)260);
                        plugin.getConfig().addDefault(customitem2, (int)352);
                        plugin.getConfig().addDefault(customitem3, (int)1);
                        plugin.getConfig().addDefault(customitem4, (int)2);
                        plugin.getConfig().options().copyDefaults(true);
                plugin.saveConfig();
     
  2. Offline

    Retherz_

    replace Material.getMaterial with Material,matchMaterial
     
  3. Offline

    ArthurHoeke

    @Retherz_ The method matchMaterial(String) in the type Material is not applicable for the arguments (int)
     
  4. @ArthurHoeke If only there were like a billion ways to convert an int to a String, eh?
     
    teej107 likes this.
  5. Offline

    teej107

  6. Offline

    ArthurHoeke

  7. Offline

    teej107

  8. Offline

    ArthurHoeke

    @teej107 I watched it, but dont get what I do wrong in my code..
     
  9. Offline

    Lorinthio

    try this

    Material mat = Material.getMaterial(id)

    its depreciated but will still work fine as far as I know.
     
  10. Offline

    teej107

    Have you actually tried to read some of the search results?
     
  11. Offline

    ArthurHoeke

    @teej107 I did but didn't found any helpfull information
     
  12. Offline

    teej107

  13. Offline

    ArthurHoeke

Thread Status:
Not open for further replies.

Share This Page