setExecutor Error

Discussion in 'Spigot Plugin Help' started by SpyingBadge2143, Aug 7, 2021.

  1. Apparently It's null Here's the code.

    creepermultiply:

    Code (Java):
    package me.spyingbagdge2143.creepermultiply;

    import org.bukkit.ChatColor;
    import org.bukkit.plugin.java.JavaPlugin;

    import java.util.Objects;


    public final class Creepermultiply extends JavaPlugin {

        private Commands commands;

        @Override
        public void onEnable() {
            System.out.println(ChatColor.GOLD + "Tapl Recreation Multiplying Health On Creeper Death Loaded. Have Fun!");
            this.getServer().getPluginManager().registerEvents(new Events(), this);
            this.getCommand("ResetHealth").setExecutor(new Commands());
        }

        @Override
        public void onDisable() {
            // Plugin shutdown logic
        }

    }
    Plugin.yml:


    Code (YAML):
    main: me.spyingbadge2143.creepermultiply.Creepermultiply
    name
    : multiplyingcreeperexplosionhealth
    version
    : 1.0
    commands
    :
      ResetHealth
    :
        description
    : Gamer Command To Reset Your Health
        permission
    : CreeperMultiply.HealthReset
        usage
    : /ResetHealth
     
    Error:


    Code (Java):
    [19:43:31 ERROR]: Error occurred while enabling Creepermultiply v1.0 (Is it up to date?)
    java.lang.NullPointerException: null
            at me.spyingbagdge2143.creepermultiply.Creepermultiply.onEnable(Creepermultiply.java:13) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.15.2.jar:git-Paper-391]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.15.2.jar:git-Paper-391]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.15.2.jar:git-Paper-391]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:472) ~[patched_1.15.2.jar:git-Paper-391]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:386) ~[patched_1.15.2.jar:git-Paper-391]
            at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:488) ~[patched_1.15.2.jar:git-Paper-391]
            at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.15.2.jar:git-Paper-391]
            at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:909) ~[patched_1.15.2.jar:git-Paper-391]
            at java.lang.Thread.run(Thread.java:832) [?:?]
     
    #1 SpyingBadge2143, Aug 7, 2021
    Last edited: Aug 7, 2021
  2. Please send Creepermultiply.java:13
     
  3. I called it main shouldn't of called it that xD
     
  4. This is null, you are not initializing it
    Code (Java):
    private Commands commands;
    Remove it and just register the command by importing the Commands class
     
    #4 reussy, Aug 7, 2021
    Last edited: Aug 7, 2021