From 7aa27a98006103ffb62cc05b164024384665ada9 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 6 Sep 2015 22:14:35 +0200 Subject: [PATCH] * ManaSpentToCastWatcher - Fixed possible null pointer exception. --- .../watchers/common/ManaSpentToCastWatcher.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Mage/src/mage/watchers/common/ManaSpentToCastWatcher.java b/Mage/src/mage/watchers/common/ManaSpentToCastWatcher.java index 608e809d93..197932e2da 100644 --- a/Mage/src/mage/watchers/common/ManaSpentToCastWatcher.java +++ b/Mage/src/mage/watchers/common/ManaSpentToCastWatcher.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.watchers.common; import mage.Mana; @@ -58,16 +57,16 @@ public class ManaSpentToCastWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) { + if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) { Spell spell = (Spell) game.getObject(event.getTargetId()); - if (this.getSourceId().equals(spell.getSourceId())) { - payment = spell.getSpellAbility().getManaCostsToPay().getPayment(); + if (spell != null && this.getSourceId().equals(spell.getSourceId())) { + payment = spell.getSpellAbility().getManaCostsToPay().getPayment(); } } if (event.getType() == GameEvent.EventType.ZONE_CHANGE && this.getSourceId().equals(event.getSourceId())) { - if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) { - payment = null; - } + if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) { + payment = null; + } } }