mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-01 21:17:45 -05:00
Add interruptTrue/Default/False as util methods
This commit is contained in:
@@ -58,6 +58,39 @@ public class CompoundEventResult<T> {
|
||||
return new CompoundEventResult<>(EventResult.interrupt(value), object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the event and stops it from being passed on to other listeners,
|
||||
* denotes the {@code true} outcome and may or may not set an extra data of the event.
|
||||
*
|
||||
* @param object the extra data of the result, this usually is the returning value of the event
|
||||
* @return an event that interrupts the event
|
||||
*/
|
||||
public static <T> CompoundEventResult<T> interruptTrue(T object) {
|
||||
return new CompoundEventResult<>(EventResult.interruptTrue(), object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the event and stops it from being passed on to other listeners,
|
||||
* does not set an outcome and may or may not set an extra data of the event.
|
||||
*
|
||||
* @param object the extra data of the result, this usually is the returning value of the event
|
||||
* @return an event that interrupts the event
|
||||
*/
|
||||
public static <T> CompoundEventResult<T> interruptDefault(T object) {
|
||||
return new CompoundEventResult<>(EventResult.interruptDefault(), object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the event and stops it from being passed on to other listeners,
|
||||
* denotes the {@code false} outcome and may or may not set an extra data of the event.
|
||||
*
|
||||
* @param object the extra data of the result, this usually is the returning value of the event
|
||||
* @return an event that interrupts the event
|
||||
*/
|
||||
public static <T> CompoundEventResult<T> interruptFalse(T object) {
|
||||
return new CompoundEventResult<>(EventResult.interruptFalse(), object);
|
||||
}
|
||||
|
||||
private CompoundEventResult(EventResult result, T object) {
|
||||
this.result = result;
|
||||
this.object = object;
|
||||
|
||||
@@ -56,6 +56,36 @@ public final class EventResult {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the event and stops it from being passed on to other listeners,
|
||||
* and denotes the {@code true} outcome.
|
||||
*
|
||||
* @return an event that interrupts the event
|
||||
*/
|
||||
public static EventResult interruptTrue() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the event and stops it from being passed on to other listeners,
|
||||
* and does not set an outcome.
|
||||
*
|
||||
* @return an event that interrupts the event
|
||||
*/
|
||||
public static EventResult interruptDefault() {
|
||||
return STOP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the event and stops it from being passed on to other listeners,
|
||||
* and denotes the {@code false} outcome.
|
||||
*
|
||||
* @return an event that interrupts the event
|
||||
*/
|
||||
public static EventResult interruptFalse() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private final boolean interruptsFurtherEvaluation;
|
||||
|
||||
private final Boolean value;
|
||||
|
||||
Reference in New Issue
Block a user