Hey Spigot-community! Currently I had to write a lot of code like this: Code (Text): plugin.getServer().getPluginManager().registerEvents(new org.bukkit.event.Listener() { @EventHandler public void onSomething(MyEvent e) { if(someCondition) e.setCancelled(true); } }, plugin); And I got really pissed about it. So I created a small API for simplifying listener like this. Code (Text): eventApi.cancelIf(MyEvent.class, e -> myCondition); If you don't want to cancel the event but just listen for it, you can use this method: Code (Text): eventApi.listen(MyEvent.class, e -> doSomething()); If you want to use this library, download/clone and compile it from https://github.com/NyxMC/SimpleEventAPI or just copy the classes in your project.
If you're using lambdas to do event listening you're generally doing something wrong, but I could definitely see this being useful for smaller projects. Nice resource.
Why? Imagine an gamemode where players may not break blocks until the game has started. Code (Text): eventApi.cancelIf(BlockBreakEvent.class, e -> !hasStarted())
Is cancelIf the only method? Where can the documentation be found? And personally, i think an API like this is kinda silly and unnceccecary.
The code contains javadocs. There are methods for canceling and listening for events. If you have no need for such an API, don't use it.