Error on enable

Discussion in 'Plugin Development' started by aloxMCT, May 15, 2020.

  1. Offline

    aloxMCT

    here's the error
    Code:
    [00:30:17] [Server thread/INFO]: [BetterRecipes] Enabling BetterRecipes v1.0
    [00:30:17] [Server thread/ERROR]: Error occurred while enabling BetterRecipes v1.0 (Is it up to date?)
    java.lang.NullPointerException: null
            at org.bukkit.craftbukkit.v1_15_R1.util.CraftNamespacedKey.toMinecraft(CraftNamespacedKey.java:28) ~[spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.inventory.CraftFurnaceRecipe.addToCraftingManager(CraftFurnaceRecipe.java:28) ~[spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.addRecipe(CraftServer.java:1106) ~[spigot.jar:git-Spigot-800b93f-8160e29]
            at alox.betterrecipes.main.recipes(main.java:20) ~[?:?]
            at alox.betterrecipes.main.onEnable(main.java:12) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:462) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:376) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.reload(CraftServer.java:811) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.Bukkit.reload(Bukkit.java:576) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:711) [spigot.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchServerCommand(CraftServer.java:696) [spigot.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.DedicatedServer.handleCommandQueue(DedicatedServer.java:436) [spigot.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.DedicatedServer.b(DedicatedServer.java:400) [spigot.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:984) [spigot.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:824) [spigot.jar:git-Spigot-800b93f-8160e29]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
    and here's the main.jar

    Code:
    package alox.betterrecipes;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.inventory.FurnaceRecipe;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class main extends JavaPlugin{
            public void onEnable() {
                recipes();
                Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&6&l[BetterRecipes]Loaded successfully"));
            }
           
            public void recipes() {
                //Flesh to leather             ftl
                ItemStack leather = new ItemStack(Material.LEATHER);
                FurnaceRecipe ftl = new FurnaceRecipe(null, leather, Material.ROTTEN_FLESH, 1, 8);
                getServer().addRecipe(ftl);
            }
           
    
            public void onDisable() {
                Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&6&l[BetterRecipes]Disabled successfully"));
            }
        }
    I... don't know what to change :I
     
  2. Offline

    Tango_

    The first parameter of your FurnaceRecipe cannot be null, it takes a NamespacedKey, it can be done like so:

    Code:
        public void recipes() {
          
            NamespacedKey key = new NamespacedKey(this, "anyKey");
          
            //Flesh to leather  ftl
            ItemStack leather = new ItemStack(Material.LEATHER);
            FurnaceRecipe ftl = new FurnaceRecipe(key, leather, Material.ROTTEN_FLESH, 1, 8);
          
            getServer().addRecipe(ftl);
          
        }
     
    Last edited: May 16, 2020
  3. Offline

    aloxMCT

Share This Page