Returning NPE?

Discussion in 'Spigot Plugin Development' started by TheMasteredPanda, Jun 12, 2016.

  1. Aight so, apologises if this is a noob question it's coming up to 2am for me and I'm reluctant to finish this plugin off before I go to bed but my onJoin event in the TownyEconomyEvents is returning a null. How would I go about fixing this?
     
  2. It would help if you posted the error log when you run it...
     
    • Agree Agree x 1
  3. Oh apologises, forgot to add it! xD: http://prntscr.com/bfac5c
     
  4. Are you certain that
    TownyEconomyEvents
    and
    TownyEconomyEvents
    are called first? (Without actual error, all we can do is speculate)
     
  5. Your error and posted code do not line up... Your provided screenshots are saying "}" is causing a NPE..
     
  6. Which constructor do you use? You have 2 variables (getTEA and getTEF) and you are using both of them in the event but you only initialise one of them.
     
  7. My code if it serves to help you help me better.
     
  8. @Lyxnx is correct. You're calling the top constructor, but not the bottom one, so getTEF is never defined. I recommend editing the top constructor to this (and removing the bottom one):
    Code (Text):
        public TownyEconomyEvents(TownyEconomyAddon instance)
        {
            this.getTEA = instance;
            this.getTEF = instance.//getter for getTEF
        }
     
  9. Ahh right, would this work by any chance?

    Code (Text):
        public TownyEconomyEvents(TownyEconomyAddon instance, TownyEconomyFiles instance2)
        {
            this.getTEA = instance;
            this.getTEF = instance2;
        }
     
     
    • Like Like x 1
  10. Yes, this should work. (Assuming you call it with the correct values).