Null pointer across plugins

Discussion in 'Spigot Plugin Development' started by Remy2402, Jul 7, 2017.

  1. Heya,

    I am currently running 2 plugins, a core plugin that handles SQL, player accounts and more. I also have my hub plugin that should be using the core plugins methods to get those player accounts.

    Right now, when a player's profile is retrieved on join, it stores it in a HashMap so it doesn't need to query the database every single time it needs player data. I also intended to use this HashMap to retrieve player profiles from other plugins but when I do so, I receive a null pointer exception. Is there something I have done wrong there already? Code can be provided if required but if there is already a problem identifiable from what I have said, let me know.

    Thanks in advance.
     
  2. How are you trying to access this hashmap from your other project?
     
  3. If your getting a null whenever your trying to get a value then that means the key doesnt exist
     
  4. It definitely does exist. The plugin that holds the keys/hashmap can access it but when the other plugin tries to it does not work
     
  5. you can say it is null or not if you debug your plugin
    Code (Java):
    // validate if null {
       System.out.print(" it is null " );
     } else {
        System.out.print(" it is not " );
    }
     
  6. Using libraries of other plugins aren't the reason for null pointer exceptions. NPE is caused when you try to access a null value, so that's what's occurring here. Perhaps your method of actually getting the plugin is null?


    Sent from my iPhone using Tapatalk
     
    • Agree Agree x 1