java.lang.NullPointerException with plugin

Discussion in 'Plugin Development' started by Fingolfin, Apr 17, 2021.

  1. Offline


    So I tried to code my own plugins and it worked for a while but after coming back to it after a long pause my commands do not work anymore.. it only throws a `java.lang.NullPointerException`
    Here is my code so far:
    public class Main extends JavaPlugin {
    public void onEnable() {
    new HelloCommand(this);
    and my HelloCommand Plugin:
    public class HelloCommand implements CommandExecutor {
    private Main plugin1;
    public HelloCommand(Main plugin) {
    this.plugin1 = plugin;

    @Overridepublic boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
    sender.sendMessage("Only player should execute dad shyte");
    return true;
    I really appreciate any help!

    the error message:
    at me.fingolfin.helloworld.commands.HelloCommand.<init>( ~[?:?]
    at me.fingolfin.helloworld.Main.onEnable( ~[?:?]
    at ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.MinecraftServer.s( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.MinecraftServer.k( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.MinecraftServer.a( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.DedicatedServer.init( [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at [?:1.8.0_282]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Apr 17, 2021
  2. Offline

    timtower Administrator Administrator Moderator

    @Fingolfin Did you register the command in the plugin.yml?

Share This Page