Hello. I recently changed something in my plugin and there was a mistake. I can not understand what, but it's because of Adrenalin.getInstance (). Adrenalins.put (p.getName (), 1); Code: @EventHandler public void GUI(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); Inventory inventory = e.getInventory(); if (inventory.getName().equals(c.getName())) { e.setCancelled(true); p.updateInventory(); Adrenalin.getInstance().Adrenalins.put(p.getName(), 1); } } Error: https://pastebin.com/RfgHDZDi Sorry for my english, he's not the best.
Perhaps some research on the Singleton design pattern will do you some good, in the mean time check this tutorial out: http://www.java2novice.com/java_constructor_examples/singleton/
I can not understand. I'm doing everything right, but it does not work. I will soon have a brain explode!
@ewrs The best way to go about initializing your instance is simply doing it in the onEnable method() Code: public void onEnable() { //SOME CODE HERE instance = this; //OTHER CODE HERE }
This would give him an instance of his plugin, but not of the Adrenalin class he wants. In the link I provided there is literally the code he needs.
So tnank you. I figured it out. Only I can not understand why the plug-in does not register events ... I wrote everything correctly. In Adrenalin there is a Listener getServer().getPluginManager().registerEvents(new Adrenalin(), this); I DO NOT UNDERSTAND! Now after all this I have problems with events! If you remove from that code, problems with ClickEvent AGAIN!
Are you registering this listener in Adrenalin class or your main class (the one that extends JavaPlugin)?