Register Events across classes

Discussion in 'Spigot Plugin Development' started by Camoleopard, Jun 29, 2015.

  1. I am simply trying to register events between classes, I have an event class and a main class, how would I register my event class in my main class, I have tried
    Code (Text):
     bukkit.getServer().getPluginManager.registerEvents(new Event(), this)
    if I could get some help that would be great!
  2. Looks fine to me for the code you posted. What's the issue?
  3. That should work. What exactly is the error?

    Actually, did you add the semi-colon behind that line of code? (Just to be sure, as it lacks in the provided code)

    And also the Event class should implement Listener.

    Also don't forget the @EventHandler annotation (Sorry for the member called EventHandler); can be a pain to figure out why an event is not fired, when you forgot something this small.
  4. I think he is missing a constructor in his class that he is trying to register like this

    Code (Text):
    Main main;

        public <Yourclasshere>(Main main) {
            this.main = main;
  5. The issue I am getting is that it is simply not registering, my event handler in my other class is not being registered therefore nothing is happening in my event. I thought I had registered this event right but it doesn't seem so.
  6. There is no need for that; hell, a static getter would work just fine for something like that.
  7. Put the code of your event class.
    • Agree Agree x 1
  8. All is ok, it seemed as though I had spelt my menu name wrong, so it was not picking it up.