Solved ClickError

Discussion in 'Plugin Development' started by ewrs, Sep 6, 2018.

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

    ewrs

    Hello. I had this error after I put HashMap Adrenalins and GUI (ClickEvent) in different classes. I made them normal access. If you understand how to do it right, say EXAMPLE! And not just words, I do not always understand!

    https://pastebin.com/LYqvWkCA

    Forgive my English.
     
  2. Online

    timtower Administrator Administrator Moderator

    @ewrs Please post your code. We can't do anything with just the error.
    And put the map in the main class, then make a getter for it.
     
  3. Offline

    ewrs

    MAIN: NULL
    AdrenalinMechanic: NULL
    The GUI simply adds the player. Put

    But why do I need getters? And how can I apply them in this case ??
     
    Last edited: Sep 7, 2018
  4. Online

    timtower Administrator Administrator Moderator

    @ewrs Getters and non static are basic java. Not gonna explain that.
    Why do you make instances and you register different ones?

    And your code doesn't even have the line with the error...
     
  5. Offline

    ewrs

    and what should I do? .. I tried all my options.

    I did getter and setter, but the error repeats ... What do I do, @timtower?

    https://pastebin.com/tuZhfc3F
     
    Last edited: Sep 6, 2018
  6. @ewrs
    The main issue is you're not initializing the hashmap, its null you need to do
    public HashMap<String, Integer> Adrenalins = new HashMap<String, Integer>();
    also just another thing i noticed in your main class
    this.getServer().getPluginManager().registerEvents(new NokdaynMechanic(), (Plugin)this);
    you don't need to cast Plugin to your main class because it extends JavaPlugin
    also you don't need new NokdaynMechanic() just use the variable you created at the top
    so it should be
    this.getServer().getPluginManager().registerEvents(NokdaynMechanic, this);
    same goes for all the other events
     
  7. Offline

    ewrs

    Thank you very much! Now everything works according to the idea. :)
     
Thread Status:
Not open for further replies.

Share This Page