diff --git a/README.md b/README.md index 27af4c1..f69e3f6 100644 --- a/README.md +++ b/README.md @@ -5,43 +5,57 @@ A simple Java EventManager using lambdas ``` repositories { maven { - name = "jitpack.io" - url = "https://jitpack.io" - } + name = "tigr.dev" + url = "https://maven.tigr.dev" + } } dependencies { - compile "com.github.Tigermouthbear:SimpleEvents:master-SNAPSHOT" + compile "dev.tigr:simpleevents:1.0" } ``` -## Java +## Java Example ``` public class Test { static EventManager EVENT_MANAGER = new EventManager(); // Create new EventManager public static void main(String[] args) { - EVENT_MANAGER.register(new Test()); // Register object to EventManager + EVENT_MANAGER.register(Test.class); // registers static listeners of class + EVENT_MANAGER.unregister(lowest); // unregisters single listener + EVENT_MANAGER.register(lowest); // registers single listener + EVENT_MANAGER.register(new Test()); // registers non-static listeners of object + TestEvent event = EVENT_MANAGER.post(new TestEvent()); // Create event and post it to the EventManager + System.out.println("\n"); System.out.println(event.text); // prints "lowest" System.out.println(event.isCancelled()); // prints false } - @EventHandler - EventListener lowest = new EventListener<>(Priority.LOWEST, event -> { + @EventHandler + private static EventListener lowest = new EventListener<>(Priority.LOWEST, event -> { + System.out.println("lowest called!"); + event.text = "lowest"; event.setCancelled(false); }); - @EventHandler - EventListener highest = new EventListener<>(Priority.HIGHEST, event -> { + @EventHandler + private static EventListener highest = new EventListener<>(Priority.HIGHEST, event -> { + System.out.println("highest called!"); + event.text = "highest"; event.setCancelled(true); }); + + @EventHandler + private EventListener defaulT = new EventListener<>(event -> { + System.out.println("default called!"); + }); } -// TestEvent does not need to extend Event, unless the built in functions of an SimpleEvent Event is needed +// TestEvent does not need to extend Event, unless the built in functions of a SimpleEvent Event is needed class TestEvent extends Event { String text = "original"; } -``` \ No newline at end of file +```