Weirdest nullpointerexception 2013

Discussion in 'Plugin Development' started by ceoepts, Jul 8, 2013.

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

    ceoepts

    Hi today i felt like keep working on my plugin that was working 100% yerterday so first i want to test it and the first thing i find is that my plugin is saying there is a nullpointerexception at this line

    Code:
            getCommand("cutscene").setExecutor(new CommandExecuter(this));
    
    here is the plugin.yml

    Code:
    name: cutscenesforlajf
    version: 0.1
    main: me.ceoepts.cutscenes.Cutscenes
    commands:
    cutscene:
    playc:
     
  2. Offline

    Rocoty

    Indent your plugin.yml correctly
     
  3. Offline

    Chinwe

    I'm not sure if indentation is important, but I think you might need usage/description (iirc it's not necessary but it's useful)

    Try indenting with 4 spaces (no tabs)
    Code:
    commands:
        cutscene:
            usage: bleh
        playc:
            usage: bleh
     
  4. Offline

    afistofirony

    Need a bit more context. Stack-trace please?
     
  5. Offline

    Rocoty

    chinwe In YAML, indenting is necessary. And by convention, indents are two spaces, although it will work with four.
     
  6. Offline

    Chinwe

    Rocoty Ah okiedokie, thanks for the info :>
     
  7. Offline

    ceoepts

    sry Eclipse made them look wrong here is the real error yml
    Code:
    name: cutscenesforlajf
    version: 0.1
    main: me.ceoepts.cutscenes.Cutscenes
    commands:
      cutscene:
      playc:
    That code does not work here is my code for another plugin ive made:
    Code:
    name: RPGArmor
    version: 0.1
    main: me.ceoepts.rpgarmor.Main
    commands:
      stats:
    that works perfectly
    STILL UNSOLVED
     
  8. Offline

    slayr288

    ceoepts
    Because you need to have atleast some data for a YAML entry. Add a description to the commands.
     
  9. Offline

    ceoepts

    Code:
    Console    : 2013-07-08 13:15:32 [SEVERE] Error occurred while enabling cutscenesforlajf v0.1 (Is it up to date?)
    Console    : java.lang.NullPointerException
    Console    :    at me.ceoepts.cutscenes.Cutscenes.onEnable(Cutscenes.java:34)
    Console    :    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
    Console    :    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:375)
    Console    :    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:382)
    Console    :    at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugin(CraftServer.java:311)
    Console    :    at org.bukkit.craftbukkit.v1_5_R3.CraftServer.enablePlugins(CraftServer.java:293)
    Console    :    at net.minecraft.server.MinecraftServer.j(MinecraftServer.java:315)
    Console    :    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:294)
    Console    :    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:254)
    Console    :    at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:159)
    Console    :    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:393)
    Console    :    at net.minecraft.server.ThreadServerApplication.run(SourceFile:573)
    No you dont need data for a yaml entry if you read i said that the secound code worked fine
    Code:
    name: RPGArmor
    version: 0.1
    main: me.ceoepts.rpgarmor.Main
    commands:
      stats:
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  10. Offline

    slayr288

    ceoepts
    How about you try it before you say it doesn't work.
     
  11. Offline

    ceoepts

    Well i think its pointless to try somthing that would probably not work because my RPGArmor plugin worked perfectly with the same yml. So. But sure i can try

    Didnt work:
    Code:
    name: cutscenesforlajf
    version: 0.1
    main: me.ceoepts.cutscenes.Cutscenes
    commands:
      cutscene:
        description: cutscene command
      playc:
        description: cutscene command
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  12. Offline

    lDucks

    You don't need a description for your commands.
     
  13. Offline

    slayr288

    lDucks ceoepts
    Oh nevermind, forgot the entry would just return null.
    Are you sure that the line you showed us is correct as per the stacktrace?
    (Includes package and imports as lines)

    Or

    Your command class doesn't have a constructor of the main class.

    Or

    Your command class doesn't implement CommandExecuter
     
  14. Offline

    ceoepts

    My command class is having a constructor
    Code:
        Cutscenes plugin;
        public CommandExecuter(Cutscenes instance){
            plugin = instance;
        }
    and my command file does implement commandexecuter
    public class CommandExecuter implements CommandExecutor {
     
  15. Offline

    slayr288

    ceoepts
    Try renaming the class so it's not the same name as the class it's implementing.
     
  16. Offline

    ceoepts

    K... I just want to remaind you of that everything worked perfectly yesterday. Havnt changed any code
     
  17. Offline

    afistofirony

    ceoepts Could you try something like the following, please?

    Code:
    Cutscenes cs = new Cutscenes();
     
    @Override
    public void onEnable () {
        getCommand("cutscene").setExecutor(new CommandExecuter(cs));
    }
    It does not share names. CommandExecutor is the interface being implemented, CommandExecuter is the class implementing it. Note the o versus the e.

    EDIT: Fixed indentation error.
     
  18. Offline

    ceoepts

    This is solved remade the plugin and it worked
     
Thread Status:
Not open for further replies.

Share This Page