From 8c0f2b9bf8c7395f2724251047afb73dc28729b2 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Mon, 28 Aug 2023 22:42:34 -0400 Subject: [PATCH] Followup cleanup to manaCosts access in AbilityImpl (#11060) (a relic of the rejected proposal to lazily instantiate manaCosts was left in #9625 and is removed here, allowing the fields to be made final) --- .../main/java/mage/abilities/AbilityImpl.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index d9468b5a9e0..3fd5caa383f 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -56,8 +56,8 @@ public abstract class AbilityImpl implements Ability { protected AbilityType abilityType; protected UUID controllerId; protected UUID sourceId; - private ManaCosts manaCosts; - private ManaCosts manaCostsToPay; + private final ManaCosts manaCosts; + private final ManaCosts manaCostsToPay; private Costs costs; protected Modes modes; // access to it by GetModes only (it can be overridden by some abilities) protected Zone zone; @@ -83,7 +83,7 @@ public abstract class AbilityImpl implements Ability { protected String appendToRule = null; protected int sourcePermanentTransformCount = 0; - public AbilityImpl(AbilityType abilityType, Zone zone) { + protected AbilityImpl(AbilityType abilityType, Zone zone) { this.id = UUID.randomUUID(); this.originalId = id; this.abilityType = abilityType; @@ -879,9 +879,6 @@ public abstract class AbilityImpl implements Ability { if (manaCost == null) { return; } - if (manaCostsToPay == null) { - manaCostsToPay = new ManaCostsImpl<>(); - } if (manaCost instanceof ManaCosts) { manaCostsToPay.addAll((ManaCosts) manaCost); } else { @@ -894,14 +891,6 @@ public abstract class AbilityImpl implements Ability { if (manaCost == null) { return; } - - if (manaCosts == null) { - manaCosts = new ManaCostsImpl<>(); - } - if (manaCostsToPay == null) { - manaCostsToPay = new ManaCostsImpl<>(); - } - manaCosts.add(manaCost); manaCostsToPay.add(manaCost); }