diff --git a/Mage/src/main/java/mage/game/GameState.java b/Mage/src/main/java/mage/game/GameState.java index 7dbfeedc9a..22cbccb7f9 100644 --- a/Mage/src/main/java/mage/game/GameState.java +++ b/Mage/src/main/java/mage/game/GameState.java @@ -29,6 +29,8 @@ package mage.game; import java.io.Serializable; import java.util.*; +import java.util.stream.Collectors; + import mage.MageObject; import mage.abilities.*; import mage.abilities.effects.ContinuousEffect; @@ -170,7 +172,7 @@ public class GameState implements Serializable, Copyable { this.watchers = state.watchers.copy(); for (Map.Entry entry : state.values.entrySet()) { if (entry.getValue() instanceof HashSet) { - this.values.put(entry.getKey(), (HashSet) ((HashSet) entry.getValue()).clone()); + this.values.put(entry.getKey(), ((HashSet) entry.getValue()).clone()); } else { this.values.put(entry.getKey(), entry.getValue()); } @@ -882,22 +884,12 @@ public class GameState implements Serializable, Copyable { } public void removeDelayedTriggeredAbility(UUID abilityId) { - for (DelayedTriggeredAbility ability : delayed) { - if (ability.getId().equals(abilityId)) { - delayed.remove(ability); - break; - } - } + delayed.removeIf(ability -> ability.getId().equals(abilityId)); } public List getTriggered(UUID controllerId) { - List triggereds = new ArrayList<>(); - for (TriggeredAbility ability : triggered) { - if (ability.getControllerId().equals(controllerId)) { - triggereds.add(ability); - } - } - return triggereds; + return triggered.stream().filter(triggeredAbility -> triggeredAbility.getControllerId().equals(controllerId)) + .collect(Collectors.toList()); } public DelayedTriggeredAbilities getDelayed() { @@ -1089,10 +1081,7 @@ public class GameState implements Serializable, Copyable { } public int getZoneChangeCounter(UUID objectId) { - if (this.zoneChangeCounter.containsKey(objectId)) { - return this.zoneChangeCounter.get(objectId); - } - return 1; + return zoneChangeCounter.getOrDefault(objectId, 1); } public void updateZoneChangeCounter(UUID objectId) {