Do not use this plugin AND StarCore together. StarCore already provides StarEvents and this plugin is not needed.
This is simply a plugin version to allow other developers and other projects of mine to use it without having to depend on StarCore as it is not always needed.
There are a total of three artifacts
-
Dependency Artifact: This is the base artifact and is what is used for the published maven dependency. Use this to develop against
-
Plugin Artifact: This artifact is a plugin, however it does not have all of the required dependencies and is to be used with the other library plugins like StarMCLib. This only contains the StarEvents code
-
Standalone Artifact: This artifact is what you download here on SpigotMC and is a completely standalone version that has all the dependencies that it requires bundled into the plugin
StarEvents is a library that passes the Bukkit Events into a StarLib IEventBus. This allows for a wide range of flexibility in the event system.
The primary use case and the reason why I made it was to allow listening to parent events that do not have a HandlerList defined. For example, you can listen to the base Event class and you get a listener that listens for all events in just a few lines of code.
This also allows for the use case of having listeners in lambdas.
Again, this is the plugin version, so there is no need to directly call StarEvents.init() and the plugin does that already and handles the listener registration. To use this plugin in your own, it is just the standard way of using it.
The first thing is that there is a Functional Interface called EventListener that adds the ability to create lambdas for a listener.
Below is an example.
Code (Java):
StarEvents.
registerListener
(PlayerJoinEvent.
class, e
-> e.
getPlayer
(
).
sendMessage
(
"Hello from the lambda universe!"
)
)
;
The first argument is the class of the event. This makes it so that casts aren't needed to use the methods within that specific event.
The second argument is the lambda expression.
As of StarEvents 0.2.0, all event detection is dynamic. What happens is that the Jar files for Spigot and Paper are looked at first and all classes that extend org.bukkit.event.Event, have a static getHandlerList() method and are not deprecated are detected and dynamically added to the loader plugin's directory/codegen/StarEventsSpigotEventListener.class. This is generated each time that it is loaded either by the standalone plugin or another plugin like StarCore. These listeners ignore the cancelled flag and are of the MONITOR event priority. Use the StarLib @SubscribeEvent annotation in a custom listener to specify this.
Then StarEvents looks at all plugins except for the plugin that loads StarEvents itself and searches for the same requirements of an Event as above. So StarEvents detects other plugin events and each plugin gets their own listener with the pattern StarEvents%PLUGINNAME%Listener.class in the same folder. These are only regenerated and loaded if the plugin is detected. There will be warnings in console related to this though. The warning below is an example
Code (Text):
[PlaceholderAPI] Loaded class com.stardevllc.starevents.BukkitEventListener from StarEvents v0.2.0 which is not a depend or softdepend of this plugin.
There is not an easy way to fix this though, so it will just have to exist.
This plugin is provided free of charge and under the MIT Open Source License. I will never sell this library anywhere. If you see it being sold, it is not by me and please report any of these cases to me directly.