public final class Cause
extends java.lang.Object
For example, if a player fires an arrow that hits an item frame, the player is the initiator, while the arrow is merely controlled by the player to hit the item frame.
| Modifier and Type | Method and Description |
|---|---|
static Cause |
create(java.lang.Object... cause)
Create a new instance with the given objects as the cause,
where the first-most object is the initial initiator and those
following it are controlled by the previous entry.
|
org.bukkit.entity.EntityType |
find(org.bukkit.entity.EntityType... types)
Find the first type matching one in the given array.
|
org.bukkit.block.Block |
getFirstBlock() |
org.bukkit.entity.Entity |
getFirstEntity() |
org.bukkit.entity.Entity |
getFirstNonPlayerEntity() |
org.bukkit.entity.Player |
getFirstPlayer() |
java.lang.Object |
getRootCause() |
boolean |
isIndirect()
Test whether the traced cause is indirect.
|
boolean |
isKnown()
Return whether a cause is known.
|
java.lang.String |
toString() |
static void |
trackParentCause(org.bukkit.metadata.Metadatable target,
java.lang.Object parent)
Add a parent cause to a
Metadatable object. |
static Cause |
unknown()
Create a new instance that indicates that the cause is not known.
|
public boolean isIndirect()
If the cause is indirect, then the root cause may not be notified, for example.
public boolean isKnown()
@Nullable public java.lang.Object getRootCause()
@Nullable public org.bukkit.entity.Player getFirstPlayer()
@Nullable public org.bukkit.entity.Entity getFirstEntity()
@Nullable public org.bukkit.entity.Entity getFirstNonPlayerEntity()
@Nullable public org.bukkit.block.Block getFirstBlock()
@Nullable public org.bukkit.entity.EntityType find(org.bukkit.entity.EntityType... types)
types - an array of typespublic java.lang.String toString()
toString in class java.lang.Objectpublic static Cause create(@Nullable java.lang.Object... cause)
cause - an array of causing objectspublic static Cause unknown()
public static void trackParentCause(org.bukkit.metadata.Metadatable target,
java.lang.Object parent)
Metadatable object.
Note that target cannot be an instance of
Block because create(Object...) will not bother
checking for such data on blocks (because it is relatively costly
to do so).
target - the targetparent - the parent causejava.lang.IllegalArgumentException - thrown if target is an instance of Block