different executors for different events

Discussion in 'Spigot Plugin Development' started by TheCreeperCow, Apr 19, 2017.

  1. Hello im wondering how would i go about setting the executor for the event inventoryclick to the class InventoryEvent and onChat event to ChatEvent class
     
  2. Aren't you confusing something here? Executers are for Commands.

    If you want to run code on events you are using Listeners. You can easily write a class for only chat events and one for inventory events and so on. Register each class as a Listener (it has to implement org.bukkit.event.Listener) and then only listen for the specific events you want inside the classes.
     
  3. But dont i need to define Bukkit.getPluginManager().registerEvents(New ChatEvent, this) for each listener
     
  4. I still need an answer
     
  5. You need one listener registration in your main class (the class that extends JavaPlugin) for each class that implements Listener, not for every listener itself in that class.
     
  6. Yes, like i said above: you have to register each Listener.

    Edit: seeing the post above: with Listener I mean the class that implements org.bukkit.event.Listener!

    inside that class are just a few methods with @EventHandler I wouldn't call each of those methods a listener...