Class Cause
java.lang.Object
org.spongepowered.api.event.Cause
A cause represents the reason or initiator of an event.
For example, if a block of sand is placed where it drops, the block of sand would create a falling sand entity, which then would place another block of sand. The block place event for the final block of sand would have the cause chain of the block of sand -> falling sand entity.
It is not possible to accurately describe the chain of causes in all scenarios so a best effort approach is generally acceptable. For example, a player might press a lever, activating a complex Redstone circuit, which would then launch TNT and cause the destruction of some blocks, but tracing this event would be too complicated and thus may not be attempted.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionOptional<?> Gets the object immediately after the object that is an instance of theClasspassed in.all()<T> List<T> Optional<?> Gets the object immediately before the object that is an instance of theClasspassed in.static Cause.Builderbuilder()Creates a newCause.Builderto make a newCause.booleanChecks if this cause contains of any of the providedObject.booleancontainsType(Class<?> target) Returns whether the target class matches any object of thisCause.context()Gets the event context relating to this cause.boolean<T> Optional<T> Gets the firstTobject of thisCause, if available.inthashCode()iterator()<T> Optional<T> Gets the last object instance of theClassof typeT.static Causeof(EventContext ctx, Iterable<Object> iterable) Constructs a new cause with the specified event context and causes.static Causeof(EventContext ctx, Object cause) Constructs a new cause with the specified event context and cause.static Causeof(EventContext ctx, Object cause, Object... causes) Constructs a new cause with the specified event context and causes.root()Gets the rootObjectof this cause.toString()Creates a newCausewhere the objects are added at the end of the cause array of objects.Creates a newCausewhere the objects are added at the end of the cause array of objects.Creates a newCausewhere the objects are added at the end of the cause array of objects.Merges this cause with the other cause.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
builder
Creates a newCause.Builderto make a newCause.- Returns:
- The new builder
-
of
Constructs a new cause with the specified event context and cause.- Parameters:
ctx- The event contextcause- The direct object cause- Returns:
- The constructed cause
-
of
Constructs a new cause with the specified event context and causes.- Parameters:
ctx- The event contextcause- The direct object causecauses- Other associated causes- Returns:
- The built cause
-
of
Constructs a new cause with the specified event context and causes.- Parameters:
ctx- The event contextiterable- The associated causes- Returns:
- The built cause
-
context
Gets the event context relating to this cause.- Returns:
- The event context
-
root
-
first
-
last
-
before
-
after
-
containsType
-
contains
Checks if this cause contains of any of the providedObject. This is the equivalent to checking based onequals(Object)for each object in this cause.- Parameters:
object- The object to check if it is contained- Returns:
- True if the object is contained within this cause
-
allOf
-
noneOf
-
all
-
with
-
with
-
with
-
with
-
iterator
-
equals
-
hashCode
-
toString
-