Events in second class

Hi, I have a problem…

I have a second class that houses an event. But for some reason it’s not running. I do only need to add the “@Subscribe” above it correct? Or do I have to start it from my main class somehow?

And is there a way to get when a player throws something? Like an egg or a snowball?

Regards Bumi.

You need to register an instance of the class

game.getEventManager().register(MyPlugin.getInstance(), new MyEventHandler());

Where MyPlugin is the plugin main class (annotated with @Plugin) and MyEventHandler is the event handler you want to receive events (methods annotated with @Subscribe)

There is a ProjectileLaunchEvent.
Check the source of the event (getSource()) to see whether it’s a player. The projectile that was launched is getLaunchedProjectile()

And make shure that the events you want to subscribe to are already implemented. Because some events aren’t implamented yet and this could cause that issue too :]

If you are registering the second event handler class from your main plugin class, it is easier:

game.getEventManager().register(this, new MyEventHandler());

(this refers to the plugin instance)

Thank you for your answers. It helped me allot! :smiley:

It’s all in the docs :slight_smile:

Hi, where can I check for which ones are implemented or not?
Thanks :slight_smile:

I believe this is still a live tracker.

Yep. You ninja’d me right there :stuck_out_tongue:

oh, xD. I didn’t think I even replied that fast lol

Fast answers. Thank you :smiley:

Welcome to Sponge Forums

…where we have a bunch of dedicated zombies without a life answering questions 24/7 :stuck_out_tongue:


where the ui is clean and the jdocs pretty


I guess ProjectileLaunchEvent is not implemented yet. It doesn’t fire… So my plugin has to wait I guess :smiley:

ProjectileLaunchEvent isn’t implemented, you’re right.

You’re better off looking at this progress tracker: