Skip to content

Commit

Permalink
Merge pull request #3 from 7orivorian/3.3.0
Browse files Browse the repository at this point in the history
3.3.0
  • Loading branch information
7orivorian authored Jul 3, 2024
2 parents 2822488 + b28f47c commit c2ed230
Show file tree
Hide file tree
Showing 20 changed files with 890 additions and 240 deletions.
674 changes: 670 additions & 4 deletions .gitignore

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Lightweight Java event library created and maintained by [7orivorian](https://gi
<dependency>
<groupId>com.github.7orivorian</groupId>
<artifactId>Wraith</artifactId>
<version>3.2.2</version>
<version>3.3.0</version>
</dependency>
```

Expand All @@ -51,13 +51,13 @@ repositories {

```gradle
dependencies {
implementation 'com.github.7orivorian:Wraith:3.2.2'
implementation 'com.github.7orivorian:Wraith:3.3.0'
}
```

### Other

Download a `.jar` file from [releases](https://github.com/7orivorian/Wraith/releases/tag/3.2.2)
Download a `.jar` file from [releases](https://github.com/7orivorian/Wraith/releases/tag/3.3.0)

# Building

Expand Down Expand Up @@ -99,6 +99,7 @@ Once you've defined your subscriber, you can subscribe it to an event bus direct
public class Consts {
private static final IEventBus EVENT_BUS = new EventBus();
}

public class ExampleSubscriber extends Subscriber {

public ExampleSubscriber() {
Expand Down Expand Up @@ -200,8 +201,7 @@ public class ExampleSubscriber extends Subscriber {
<details>
<summary><i>Details...</i></summary>

To dispatch an event to an event bus, call one of the `dispatch` methods defined in any `IEventBus`
implementation, passing your event as a parameter:
To dispatch an event, call one of the `dispatch` methods defined in `EventBus`, passing your event as a parameter:

```java
import me.tori.wraith.event.staged.EventStage;
Expand Down
8 changes: 4 additions & 4 deletions examples/java/me/tori/example/expanded/ExampleEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@

package me.tori.example.expanded;

import me.tori.wraith.event.cancelable.CancelableEvent;
import me.tori.wraith.event.staged.EventStage;
import me.tori.wraith.event.staged.IStagedEvent;
import me.tori.wraith.event.status.StatusEvent;

/**
* Example event.
* <p>Last updated for version <b>3.1.0</b>
*
* @author <b><a href="https://github.com/7orivorian">7orivorian</a></b>
* @author <a href="https://github.com/7orivorian">7orivorian</a>
* @since 1.0.0
*/
class ExampleEvent extends CancelableEvent implements IStagedEvent {
class ExampleEvent extends StatusEvent implements IStagedEvent {

private String message;
private final EventStage stage;
Expand Down
5 changes: 2 additions & 3 deletions examples/java/me/tori/example/expanded/ExampleListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@

/**
* Example listener.
* <p>Last updated for version <b>3.1.0</b>
*
* @author <b><a href="https://github.com/7orivorian">7orivorian</a></b>
* @since <b>1.0.0</b>
* @author <a href="https://github.com/7orivorian">7orivorian</a>
* @since 1.0.0
*/
class ExampleListener extends EventListener<ExampleEvent> {

Expand Down
10 changes: 5 additions & 5 deletions examples/java/me/tori/example/expanded/ExampleMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import me.tori.wraith.event.staged.EventStage;

/**
* Example program
* <p>Last updated for version <b>3.1.0</b>
* Example program.
*
* @author <b><a href="https://github.com/7orivorian">7orivorian</a></b>
* @author <a href="https://github.com/7orivorian">7orivorian</a>
* @since 1.0.0
*/
class ExampleMain {

Expand All @@ -44,15 +44,15 @@ public static void main(String[] args) {

EVENT_BUS.dispatch(event1);

if (!event1.isCanceled()) {
if (!event1.isSuppressed()) {
System.out.println(event1.getMessage());
}

ExampleEvent event2 = new ExampleEvent(EventStage.POST);

EVENT_BUS.dispatch(event2);

if (!event2.isCanceled()) {
if (!event2.isSuppressed()) {
System.out.println(event2.getMessage());
}
}
Expand Down
5 changes: 2 additions & 3 deletions examples/java/me/tori/example/expanded/ExampleSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@

/**
* Example subscriber.
* <p>Last updated for version <b>3.1.0</b>
*
* @author <b><a href="https://github.com/7orivorian">7orivorian</a></b>
* @since <b>1.0.0</b>
* @author <a href="https://github.com/7orivorian">7orivorian</a>
* @since 1.0.0
*/
class ExampleSubscriber extends Subscriber {

Expand Down
33 changes: 8 additions & 25 deletions examples/java/me/tori/example/simple/SimpleExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
package me.tori.example.simple;

import me.tori.wraith.bus.EventBus;
import me.tori.wraith.event.cancelable.CancelableEvent;
import me.tori.wraith.event.status.StatusEvent;
import me.tori.wraith.listener.LambdaEventListener;
import me.tori.wraith.subscriber.Subscriber;

/**
* One-class example
* <p>
* Last updated for version <b>3.1.0</b>
* One-class example.
*
* @author <b><a href="https://github.com/7orivorian">7orivorian</a></b>
* @author <a href="https://github.com/7orivorian">7orivorian</a>
*/
class SimpleExample {

Expand All @@ -45,38 +43,23 @@ public static void main(String[] args) {
// Subscribe to the event bus
bus.subscribe(subscriber);

SimpleEvent event;

// Create a simple event
// This event will be canceled, see the lambda in SimpleSubscriber to know why ;P
event = new SimpleEvent("Pie is gross!");

if (!bus.dispatch(event)) {
// Only log the message if our event isn't canceled
System.out.println(event.getMessage());
}
SimpleEvent event = new SimpleEvent("Pie is delicious <3");

event = new SimpleEvent("Pie is delicious <3");
if (!bus.dispatch(event)) {
System.out.println(event.getMessage());
}
// Dispatch our event
bus.dispatch(event);
}

private static final class SimpleSubscriber extends Subscriber {

public SimpleSubscriber() {
registerListener(
new LambdaEventListener<>(SimpleEvent.class, event -> {
if (event.getMessage().contains("gross")) {
// Pie is not gross, so we cancel this event, preventing it from being written to the console
event.cancel();
}
})
new LambdaEventListener<>(SimpleEvent.class, event -> System.out.println(event.getMessage()))
);
}
}

private static final class SimpleEvent extends CancelableEvent {
private static final class SimpleEvent extends StatusEvent {

private final String message;

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<groupId>me.tori</groupId>
<artifactId>Wraith</artifactId>
<packaging>jar</packaging>
<version>3.2.2</version>
<version>3.3.0</version>

<licenses>
<license>
Expand Down
Loading

0 comments on commit c2ed230

Please sign in to comment.