diff --git a/Mage/src/main/java/mage/watchers/Watcher.java b/Mage/src/main/java/mage/watchers/Watcher.java index 14f2323a38..2b75cba4d8 100644 --- a/Mage/src/main/java/mage/watchers/Watcher.java +++ b/Mage/src/main/java/mage/watchers/Watcher.java @@ -1,14 +1,12 @@ - package mage.watchers; -import mage.constants.WatcherScope; -import mage.game.Game; -import mage.game.events.GameEvent; -import org.apache.log4j.Logger; - import java.io.Serializable; import java.lang.reflect.*; import java.util.*; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import org.apache.log4j.Logger; /** * watches for certain game events to occur and flags condition @@ -24,7 +22,6 @@ public abstract class Watcher implements Serializable { protected boolean condition; protected final WatcherScope scope; - public Watcher(WatcherScope scope) { this.scope = scope; } @@ -114,7 +111,7 @@ public abstract class Watcher implements Serializable { if (field.getType() == Set.class) { ((Set) field.get(watcher)).clear(); ((Set) field.get(watcher)).addAll((Set) field.get(this)); - } else if (field.getType() == Map.class) { + } else if (field.getType() == Map.class || field.getType() == HashMap.class) { ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); Type valueType = parameterizedType.getActualTypeArguments()[1]; if (valueType.getTypeName().contains("Set")) { @@ -126,8 +123,7 @@ public abstract class Watcher implements Serializable { set.addAll(e.getValue()); target.put(e.getKey(), set); } - } - else if (valueType.getTypeName().contains("List")) { + } else if (valueType.getTypeName().contains("List")) { Map> source = (Map>) field.get(this); Map> target = (Map>) field.get(watcher); target.clear(); @@ -136,8 +132,7 @@ public abstract class Watcher implements Serializable { list.addAll(e.getValue()); target.put(e.getKey(), list); } - } - else if (valueType.getTypeName().contains("Map")) { + } else if (valueType.getTypeName().contains("Map")) { Map> source = (Map>) field.get(this); Map> target = (Map>) field.get(watcher); target.clear(); @@ -147,8 +142,7 @@ public abstract class Watcher implements Serializable { target.put(e.getKey(), map); } - } - else { + } else { ((Map) field.get(watcher)).putAll((Map) field.get(this)); } } else if (field.getType() == List.class) {