Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigermouthbear committed Jun 17, 2020
2 parents ec6745d + 1321f92 commit b0388d9
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestEvent> lowest = new EventListener<>(Priority.LOWEST, event -> {
@EventHandler
private static EventListener<TestEvent> lowest = new EventListener<>(Priority.LOWEST, event -> {
System.out.println("lowest called!");
event.text = "lowest";
event.setCancelled(false);
});
@EventHandler
EventListener<TestEvent> highest = new EventListener<>(Priority.HIGHEST, event -> {
@EventHandler
private static EventListener<TestEvent> highest = new EventListener<>(Priority.HIGHEST, event -> {
System.out.println("highest called!");
event.text = "highest";
event.setCancelled(true);
});
@EventHandler
private EventListener<TestEvent> 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";
}
```
```

0 comments on commit b0388d9

Please sign in to comment.