Solved Help needed with deprecated method (ShapedRecipe)

Discussion in 'Plugin Development' started by DutchJellyV2, Feb 13, 2018.

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

    DutchJellyV2

    Hi,

    I'm trying to create a custom recipe, but appearently the method all tutorials use is deprecated. I found some documentations about it:
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/ShapedRecipe.html
    https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/NamespacedKey.html
    I do realise that a NamespacedKey is needed for the not deprecated method of creating the recipe instance. Unfortunately do I not fully understand this key class. Also can't I find good documentations on it that explain what it is.

    Enough information, here's the code that throws errors in eclipse.

    Code:
    NamespacedKey key = new NamespacedKey(this, NamespacedKey.BUKKIT);
            ShapedRecipe recipe = new ShapedRecipe(key, resultItem);
    I hope someone knows more about this recently added deprecation and how to fix it.

    -DutchJelly
     
  2. Offline

    timtower Administrator Administrator Moderator

    @DutchJellyV2 Looks like the NamespaceKey is just some internal stuff.
     
  3. Offline

    DutchJellyV2

    Ehm eclipse didn't update which was the problem I think . Sorry about that. I'll look if it works and if it does I'll set the tag to solved.

    Hey @timtower quick question: is there a way to add enchanted items to a recipe? I tried:

    Code:
    bookMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true);
            book.setItemMeta(bookMeta);
            recipe.setIngredient('B', book.getData());
    but it's not working.
    thanks in advance

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 13, 2018
  4. Offline

    timtower Administrator Administrator Moderator

    @DutchJellyV2 You need to listen to the events for that I believe, but I am not sure on it (never did anything with crafting)
     
  5. Offline

    DutchJellyV2

    Oh damn.. that sucks. Thanks :)
     
Thread Status:
Not open for further replies.

Share This Page