From 451b679323c11b58a1ea56805a640cbd869ec3fa Mon Sep 17 00:00:00 2001
From: sk89q
Date: Mon, 19 Jan 2015 18:28:41 -0800
Subject: [PATCH] Track cause through targets.
Fixes WORLDGUARD-3314.
---
.../sk89q/worldguard/bukkit/cause/Cause.java | 144 ++++++++++--------
.../listener/RegionProtectionListener.java | 2 +-
2 files changed, 82 insertions(+), 64 deletions(-)
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/cause/Cause.java b/src/main/java/com/sk89q/worldguard/bukkit/cause/Cause.java
index 05d3b252..3d226dff 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/cause/Cause.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/cause/Cause.java
@@ -20,23 +20,17 @@
package com.sk89q.worldguard.bukkit.cause;
import com.google.common.base.Joiner;
+import com.google.common.collect.Sets;
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
import org.bukkit.block.Block;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.entity.Tameable;
-import org.bukkit.entity.Vehicle;
+import org.bukkit.entity.*;
import org.bukkit.metadata.Metadatable;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -49,23 +43,36 @@
* is the initiator, while the arrow is merely controlled by the player to
* hit the item frame.
*/
-public class Cause {
+public final 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 static final Cause UNKNOWN = new Cause(Collections.emptyList(), false);
private final List