Java NullPointerExceptions

Discussion in 'Plugin Development' started by aPerson12, Aug 14, 2023.

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

    aPerson12

    hello! I am trying to learn how to code some plugins, but I am having issues with my commands.
    i tried adding this (suggested to me by intelliJ because it said there are potential nullpointerexception errors there, I added it but they still exist
    upload_2023-8-14_11-32-3.png upload_2023-8-14_11-33-11.png
    this is my command class, I have no idea what could be causing the errors, I tried making the command from this guide: https://www.spigotmc.org/wiki/create-a-simple-command/
    and this tutorial:
    but both of them give me the same errors
     
  2. Offline

    timtower Administrator Administrator Moderator

    @aPerson12 you did not register the command in your plugin.yml
     
  3. Offline

    aPerson12

    upload_2023-8-14_12-46-5.png
    i did register it
     
  4. Offline

    KarimAKL

    @aPerson12 Does the plugin enable successfully? Check the server log.
     
  5. Offline

    NotCopter

    try:

    Code:
    getServer().getPluginCommand("test").setExecutor(new Command1());
    
     
  6. Offline

    Strahan

    Show us a server startup log.

    The require non null is irrelevant you can remove that.
    It doesn't make any difference, as he's in the main class so it inherits the necessary methods. Getting the server isn't required and does the same thing anyway.
     
  7. Offline

    aPerson12

    sorry for the late responses i was on a vacation, here is the log: https://pastebin.com/jVrnMYLs

    it did not work, it gave me an error again java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.improve.testing.TestingPlugin.getCommand(String)" is null

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  8. Offline

    timtower Administrator Administrator Moderator

    Locked
    Offline mode and protocol hacks are not supported by Bukkit
     
Thread Status:
Not open for further replies.

Share This Page