Solved NamespacedKey cannot be resolved to a type

Discussion in 'Plugin Development' started by LucaForever, Nov 9, 2020.

  1. Offline


    I was trying to add a recipe, and i literally copied from the spigot website the code:

    package org.---.utilites;
    import org.---.commands.FlyCommand;
    import org.---.commands.GameUICommand;
    import org.---.commands.HelloCommand;
    import org.---.commands.gamemode.Adventure;
    import org.--.commands.gamemode.Creative;
    import org.---.commands.gamemode.Spectator;
    import org.---.commands.gamemode.Survival;
    import org.---.listeners.InventoryClickListener;
    import org.---.listeners.JoinListeners;
    import org.---.ui.GamesUI;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.inventory.meta.ItemMeta;
    [B]import org.bukkit.NamespacedKey[/B]
    public class Main extends JavaPlugin
        public void onEnable()
            new HelloCommand(this);
            new GameUICommand(this);
            new FlyCommand(this);
            new Creative(this);
            new Survival(this);
            new Adventure(this);
            new Spectator(this);
            new JoinListeners(this);
            new InventoryClickListener(this);
            //ui initializer
            ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(ChatColor.GREEN + "Emerald Sword");
            item.addEnchantment(Enchantment.DAMAGE_ALL, 5);
            NamespacedKey key = new NamespacedKey(this, "emerald_sword");
            ShapedRecipe recipe = new ShapedRecipe(key, item);
            recipe.shape(" E ", " E ", " S ");
            recipe.setIngredient('E', Material.EMERALD);
            recipe.setIngredient('S', Material.STICK);

    Here are the errors:

    ok i just found out that namespacedkey is 1.12 and im on 1.8.9

    but i dont know how to do it still[/I][/INDENT]
    Last edited: Nov 11, 2020
  2. Offline

    timtower Moderator Moderator

    @LucaForever Remove the key variable.
    And try to use [code] <code here> [/code]
    Then it is actually readable.
  3. Offline


    I did, but i already fixed this. Thanks for responding tho

Share This Page