How to reference HashMap from Main class

Discussion in 'Bukkit Help' started by soloyolorolo123, Jun 22, 2020.

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

    soloyolorolo123

    Like the title says, how do I reference a HashMap from Main JavaPlugin class.

    Heres my code:

    Main class: https://pastebin.com/MpfVu07q
    Line 45- adding to the hashmap
    Line 321 - onEnable with plugin reference

    custom_mob class (referencing main class): https://pastebin.com/erAcmKwR
    Line 141 - attempt to access hashmap I get a null error, despite the fact that if I access it from the main class
    it is not null, did some debugging to find this.

    custom_item class (in case you need it): https://pastebin.com/kryCPz9L

    Any help is greatly appreciated, if its a stupid mistake I apologize for my ignorance.
     
  2. Offline

    Machine Maker

    Well the variable 'plugin' in your main class is never set to anything. So any reference to it would be null. So your issue isn't the hashmap being null, its the plugin reference being null. Also, please follow Java naming conventions.
     
  3. Offline

    soloyolorolo123

    Line 324 in the main class onEnable function, plugin = this
     
  4. Offline

    KarimAKL

    @soloyolorolo123 That initialization is after giving the null reference to the "custom_mob" class at line 323.
     
Thread Status:
Not open for further replies.

Share This Page