Package com.griefdefender.api.event
Class EventCause
java.lang.Object
com.griefdefender.api.event.EventCause
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()Gets anListof all causes within thisEventCause.<T> List<T> Gets anof all objects that are instances of the giveninvalid reference
ImmutableListClasstypeT.Optional<?> Gets the object immediately before the object that is an instance of theClasspassed in.static EventCause.Builderbuilder()Creates a newEventCause.Builderto make a newEventCause.booleanChecks if this cause contains of any of the providedObject.booleancontainsType(Class<?> target) Returns whether the target class matches any object of thisEventCause.boolean<T> Optional<T> Gets the firstTobject of thisEventCause, if available.inthashCode()iterator()<T> Optional<T> Gets the last object instance of theClassof typeT.static EventCauseConstructs a new cause with the specified event context and causes.static EventCauseConstructs a new cause with the specified event context and cause.static EventCauseConstructs a new cause with the specified event context and causes.root()Gets the rootObjectof this cause.toString()with(EventCause cause) Merges this cause with the other cause.Creates a newEventCausewhere the objects are added at the end of the cause array of objects.Creates a newEventCausewhere the objects are added at the end of the cause array of objects.Creates a newEventCausewhere the objects are added at the end of the cause array of objects.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
builder
Creates a newEventCause.Builderto make a newEventCause.- Returns:
- The new builder
-
of
Constructs a new cause with the specified event context and cause.- Parameters:
cause- The direct object cause- Returns:
- The constructed cause
-
of
Constructs a new cause with the specified event context and causes.- Parameters:
cause- The direct object causecauses- Other associated causes- Returns:
- The built cause
-
of
Constructs a new cause with the specified event context and causes.- Parameters:
iterable- The associated causes- Returns:
- The built cause
-
root
Gets the rootObjectof this cause.- Returns:
- The root object cause for this cause
-
first
Gets the firstTobject of thisEventCause, if available.- Type Parameters:
T- The type of object being queried for- Parameters:
target- The class of the target type- Returns:
- The first element of the type, if available
-
last
Gets the last object instance of theClassof typeT.- Type Parameters:
T- The type of object being queried for- Parameters:
target- The class of the target type- Returns:
- The last element of the type, if available
-
before
Gets the object immediately before the object that is an instance of theClasspassed in.- Parameters:
clazz- The class of the object- Returns:
- The object
-
after
Gets the object immediately after the object that is an instance of theClasspassed in.- Parameters:
clazz- The class to type check- Returns:
- The object after, if available
-
containsType
Returns whether the target class matches any object of thisEventCause.- Parameters:
target- The class of the target type- Returns:
- True if found, false otherwise
-
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
Gets anof all objects that are instances of the giveninvalid reference
ImmutableListClasstypeT.- Type Parameters:
T- The type of objects to query for- Parameters:
target- The class of the target type- Returns:
- An immutable list of the objects queried
-
noneOf
- Parameters:
ignoredClass- The class of object types to ignore- Returns:
- The list of objects not an instance of the provided class
-
all
Gets anListof all causes within thisEventCause.- Returns:
- An immutable list of all the causes
-
with
Creates a newEventCausewhere the objects are added at the end of the cause array of objects.- Parameters:
additional- The additional object to add- Returns:
- The new cause
-
with
Creates a newEventCausewhere the objects are added at the end of the cause array of objects.- Parameters:
additional- The additional object to addadditionals- The remaining objects to add- Returns:
- The new cause
-
with
Creates a newEventCausewhere the objects are added at the end of the cause array of objects.- Parameters:
iterable- The additional objects- Returns:
- The new cause
-
with
Merges this cause with the other cause.- Parameters:
cause- The cause to merge with this- Returns:
- The new merged cause
-
iterator
-
equals
-
hashCode
public int hashCode() -
toString
-