Solved NPE on event register

Discussion in 'Spigot Plugin Development' started by Sp1goted, Sep 15, 2019.

  1. Im posting this here cos I have never seen anything like this before and am slightly confused why Im getting it. I have 3 events to handle the mining on my server (because I am using packets and such to do chance the default mining) and one of my events (the last one to register) is returning an NPE. Any suggestions?

    Error Screenshot:
    [​IMG]

    Solved: I had to redo the Handler List method form the custom event that was being used in the class that was failing to enable.
     
    #1 Sp1goted, Sep 15, 2019
    Last edited: Sep 15, 2019
  2. What's line 44 in Prisons.java? You're passing a null reference to something.

    Also, here's how to read the error.
     
  3. I know how to read a stack trace, I've been doing this a while.

    Line 44 in Prisons is the ranks manager, its not null as its fully registering the list of ranks (and outputting to the console how many that are registered) before the event manager registers
     
  4. If nothing was null, it wouldn't throw a null pointer. What does line 74 in your EventManager class look like?
     
  5. Not meant to be a slur on your good name, just a friendly mention in the case that you were new (account's only 3 months old, 20-some-odd posts, I did what I could with what information I had).

    It's likely that a rank you're registering/outputting has a null element that isn't being considered (as above said, EventManager.java:74). The error does exist for a reason.
     
  6. The event itself doesnt actually have anything to do with rank manager which is why im confused this is causing an issues. Ive output all info that the rank manager is loading in and nothing appears wrong (everything is loading correctly from the file to the object).

    'prisons.getServer().getPluginManager().registerEvents(this.blockHitListener, prisons);'
     
  7. Well either this.blockHitListener or prisons is null, SimplePluginManager throws a null pointer for either.
     
  8. Assuming this is EventManager:74, we'd need to make sure the 'prisons' instance has been instantiated as well as the blockHitListener. Where have you done that? (I see in the first screenshot that you debugged the object for blockHitListener -- it didn't appear to be null, so what about the prisons instance?)
     
  9. Debugging prisons from inside of my EventManager class outputs 'Prisons v0.0.1' which is correct therefor it cannot be null.

    EDIT: I can even successfully debug prisons from inside of the event class that is throwing the error on server start.
     
  10. And did you indeed debug blockHitListener from inside the event correct class?

    Edit: brain oof
     
  11. @Sp1goted If that's the case, source code would be needed to determine further action (outside of recommending that you are running the up-to-date code).