Package xyz.janboerman.scalaloader.event
Interface EventExecutor<L extends Listener,E extends Event>
- Type Parameters:
L
- the listener typeE
- the event type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An event executor. Can be implemented using a lambda expression in your ScalaPlugin.
- See Also:
- Implementation Note:
This interface CANNOT be implemented by classes that are not loaded through the
ScalaPluginClassLoader
, which basically means you can't use this from a JavaPlugin. Use Bukkit's Listener/EventHandler reflection api instead!public class MyListener implements org.bukkit.event.Listener { @org.bukkit.event.EventHandler public void onEvent(SomeScalaPluginEvent event) { //use the event } }
Alternatively you can use Bukkit's EventExecutor api like so:
org.bukkit.plugin.EventExecutor = (listener, bukkitEvent) -> { SomeScalaPluginEvent event = (SomeScalaPluginEvent) (Object) bukkitEvent; //use the event }
This will work because at runtime all events defined by ScalaPlugins will extend org.bukkit.event.Event instead of xyz.janboerman.scalaloader.event.Event. DO NOT EVER CAST TO xyz.janboerman.scalaloader.event.Event, use java.lang.Object instead!
-
Method Summary
-
Method Details
-
execute
The callback method that is executed when the event is called.- Parameters:
listener
- the listenerevent
- the event
-