mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-12 11:21:34 +01:00
Limit the cause chain to 40 items.
This commit is contained in:
parent
73dea11de2
commit
2a2b2f6f64
@ -35,6 +35,8 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -49,8 +51,10 @@
|
||||
*/
|
||||
public class Cause {
|
||||
|
||||
private static final Logger log = Logger.getLogger(Cause.class.getCanonicalName());
|
||||
private static final String CAUSE_KEY = "worldguard.cause";
|
||||
private static final Cause UNKNOWN = new Cause(Collections.emptyList());
|
||||
private static final int MAX_CAUSE_LENGTH = 40;
|
||||
|
||||
private final List<Object> causes;
|
||||
|
||||
@ -162,6 +166,13 @@ public String toString() {
|
||||
* @param element an array of objects
|
||||
*/
|
||||
private static void expand(List<Object> list, @Nullable Object ... element) {
|
||||
if (list.size() >= MAX_CAUSE_LENGTH) {
|
||||
log.log(Level.WARNING, "While discovering the true cause of an event, the chain of " +
|
||||
"causes exceeded the limit (" + MAX_CAUSE_LENGTH + "). This could be " +
|
||||
"caused by a circular cause (arrow's shooter = arrow).", new RuntimeException());
|
||||
return;
|
||||
}
|
||||
|
||||
if (element != null) {
|
||||
for (Object o : element) {
|
||||
if (o == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user