Fix Cause#isKnown() (#1768)

* Fix Cause#isKnown()

* Grammar

Co-authored-by: wizjany <wizjany@gmail.com>
This commit is contained in:
stonar96 2021-05-15 21:03:55 +02:00 committed by GitHub
parent c1c26360e3
commit c4e76af5f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,26 +90,15 @@ public boolean isIndirect() {
}
/**
* Return whether a cause is known. This method will return true if
* the list of causes is empty or the list of causes only contains
* objects that really are not root causes (i.e primed TNT).
* Return whether a cause is known. This method will return false if
* the list of causes is empty or the root cause is really not known
* (e.g. primed TNT).
*
* @return true if known
*/
public boolean isKnown() {
if (causes.isEmpty()) {
return false;
}
boolean found = false;
for (Object object : causes) {
if (!(object instanceof TNTPrimed) && !(object instanceof Vehicle)) {
found = true;
break;
}
}
return found;
Object object = getRootCause();
return !(object == null || object instanceof TNTPrimed || object instanceof Vehicle);
}
@Nullable