diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 008a3b654a..3437772294 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -538,7 +538,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { // Always hide not hidden popup window or enlarged card view if a frame is set to active try { ActionCallback callback = Plugins.instance.getActionCallback(); - if (callback != null && callback instanceof MageActionCallback) { + if (callback instanceof MageActionCallback) { ((MageActionCallback) callback).hideEnlargedCard(); } Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER); diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java index 2f7f69998e..329ff3ec0e 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java @@ -319,7 +319,7 @@ public class DialogManager extends JComponent implements MouseListener, if (e.getButton() == MouseEvent.BUTTON1) { j = (JComponent) getComponentAt(e.getX(), e.getY()); - if (j != null && j instanceof DialogContainer) { + if (j instanceof DialogContainer) { rec = j.getBounds(); bDragged = true; mx = e.getX(); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java index bea5f97b11..fd53051191 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java @@ -530,7 +530,7 @@ public class MageBook extends JComponent { Class c = Class.forName(className); Constructor cons = c.getConstructor(); Object newToken = cons.newInstance(); - if (newToken != null && newToken instanceof mage.game.permanent.token.Token) { + if (newToken instanceof Token) { ((Token) newToken).setExpansionSetCodeForImage(set); ((Token) newToken).setOriginalExpansionSetCode(set); ((Token) newToken).setTokenType(token.getType()); @@ -580,7 +580,7 @@ public class MageBook extends JComponent { Class c = Class.forName(className); Constructor cons = c.getConstructor(); Object newEmblem = cons.newInstance(); - if (newEmblem != null && newEmblem instanceof mage.game.command.Emblem) { + if (newEmblem instanceof Emblem) { ((Emblem) newEmblem).setExpansionSetCodeForImage(set); emblems.add((Emblem) newEmblem); @@ -637,7 +637,7 @@ public class MageBook extends JComponent { Class c = Class.forName(className); Constructor cons = c.getConstructor(); Object newPlane = cons.newInstance(); - if (newPlane != null && newPlane instanceof mage.game.command.Plane) { + if (newPlane instanceof Plane) { ((Plane) newPlane).setExpansionSetCodeForImage(set); planes.add((Plane) newPlane); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java index c2b24748e3..20e6513c1d 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java @@ -369,7 +369,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid { if (!card.getId().equals(bigCard.getCardId())) { if (!MageFrame.isLite()) { Image image = Plugins.instance.getOriginalImage(card); - if (image != null && image instanceof BufferedImage) { + if (image instanceof BufferedImage) { // XXX: scaled to fit width bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<>(), false); } else { diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index 4d69a16ce8..344e62c1b6 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -617,7 +617,7 @@ public class MageActionCallback implements ActionCallback { } private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) { - if (image != null && image instanceof BufferedImage) { + if (image instanceof BufferedImage) { // XXX: scaled to fit width bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate()); // if it's an ability, show only the ability text as overlay diff --git a/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryItemEditor.java b/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryItemEditor.java index b7f476bc27..75f6635324 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryItemEditor.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/countryBox/CountryItemEditor.java @@ -47,7 +47,7 @@ public class CountryItemEditor extends BasicComboBoxEditor { @Override public void setItem(Object item) { - if (item == null || !(item instanceof String[])) { + if (!(item instanceof String[])) { return; } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index a124d63fa0..9c670224dd 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -800,7 +800,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener, // this update removes the isChoosable mark from targetCardsInLibrary // so only done for permanents because it's needed to redraw counters in different size, if window size was changed // no perfect solution yet (maybe also other not wanted effects for PermanentView objects) - if (updateCard != null && (updateCard instanceof PermanentView)) { + if ((updateCard instanceof PermanentView)) { update(updateCard); } } diff --git a/Mage.Common/src/main/java/mage/remote/Connection.java b/Mage.Common/src/main/java/mage/remote/Connection.java index 6022fcad8d..ecc7dd4416 100644 --- a/Mage.Common/src/main/java/mage/remote/Connection.java +++ b/Mage.Common/src/main/java/mage/remote/Connection.java @@ -225,7 +225,7 @@ public class Connection { for (InterfaceAddress addr : iface.getInterfaceAddresses()) { if (addr != null) { InetAddress iaddr = addr.getAddress(); - if (iaddr != null && iaddr instanceof Inet4Address) { + if (iaddr instanceof Inet4Address) { return iaddr; } } diff --git a/Mage.Common/src/main/java/mage/utils/CompressUtil.java b/Mage.Common/src/main/java/mage/utils/CompressUtil.java index 39fa5fdf6d..eeef7533de 100644 --- a/Mage.Common/src/main/java/mage/utils/CompressUtil.java +++ b/Mage.Common/src/main/java/mage/utils/CompressUtil.java @@ -39,7 +39,7 @@ public final class CompressUtil { * @return Decompressed object */ public static Object decompress(Object data) { - if (data == null || !(data instanceof ZippedObject)) { + if (!(data instanceof ZippedObject)) { return data; } return ((ZippedObject) data).unzip(); diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/LevelUpOptimizer.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/LevelUpOptimizer.java index c3c8934fa1..545851185a 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/LevelUpOptimizer.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/LevelUpOptimizer.java @@ -27,7 +27,7 @@ public class LevelUpOptimizer extends BaseTreeOptimizer { for (Ability ability : actions) { if (ability instanceof LevelUpAbility) { Permanent permanent = game.getPermanent(ability.getSourceId()); - if (permanent != null && permanent instanceof PermanentCard) { + if (permanent instanceof PermanentCard) { PermanentCard leveler = (PermanentCard) permanent; // check already existing Level counters and compare to maximum that make sense if (permanent.getCounters(game).getCount(CounterType.LEVEL) >= leveler.getMaxLevelCounters()) { diff --git a/Mage.Server/src/main/java/mage/server/util/SystemUtil.java b/Mage.Server/src/main/java/mage/server/util/SystemUtil.java index 0d0941623e..395becdf94 100644 --- a/Mage.Server/src/main/java/mage/server/util/SystemUtil.java +++ b/Mage.Server/src/main/java/mage/server/util/SystemUtil.java @@ -408,7 +408,7 @@ public final class SystemUtil { Class c = Class.forName("mage.game.permanent.token." + command.cardName); Constructor cons = c.getConstructor(); Object token = cons.newInstance(); - if (token != null && token instanceof mage.game.permanent.token.Token) { + if (token instanceof mage.game.permanent.token.Token) { ((mage.game.permanent.token.Token) token).putOntoBattlefield(command.Amount, game, null, player.getId(), false, false); continue; } @@ -417,7 +417,7 @@ public final class SystemUtil { Class c = Class.forName("mage.game.command.emblems." + command.cardName); Constructor cons = c.getConstructor(); Object emblem = cons.newInstance(); - if (emblem != null && emblem instanceof mage.game.command.Emblem) { + if (emblem instanceof mage.game.command.Emblem) { ((mage.game.command.Emblem) emblem).setControllerId(player.getId()); game.addEmblem((mage.game.command.Emblem) emblem, null, player.getId()); continue; @@ -427,7 +427,7 @@ public final class SystemUtil { Class c = Class.forName("mage.game.command.planes." + command.cardName); Constructor cons = c.getConstructor(); Object plane = cons.newInstance(); - if (plane != null && plane instanceof mage.game.command.Plane) { + if (plane instanceof mage.game.command.Plane) { ((mage.game.command.Plane) plane).setControllerId(player.getId()); game.addPlane((mage.game.command.Plane) plane, null, player.getId()); continue; diff --git a/Mage.Sets/src/mage/cards/b/Berserk.java b/Mage.Sets/src/mage/cards/b/Berserk.java index f193dcae69..3d38da94d8 100644 --- a/Mage.Sets/src/mage/cards/b/Berserk.java +++ b/Mage.Sets/src/mage/cards/b/Berserk.java @@ -171,7 +171,7 @@ class BerserkDelayedDestroyEffect extends OneShotEffect { Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { + if (watcher instanceof AttackedThisTurnWatcher) { if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { return permanent.destroy(source.getSourceId(), game, false); } diff --git a/Mage.Sets/src/mage/cards/b/BuzzingWhackADoodle.java b/Mage.Sets/src/mage/cards/b/BuzzingWhackADoodle.java index 48c26262d3..1c2b59519b 100644 --- a/Mage.Sets/src/mage/cards/b/BuzzingWhackADoodle.java +++ b/Mage.Sets/src/mage/cards/b/BuzzingWhackADoodle.java @@ -136,7 +136,7 @@ class WhackCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { Object object = game.getState().getValue("whack" + source.getSourceId()); - if (object != null && object instanceof Boolean && (Boolean) object) { + if (object instanceof Boolean && (Boolean) object) { return 1; } return 0; @@ -157,7 +157,7 @@ class DoodleCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { Object object = game.getState().getValue("doodle" + source.getSourceId()); - if (object != null && object instanceof Boolean && (Boolean) object) { + if (object instanceof Boolean && (Boolean) object) { return 1; } return 0; @@ -178,7 +178,7 @@ class BuzzCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { Object object = game.getState().getValue("buzz" + source.getSourceId()); - if (object != null && object instanceof Boolean && (Boolean) object) { + if (object instanceof Boolean && (Boolean) object) { return 1; } return 0; diff --git a/Mage.Sets/src/mage/cards/c/ChainOfSilence.java b/Mage.Sets/src/mage/cards/c/ChainOfSilence.java index 92d48f1e29..b9848d13ba 100644 --- a/Mage.Sets/src/mage/cards/c/ChainOfSilence.java +++ b/Mage.Sets/src/mage/cards/c/ChainOfSilence.java @@ -81,7 +81,7 @@ class ChainOfSilenceEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null) { StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true); - if (newStackObject != null && newStackObject instanceof Spell) { + if (newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); diff --git a/Mage.Sets/src/mage/cards/c/ChainOfVapor.java b/Mage.Sets/src/mage/cards/c/ChainOfVapor.java index f5abf3ace4..d6b94d8838 100644 --- a/Mage.Sets/src/mage/cards/c/ChainOfVapor.java +++ b/Mage.Sets/src/mage/cards/c/ChainOfVapor.java @@ -78,7 +78,7 @@ class ChainOfVaporEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null) { StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true); - if (newStackObject != null && newStackObject instanceof Spell) { + if (newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); diff --git a/Mage.Sets/src/mage/cards/c/ChainStasis.java b/Mage.Sets/src/mage/cards/c/ChainStasis.java index f49ea83cc0..295f1bffa1 100644 --- a/Mage.Sets/src/mage/cards/c/ChainStasis.java +++ b/Mage.Sets/src/mage/cards/c/ChainStasis.java @@ -80,7 +80,7 @@ class ChainStasisEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null) { StackObject newStackObject = spell.createCopyOnStack(game, source, player.getId(), true); - if (newStackObject != null && newStackObject instanceof Spell) { + if (newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); diff --git a/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java b/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java index f49e01f459..31bb27a193 100644 --- a/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java +++ b/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java @@ -98,7 +98,7 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl { // save the x value to be available for ETB replacement effect Object object = game.getState().getValue("spellX" + source.getSourceId()); Map spellX; - if (object != null && object instanceof Map) { + if (object instanceof Map) { spellX = (Map) object; } else { spellX = new HashMap<>(); diff --git a/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java b/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java index def0376ffc..936d838767 100644 --- a/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java +++ b/Mage.Sets/src/mage/cards/e/EngineeredExplosives.java @@ -70,7 +70,7 @@ class EngineeredExplosivesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { MageObject engineeredExplosives = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if(engineeredExplosives != null && engineeredExplosives instanceof Permanent){ + if(engineeredExplosives instanceof Permanent){ int count = ((Permanent)engineeredExplosives).getCounters(game).getCount(CounterType.CHARGE); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if(permanent.getConvertedManaCost() == count){ diff --git a/Mage.Sets/src/mage/cards/e/EssenceFlux.java b/Mage.Sets/src/mage/cards/e/EssenceFlux.java index f2802fc6b1..8364d113e6 100644 --- a/Mage.Sets/src/mage/cards/e/EssenceFlux.java +++ b/Mage.Sets/src/mage/cards/e/EssenceFlux.java @@ -77,7 +77,7 @@ class EssenceFluxEffect extends OneShotEffect { cardsToBattlefield.add(targetId); } else { Card card = game.getCard(targetId); - if (card != null && card instanceof MeldCard) { + if (card instanceof MeldCard) { MeldCard meldCard = (MeldCard) card; Card topCard = meldCard.getTopHalfCard(); Card bottomCard = meldCard.getBottomHalfCard(); diff --git a/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java b/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java index 9c4dcf83fc..3d396bc564 100644 --- a/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java +++ b/Mage.Sets/src/mage/cards/f/FiresongAndSunspeaker.java @@ -87,7 +87,7 @@ class FiresongAndSunspeakerTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { MageObject object = game.getObject(event.getSourceId()); - if (object != null && object instanceof Spell) { + if (object instanceof Spell) { if (event.getTargetId().equals(this.getControllerId()) && object.getColor(game).contains(ObjectColor.WHITE) && (object.isInstant() diff --git a/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java b/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java index 06678f2232..3f1471760d 100644 --- a/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java +++ b/Mage.Sets/src/mage/cards/f/ForbiddenCrypt.java @@ -151,7 +151,7 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff Card card = game.getCard(event.getTargetId()); if (card != null && card.isOwnedBy(source.getControllerId())) { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); - if (permanent == null || !(permanent instanceof PermanentToken)) { + if (!(permanent instanceof PermanentToken)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/f/ForsakenWastes.java b/Mage.Sets/src/mage/cards/f/ForsakenWastes.java index 0939aab170..6fb1308f39 100644 --- a/Mage.Sets/src/mage/cards/f/ForsakenWastes.java +++ b/Mage.Sets/src/mage/cards/f/ForsakenWastes.java @@ -73,7 +73,7 @@ class ForsakenWastesTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { MageObject eventSourceObject = game.getObject(event.getSourceId()); - if (eventSourceObject != null && event.getTargetId().equals(this.getSourceId())&& eventSourceObject instanceof Spell ) { + if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) { getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } diff --git a/Mage.Sets/src/mage/cards/g/GOTOJAIL.java b/Mage.Sets/src/mage/cards/g/GOTOJAIL.java index bd29803529..a7977281ff 100644 --- a/Mage.Sets/src/mage/cards/g/GOTOJAIL.java +++ b/Mage.Sets/src/mage/cards/g/GOTOJAIL.java @@ -150,7 +150,7 @@ class GoToJailUpkeepEffect extends OneShotEffect { Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game); - if (sourceObject != null && sourceObject instanceof Permanent && permanent != null) { + if (sourceObject instanceof Permanent && permanent != null) { UUID opponentId = (UUID) game.getState().getValue(sourceObject.getId().toString() + ChooseOpponentEffect.VALUE_KEY); Player opponent = game.getPlayer(opponentId); diff --git a/Mage.Sets/src/mage/cards/g/GenesisHydra.java b/Mage.Sets/src/mage/cards/g/GenesisHydra.java index 1a9527827f..be84c1942d 100644 --- a/Mage.Sets/src/mage/cards/g/GenesisHydra.java +++ b/Mage.Sets/src/mage/cards/g/GenesisHydra.java @@ -71,7 +71,7 @@ class GenesisHydraPutOntoBattlefieldEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY); - if (controller != null && obj != null && obj instanceof SpellAbility) { + if (controller != null && obj instanceof SpellAbility) { int count = ((SpellAbility) obj).getManaCostsToPay().getX(); if (count > 0) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count)); diff --git a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java index 0a31b9a4fb..5df2aeefb8 100644 --- a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java +++ b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java @@ -184,7 +184,7 @@ class HopeOfGhirapurCombatDamageWatcher extends Watcher { public boolean playerGotCombatDamage(UUID objectId, UUID playerId, Game game) { StackObject stackObject = game.getState().getStack().getStackObject(objectId); MageObjectReference mor; - if (stackObject != null && stackObject instanceof StackAbility) { + if (stackObject instanceof StackAbility) { // This is neccessary because the source object was sacrificed as cost and the correct zone change counter for target calid check can only be get from stack mor = new MageObjectReference(objectId, ((StackAbility) stackObject).getSourceObjectZoneChangeCounter(), game); } else { diff --git a/Mage.Sets/src/mage/cards/i/IceCauldron.java b/Mage.Sets/src/mage/cards/i/IceCauldron.java index e0adbe1386..bacaf44c11 100644 --- a/Mage.Sets/src/mage/cards/i/IceCauldron.java +++ b/Mage.Sets/src/mage/cards/i/IceCauldron.java @@ -265,7 +265,7 @@ class IceCauldronManaCondition implements Condition { public boolean apply(Game game, Ability source) { if (source instanceof SpellAbility) { Card card = game.getCard(source.getSourceId()); - if (card != null && exiledCard != null && card.equals(exiledCard)) { + if (card != null && card.equals(exiledCard)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/l/LabyrinthGuardian.java b/Mage.Sets/src/mage/cards/l/LabyrinthGuardian.java index bbc39d2bad..691561a52f 100644 --- a/Mage.Sets/src/mage/cards/l/LabyrinthGuardian.java +++ b/Mage.Sets/src/mage/cards/l/LabyrinthGuardian.java @@ -74,7 +74,7 @@ class LabyrinthGuardianTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { MageObject eventSourceObject = game.getObject(event.getSourceId()); - if (eventSourceObject != null && event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) { + if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) { getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } diff --git a/Mage.Sets/src/mage/cards/m/MeletisCharlatan.java b/Mage.Sets/src/mage/cards/m/MeletisCharlatan.java index 32170f2ac6..d88bb2b928 100644 --- a/Mage.Sets/src/mage/cards/m/MeletisCharlatan.java +++ b/Mage.Sets/src/mage/cards/m/MeletisCharlatan.java @@ -71,7 +71,7 @@ class MeletisCharlatanCopyTargetSpellEffect extends OneShotEffect { if (spell != null) { StackObject newStackObject = spell.createCopyOnStack(game, source, spell.getControllerId(), true); Player player = game.getPlayer(spell.getControllerId()); - if (player != null && newStackObject != null && newStackObject instanceof Spell) { + if (player != null && newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); diff --git a/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java b/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java index 562ca786fa..0b77db9540 100644 --- a/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java +++ b/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java @@ -91,7 +91,7 @@ class MetzaliTowerOfTriumphEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { + if (watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); List available = new ArrayList<>(); for (MageObjectReference mor : attackedThisTurn) { diff --git a/Mage.Sets/src/mage/cards/p/PawnOfUlamog.java b/Mage.Sets/src/mage/cards/p/PawnOfUlamog.java index 0ef7b2de1c..7c10dd1271 100644 --- a/Mage.Sets/src/mage/cards/p/PawnOfUlamog.java +++ b/Mage.Sets/src/mage/cards/p/PawnOfUlamog.java @@ -70,7 +70,7 @@ class PawnOfUlamogTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { UUID targetId = event.getTargetId(); MageObject card = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); - if (card != null && card instanceof Permanent && !(card instanceof PermanentToken)) { + if (card instanceof Permanent && !(card instanceof PermanentToken)) { Permanent permanent = (Permanent) card; ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java b/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java index 545e778711..eb4d598ecf 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianProcessor.java @@ -99,7 +99,7 @@ class PhyrexianProcessorCreateTokenEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game); Object object = game.getState().getValue(key); - if(object != null && object instanceof Integer) { + if(object instanceof Integer) { int lifePaid = (int) object; MinionToken token = new MinionToken(); token.getPower().modifyBaseValue(lifePaid); diff --git a/Mage.Sets/src/mage/cards/p/PsychicRebuttal.java b/Mage.Sets/src/mage/cards/p/PsychicRebuttal.java index 78ed585a42..1e85aba50d 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicRebuttal.java +++ b/Mage.Sets/src/mage/cards/p/PsychicRebuttal.java @@ -85,7 +85,7 @@ class PsychicRebuttalEffect extends OneShotEffect { && controller.chooseUse(Outcome.PlayForFree, "Copy " + spell.getName() + " (you may choose new targets for the copy)?", source, game)) { StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true); - if (newStackObject != null && newStackObject instanceof Spell) { + if (newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); diff --git a/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java b/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java index 8c6055dc4b..6c6c1c9b4c 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java @@ -62,7 +62,7 @@ class PyromancersGauntletReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { MageObject object = game.getObject(event.getSourceId()); - if (object != null && object instanceof Spell) { + if (object instanceof Spell) { if (((Spell) object).isControlledBy(source.getControllerId()) && (object.isInstant() || object.isSorcery())){ diff --git a/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java b/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java index 99bc826350..9c7e5e2455 100644 --- a/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java +++ b/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java @@ -73,7 +73,7 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { Map exileIds; String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game); Object object = game.getState().getValue(valueKey); - if (object != null && object instanceof Map) { + if (object instanceof Map) { exileIds = (Map) object; } else { exileIds = new HashMap<>(); @@ -123,7 +123,7 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { Map exileIds; String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game); Object object = game.getState().getValue(valueKey); - if (object != null && object instanceof Map) { + if (object instanceof Map) { exileIds = (Map) object; } else { return true; diff --git a/Mage.Sets/src/mage/cards/s/SilverfurPartisan.java b/Mage.Sets/src/mage/cards/s/SilverfurPartisan.java index 4caebce8f9..82648348da 100644 --- a/Mage.Sets/src/mage/cards/s/SilverfurPartisan.java +++ b/Mage.Sets/src/mage/cards/s/SilverfurPartisan.java @@ -77,7 +77,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isControlledBy(this.controllerId) && (permanent.hasSubtype(SubType.WOLF, game) || permanent.hasSubtype(SubType.WEREWOLF, game))) { MageObject object = game.getObject(event.getSourceId()); - if (object != null && object instanceof Spell) { + if (object instanceof Spell) { Card c = (Spell) object; if (c.isInstant() || c.isSorcery()) { if (getTargets().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/s/Solemnity.java b/Mage.Sets/src/mage/cards/s/Solemnity.java index b930f65297..0ce74644da 100644 --- a/Mage.Sets/src/mage/cards/s/Solemnity.java +++ b/Mage.Sets/src/mage/cards/s/Solemnity.java @@ -123,7 +123,7 @@ class SolemnityEffect2 extends ReplacementEffectImpl { Permanent permanent2 = game.getPermanent(event.getTargetId()); Permanent permanent3 = game.getPermanentEntering(event.getTargetId()); - if (object != null && object instanceof Permanent) { + if (object instanceof Permanent) { if (filter.match((Permanent) object, game)) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java b/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java index 015af98ca9..abd70447d8 100644 --- a/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java +++ b/Mage.Sets/src/mage/cards/s/SoulfireGrandMaster.java @@ -111,7 +111,7 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { MageObject mageObject = game.getObject(spellId); - if (mageObject == null || !(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) { + if (!(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) { return false; } else { Card sourceCard = game.getCard(spellId); diff --git a/Mage.Sets/src/mage/cards/s/SparkFiend.java b/Mage.Sets/src/mage/cards/s/SparkFiend.java index 0de02f16fd..3f55cc67b3 100644 --- a/Mage.Sets/src/mage/cards/s/SparkFiend.java +++ b/Mage.Sets/src/mage/cards/s/SparkFiend.java @@ -69,7 +69,7 @@ class SparkFiendEffect extends OneShotEffect { if (controller != null) { int roll = controller.rollDice(game, 6) + controller.rollDice(game, 6); MageObject mageObject = game.getObject(source.getSourceId()); - if (mageObject != null && mageObject instanceof Permanent) { + if (mageObject instanceof Permanent) { Permanent sourcePermanent = (Permanent) mageObject; if (roll == 2 || roll == 3 || roll == 12) { // sacrifice @@ -114,7 +114,7 @@ class SparkFiendUpkeepEffect extends OneShotEffect { && (Integer) game.getState().getValue("SparkFiend" + source.getSourceId().toString()) != 0) { int roll = controller.rollDice(game, 6) + controller.rollDice(game, 6); MageObject mageObject = game.getObject(source.getSourceId()); - if (mageObject != null && mageObject instanceof Permanent) { + if (mageObject instanceof Permanent) { Permanent sourcePermanent = (Permanent) mageObject; if (roll == 7) { // sacrifice diff --git a/Mage.Sets/src/mage/cards/s/SpectralPrison.java b/Mage.Sets/src/mage/cards/s/SpectralPrison.java index bac2d6a6b6..f502fd33e0 100644 --- a/Mage.Sets/src/mage/cards/s/SpectralPrison.java +++ b/Mage.Sets/src/mage/cards/s/SpectralPrison.java @@ -80,7 +80,7 @@ class SpectralPrisonAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { MageObject eventSourceObject = game.getObject(event.getSourceId()); - if (eventSourceObject != null && eventSourceObject instanceof Spell) { + if (eventSourceObject instanceof Spell) { Permanent enchantment = game.getPermanent(sourceId); if (enchantment != null && enchantment.getAttachedTo() != null) { if (event.getTargetId().equals(enchantment.getAttachedTo())) { diff --git a/Mage.Sets/src/mage/cards/s/SpellShrivel.java b/Mage.Sets/src/mage/cards/s/SpellShrivel.java index 9da3aaafe4..6ab606a199 100644 --- a/Mage.Sets/src/mage/cards/s/SpellShrivel.java +++ b/Mage.Sets/src/mage/cards/s/SpellShrivel.java @@ -66,7 +66,7 @@ class SpellShrivelCounterUnlessPaysEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); MageObject sourceObject = source.getSourceObject(game); - if (spell != null && (spell instanceof Spell) && sourceObject != null) { + if ((spell instanceof Spell) && sourceObject != null) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int amount = 4; diff --git a/Mage.Sets/src/mage/cards/s/SummoningTrap.java b/Mage.Sets/src/mage/cards/s/SummoningTrap.java index 31be77a83f..8bc4391c42 100644 --- a/Mage.Sets/src/mage/cards/s/SummoningTrap.java +++ b/Mage.Sets/src/mage/cards/s/SummoningTrap.java @@ -90,8 +90,7 @@ class SummoningTrapWatcher extends Watcher { if (counteredSpell == null) { counteredSpell = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK); } - if (counteredSpell != null - && counteredSpell instanceof Spell + if (counteredSpell instanceof Spell && !players.contains(counteredSpell.getControllerId()) && counteredSpell.isCreature()) { StackObject counteringStackObject = game.getStack().getStackObject(event.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/s/Syncopate.java b/Mage.Sets/src/mage/cards/s/Syncopate.java index c2ff8016d8..01dd9e8825 100644 --- a/Mage.Sets/src/mage/cards/s/Syncopate.java +++ b/Mage.Sets/src/mage/cards/s/Syncopate.java @@ -61,7 +61,7 @@ class SyncopateCounterUnlessPaysEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); MageObject sourceObject = source.getSourceObject(game); - if (spell != null && (spell instanceof Spell) && sourceObject != null) { + if ((spell instanceof Spell) && sourceObject != null) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int amount = source.getManaCostsToPay().getX(); diff --git a/Mage.Sets/src/mage/cards/t/ThoughtPrison.java b/Mage.Sets/src/mage/cards/t/ThoughtPrison.java index 8a5e27bc06..7eef4e4083 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtPrison.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtPrison.java @@ -137,7 +137,7 @@ class ThoughtPrisonTriggeredAbility extends TriggeredAbilityImpl { Spell spell = (Spell) game.getObject(event.getTargetId()); Permanent sourcePermanent = game.getPermanent(this.getSourceId()); - if (spell != null && spell instanceof Spell) { + if (spell instanceof Spell) { if (sourcePermanent == null) { sourcePermanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); } diff --git a/Mage.Sets/src/mage/cards/t/TreacherousPitDweller.java b/Mage.Sets/src/mage/cards/t/TreacherousPitDweller.java index d99891cb1f..876e1d9be1 100644 --- a/Mage.Sets/src/mage/cards/t/TreacherousPitDweller.java +++ b/Mage.Sets/src/mage/cards/t/TreacherousPitDweller.java @@ -102,8 +102,7 @@ class TreacherousPitDwellerEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { MageObject permanent = source.getSourceObjectIfItStillExists(game); // it can also return Card object Player targetOpponent = game.getPlayer(source.getFirstTarget()); - if (permanent != null - && (permanent instanceof Permanent) + if ((permanent instanceof Permanent) && targetOpponent != null) { return ((Permanent) permanent).changeControllerId(targetOpponent.getId(), game); } else { diff --git a/Mage.Sets/src/mage/cards/t/TritonTactics.java b/Mage.Sets/src/mage/cards/t/TritonTactics.java index d400a0fd42..1823c39c19 100644 --- a/Mage.Sets/src/mage/cards/t/TritonTactics.java +++ b/Mage.Sets/src/mage/cards/t/TritonTactics.java @@ -89,7 +89,7 @@ class TritonTacticsUntapTargetEffect extends OneShotEffect { // save the targets for the watcher in a map with zone change counter (as the card is recast during combat it's neccessary to save with zone change counter) Map> targetMap; Object object = game.getState().getValue("targets" + source.getSourceId()); - if (object != null && object instanceof Map) { + if (object instanceof Map) { targetMap = (Map>) object; } else { targetMap = new HashMap<>(); @@ -155,7 +155,7 @@ class TritonTacticsEndOfCombatEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Map> attackerMap = null; Object object = game.getState().getValue("blockedAttackers" + source.getSourceId()); - if (object != null && object instanceof Map) { + if (object instanceof Map) { attackerMap = (Map>) object; for (Set attackerSet : attackerMap.values()) { List doNotUntapNextUntapStep = new ArrayList<>(); @@ -197,7 +197,7 @@ class BlockedCreaturesWatcher extends Watcher { if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) { Map> targetMap; Object object = game.getState().getValue("targets" + this.getSourceId().toString()); - if (object != null && object instanceof Map) { + if (object instanceof Map) { Permanent blocker = game.getPermanent(event.getSourceId()); if (blocker != null) { targetMap = (Map>) object; @@ -217,7 +217,7 @@ class BlockedCreaturesWatcher extends Watcher { Set attackers; Map> attackerMap; Object object = game.getState().getValue("blockedAttackers" + getSourceId()); - if (object != null && object instanceof Map) { + if (object instanceof Map) { attackerMap = (Map>) object; } else { attackerMap = new HashMap<>(); diff --git a/Mage.Sets/src/mage/cards/w/WildDefiance.java b/Mage.Sets/src/mage/cards/w/WildDefiance.java index 6d2fd53615..25dcefa758 100644 --- a/Mage.Sets/src/mage/cards/w/WildDefiance.java +++ b/Mage.Sets/src/mage/cards/w/WildDefiance.java @@ -65,7 +65,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isControlledBy(this.controllerId) && permanent.isCreature()) { MageObject object = game.getObject(event.getSourceId()); - if (object != null && object instanceof Spell) { + if (object instanceof Spell) { Card c = (Spell) object; if (c.isInstant() || c.isSorcery()) { if (getTargets().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/w/WispweaverAngel.java b/Mage.Sets/src/mage/cards/w/WispweaverAngel.java index ca7fe9245a..e52cbe13d4 100644 --- a/Mage.Sets/src/mage/cards/w/WispweaverAngel.java +++ b/Mage.Sets/src/mage/cards/w/WispweaverAngel.java @@ -96,7 +96,7 @@ class WispweaverAngelEffect extends OneShotEffect { cardsToBattlefield.add(targetId); } else { Card card = game.getCard(targetId); - if (card != null && card instanceof MeldCard) { + if (card instanceof MeldCard) { MeldCard meldCard = (MeldCard) card; Card topCard = meldCard.getTopHalfCard(); Card bottomCard = meldCard.getBottomHalfCard(); diff --git a/Mage.Sets/src/mage/cards/w/WorldAtWar.java b/Mage.Sets/src/mage/cards/w/WorldAtWar.java index 3bd876d6c1..0658ecda70 100644 --- a/Mage.Sets/src/mage/cards/w/WorldAtWar.java +++ b/Mage.Sets/src/mage/cards/w/WorldAtWar.java @@ -143,7 +143,7 @@ class UntapAttackingThisTurnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { + if (watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); for (MageObjectReference mor : attackedThisTurn) { Permanent permanent = mor.getPermanent(game); diff --git a/Mage.Sets/src/mage/cards/y/YawgmothsAgenda.java b/Mage.Sets/src/mage/cards/y/YawgmothsAgenda.java index fbf46de1da..d36dfbe742 100644 --- a/Mage.Sets/src/mage/cards/y/YawgmothsAgenda.java +++ b/Mage.Sets/src/mage/cards/y/YawgmothsAgenda.java @@ -137,7 +137,7 @@ class YawgmothsAgendaReplacementEffect extends ReplacementEffectImpl { Card card = game.getCard(event.getTargetId()); if (card != null && card.isOwnedBy(source.getControllerId())) { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); - if (permanent == null || !(permanent instanceof PermanentToken)) { + if (!(permanent instanceof PermanentToken)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/y/YawgmothsWill.java b/Mage.Sets/src/mage/cards/y/YawgmothsWill.java index 8690dbd141..cfdb0d77e1 100644 --- a/Mage.Sets/src/mage/cards/y/YawgmothsWill.java +++ b/Mage.Sets/src/mage/cards/y/YawgmothsWill.java @@ -127,7 +127,7 @@ class YawgmothsWillReplacementEffect extends ReplacementEffectImpl { Card card = game.getCard(event.getTargetId()); if (card != null && card.isOwnedBy(source.getControllerId())) { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); - if (permanent == null || !(permanent instanceof PermanentToken)) { + if (!(permanent instanceof PermanentToken)) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java index 19fb7eacfd..7d4a85629c 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToOneOrMoreCreaturesTriggeredAbility.java @@ -31,7 +31,7 @@ public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamage || game.getTurn().getStepType() == PhaseStep.FIRST_COMBAT_DAMAGE) { String stepHash = (String) game.getState().getValue("damageStep" + getOriginalId()); String newStepHash = game.getStep().getType().toString() + game.getTurnNum(); - if (stepHash == null || !newStepHash.equals(stepHash)) { + if (!newStepHash.equals(stepHash)) { // this ability did not trigger during this damage step game.getState().setValue("damageStep" + getOriginalId(), game.getStep().getType().toString() + game.getTurnNum()); return true; diff --git a/Mage/src/main/java/mage/abilities/common/SpellCounteredControllerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SpellCounteredControllerTriggeredAbility.java index a0d3c0f0e8..b41e1001bb 100644 --- a/Mage/src/main/java/mage/abilities/common/SpellCounteredControllerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SpellCounteredControllerTriggeredAbility.java @@ -1,62 +1,62 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package mage.abilities.common; - -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.stack.Spell; -import mage.game.stack.StackObject; - -/** - * - * @author fireshoes - */ -public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityImpl { - - public SpellCounteredControllerTriggeredAbility(Effect effect) { - this(effect, false); - } - - public SpellCounteredControllerTriggeredAbility(Effect effect, boolean optional) { - super(Zone.BATTLEFIELD, effect, optional); - } - - public SpellCounteredControllerTriggeredAbility(final SpellCounteredControllerTriggeredAbility ability) { - super(ability); - } - - @Override - public SpellCounteredControllerTriggeredAbility copy() { - return new SpellCounteredControllerTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.COUNTERED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - StackObject stackObjectThatCountered = game.getStack().getStackObject(event.getSourceId()); - if (stackObjectThatCountered == null) { - stackObjectThatCountered = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK); - } - if (stackObjectThatCountered != null && stackObjectThatCountered.isControlledBy(getControllerId())) { - StackObject counteredStackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK); - return counteredStackObject != null && (counteredStackObject instanceof Spell); - } - return false; - } - - @Override - public String getRule() { - return "Whenever a spell or ability you control counters a spell, " + super.getRule(); - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; + +/** + * + * @author fireshoes + */ +public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityImpl { + + public SpellCounteredControllerTriggeredAbility(Effect effect) { + this(effect, false); + } + + public SpellCounteredControllerTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public SpellCounteredControllerTriggeredAbility(final SpellCounteredControllerTriggeredAbility ability) { + super(ability); + } + + @Override + public SpellCounteredControllerTriggeredAbility copy() { + return new SpellCounteredControllerTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == EventType.COUNTERED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + StackObject stackObjectThatCountered = game.getStack().getStackObject(event.getSourceId()); + if (stackObjectThatCountered == null) { + stackObjectThatCountered = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK); + } + if (stackObjectThatCountered != null && stackObjectThatCountered.isControlledBy(getControllerId())) { + StackObject counteredStackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK); + return (counteredStackObject instanceof Spell); + } + return false; + } + + @Override + public String getRule() { + return "Whenever a spell or ability you control counters a spell, " + super.getRule(); + } +} diff --git a/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java index 4b95507e5a..603d43cc69 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MeldCondition.java @@ -1,40 +1,40 @@ - -package mage.abilities.condition.common; - -import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.condition.Condition; -import mage.filter.common.FilterControlledCreaturePermanent; -import mage.filter.predicate.mageobject.NamePredicate; -import mage.filter.predicate.other.OwnerIdPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; - -/** - * - * @author emerald000 - */ -public class MeldCondition implements Condition { - - private final String meldWithName; - - public MeldCondition(String meldWithName) { - this.meldWithName = meldWithName; - } - - @Override - public boolean apply(Game game, Ability source) { - MageObject sourceMageObject = source.getSourceObjectIfItStillExists(game); - if (sourceMageObject != null && sourceMageObject instanceof Permanent) { - Permanent sourcePermanent = (Permanent) sourceMageObject; - if (sourcePermanent.isControlledBy(source.getControllerId()) - && sourcePermanent.isOwnedBy(source.getControllerId())) { - FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); - filter.add(new NamePredicate(this.meldWithName)); - filter.add(new OwnerIdPredicate(source.getControllerId())); - return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0; - } - } - return false; - } -} + +package mage.abilities.condition.common; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.mageobject.NamePredicate; +import mage.filter.predicate.other.OwnerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author emerald000 + */ +public class MeldCondition implements Condition { + + private final String meldWithName; + + public MeldCondition(String meldWithName) { + this.meldWithName = meldWithName; + } + + @Override + public boolean apply(Game game, Ability source) { + MageObject sourceMageObject = source.getSourceObjectIfItStillExists(game); + if (sourceMageObject instanceof Permanent) { + Permanent sourcePermanent = (Permanent) sourceMageObject; + if (sourcePermanent.isControlledBy(source.getControllerId()) + && sourcePermanent.isOwnedBy(source.getControllerId())) { + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); + filter.add(new NamePredicate(this.meldWithName)); + filter.add(new OwnerIdPredicate(source.getControllerId())); + return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) > 0; + } + } + return false; + } +} diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SunburstCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SunburstCount.java index 9948b486a3..d42cc3f528 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/SunburstCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/SunburstCount.java @@ -24,7 +24,7 @@ public class SunburstCount implements DynamicValue { int count = 0; if (!game.getStack().isEmpty()) { StackObject spell = game.getStack().getFirst(); - if (spell != null && spell instanceof Spell && ((Spell) spell).getSourceId().equals(source.getSourceId())) { + if (spell instanceof Spell && ((Spell) spell).getSourceId().equals(source.getSourceId())) { Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getPayment(); if (mana.getBlack() > 0) { count++; diff --git a/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java index 60b9b9468d..308c16b189 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java @@ -44,7 +44,7 @@ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getSourceId().equals(this.getSourceId())) { MageObject spellObject = game.getObject(sourceId); - if (spellObject != null && (spellObject instanceof Spell)) { + if ((spellObject instanceof Spell)) { Spell spell = (Spell) spellObject; if (spell.getSpellAbility() != null) { for (Effect effect : getEffects()) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java index 9278af4374..040be4c85d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopyTargetSpellEffect.java @@ -54,7 +54,7 @@ public class CopyTargetSpellEffect extends OneShotEffect { if (spell != null) { StackObject newStackObject = spell.createCopyOnStack(game, source, useController ? spell.getControllerId() : source.getControllerId(), true); Player player = game.getPlayer(source.getControllerId()); - if (player != null && newStackObject != null && newStackObject instanceof Spell) { + if (player != null && newStackObject instanceof Spell) { String activateMessage = ((Spell) newStackObject).getActivatedMessage(game); if (activateMessage.startsWith(" casts ")) { activateMessage = activateMessage.substring(6); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlAttachedEffect.java index 7584851375..ff587be44f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlAttachedEffect.java @@ -37,7 +37,7 @@ public class ReturnToBattlefieldUnderOwnerControlAttachedEffect extends OneShotE return false; } Object object = getValue("attachedTo"); - if (object != null && object instanceof Permanent) { + if (object instanceof Permanent) { Card card = game.getCard(((Permanent) object).getId()); if (card != null) { if (controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java index b23a11e1d0..657a347d2b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java @@ -66,7 +66,7 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff } else { Card card = game.getCard(targetId); - if (card != null && card instanceof MeldCard) { + if (card instanceof MeldCard) { MeldCard meldCard = (MeldCard) card; Card topCard = meldCard.getTopHalfCard(); Card bottomCard = meldCard.getBottomHalfCard(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlAttachedEffect.java index 55130c8f3b..c3156147b8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlAttachedEffect.java @@ -43,7 +43,7 @@ public class ReturnToBattlefieldUnderYourControlAttachedEffect extends OneShotEf public boolean apply(Game game, Ability source) { Object object = getValue("attachedTo"); Player controller = game.getPlayer(source.getControllerId()); - if (controller != null && object != null && object instanceof Permanent) { + if (controller != null && object instanceof Permanent) { Card card = game.getCard(((Permanent) object).getId()); // Move the card only, if it is still in the next zone after the battlefield if (card != null && card.getZoneChangeCounter(game) == ((Permanent) object).getZoneChangeCounter(game) + 1) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlTargetEffect.java index 05787cfd2f..e8bd4ab47a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderYourControlTargetEffect.java @@ -64,7 +64,7 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe } else { Card card = game.getCard(targetId); - if (card != null && card instanceof MeldCard) { + if (card instanceof MeldCard) { MeldCard meldCard = (MeldCard) card; Card topCard = meldCard.getTopHalfCard(); Card bottomCard = meldCard.getBottomHalfCard(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandAttachedEffect.java index ff3dce414b..368788d3f2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandAttachedEffect.java @@ -33,7 +33,7 @@ public class ReturnToHandAttachedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Object object = getValue("attachedTo"); - if (object != null && object instanceof Permanent) { + if (object instanceof Permanent) { Card card = game.getCard(((Permanent)object).getId()); if (card != null) { if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/TransformSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TransformSourceEffect.java index 5e70a7f70f..e3636ad588 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/TransformSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/TransformSourceEffect.java @@ -47,7 +47,7 @@ public class TransformSourceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { MageObject sourceObject = source.getSourceObjectIfItStillExists(game); // Transform only if it's the same object as the effect was put on the stack - if (sourceObject != null && sourceObject instanceof Permanent) { + if (sourceObject instanceof Permanent) { Permanent sourcePermanent = (Permanent) sourceObject; if (sourcePermanent.canTransform(source, game)) { // check not to transform twice the same side diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java index 4b95b39ace..78834f82ae 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java @@ -37,7 +37,7 @@ public class UntapAllThatAttackedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - if (watcher != null && watcher instanceof AttackedThisTurnWatcher) { + if (watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); for (MageObjectReference mor : attackedThisTurn) { Permanent permanent = mor.getPermanent(game); diff --git a/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java b/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java index 419b78a155..d661dea215 100644 --- a/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/AftermathAbility.java @@ -149,7 +149,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl { // wants to do that in the future. UUID sourceId = source.getSourceId(); Card sourceCard = game.getCard(source.getSourceId()); - if (sourceCard != null && sourceCard instanceof SplitCardHalf) { + if (sourceCard instanceof SplitCardHalf) { sourceCard = ((SplitCardHalf) sourceCard).getParentCard(); sourceId = sourceCard.getId(); } @@ -170,7 +170,7 @@ class AftermathExileAsResolvesFromGraveyard extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { UUID sourceId = source.getSourceId(); Card sourceCard = game.getCard(source.getSourceId()); - if (sourceCard != null && sourceCard instanceof SplitCardHalf) { + if (sourceCard instanceof SplitCardHalf) { sourceCard = ((SplitCardHalf) sourceCard).getParentCard(); sourceId = sourceCard.getId(); } diff --git a/Mage/src/main/java/mage/abilities/keyword/ConspireAbility.java b/Mage/src/main/java/mage/abilities/keyword/ConspireAbility.java index 212d940a9f..30778d34e2 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ConspireAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ConspireAbility.java @@ -272,7 +272,7 @@ class ConspireEffect extends OneShotEffect { Card card = game.getCard(conspiredSpell.getSourceId()); if (card != null) { StackObject newStackObject = conspiredSpell.createCopyOnStack(game, source, source.getControllerId(), true); - if (newStackObject != null && newStackObject instanceof Spell && !game.isSimulation()) { + if (newStackObject instanceof Spell && !game.isSimulation()) { game.informPlayers(controller.getLogName() + ((Spell) newStackObject).getActivatedMessage(game)); } return true; diff --git a/Mage/src/main/java/mage/abilities/keyword/HauntAbility.java b/Mage/src/main/java/mage/abilities/keyword/HauntAbility.java index 3320589b45..9e08681fb9 100644 --- a/Mage/src/main/java/mage/abilities/keyword/HauntAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/HauntAbility.java @@ -83,7 +83,7 @@ public class HauntAbility extends TriggeredAbilityImpl { if (card != null) { String key = new StringBuilder("Haunting_").append(getSourceId().toString()).append('_').append(card.getZoneChangeCounter(game)).toString(); Object object = game.getState().getValue(key); - if (object != null && object instanceof FixedTarget) { + if (object instanceof FixedTarget) { FixedTarget target = (FixedTarget) object; if (target.getTarget() != null && target.getTarget().equals(event.getTargetId())) { usedFromExile = true; diff --git a/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java b/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java index bd29bffab2..3f0c3037dd 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java @@ -222,7 +222,7 @@ class ReplicateCopyEffect extends OneShotEffect { // create the copies for (int i = 0; i < replicateCount; i++) { StackObject newStackObject = spell.createCopyOnStack(game, source, source.getControllerId(), true); - if (newStackObject != null && newStackObject instanceof Spell && !game.isSimulation()) { + if (newStackObject instanceof Spell && !game.isSimulation()) { game.informPlayers(controller.getLogName() + ((Spell) newStackObject).getActivatedMessage(game)); } } diff --git a/Mage/src/main/java/mage/game/command/Plane.java b/Mage/src/main/java/mage/game/command/Plane.java index a21f0a27dd..b6a3768c29 100644 --- a/Mage/src/main/java/mage/game/command/Plane.java +++ b/Mage/src/main/java/mage/game/command/Plane.java @@ -286,7 +286,7 @@ public class Plane implements CommandObject { Class c = Class.forName(planeName); Constructor cons = c.getConstructor(); Object plane = cons.newInstance(); - if (plane != null && plane instanceof mage.game.command.Plane) { + if (plane instanceof Plane) { return (Plane) plane; } } catch (Exception ex) { diff --git a/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java b/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java index 26f809f941..d4dd3a6c8a 100644 --- a/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java +++ b/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java @@ -63,7 +63,7 @@ class IllusionTokenTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { MageObject eventSourceObject = game.getObject(event.getSourceId()); - if (eventSourceObject != null && event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) { + if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) { getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } diff --git a/Mage/src/main/java/mage/target/TargetImpl.java b/Mage/src/main/java/mage/target/TargetImpl.java index 4f95f3287d..110b67203c 100644 --- a/Mage/src/main/java/mage/target/TargetImpl.java +++ b/Mage/src/main/java/mage/target/TargetImpl.java @@ -149,7 +149,7 @@ public abstract class TargetImpl implements Target { @Override public boolean isRequired(UUID sourceId, Game game) { MageObject object = game.getObject(sourceId); - if (!requiredExplicitlySet && object != null && object instanceof Ability) { + if (!requiredExplicitlySet && object instanceof Ability) { return isRequired((Ability) object); } else { return isRequired(); diff --git a/Mage/src/main/java/mage/target/TargetSource.java b/Mage/src/main/java/mage/target/TargetSource.java index b65bc14aba..e0dae36e50 100644 --- a/Mage/src/main/java/mage/target/TargetSource.java +++ b/Mage/src/main/java/mage/target/TargetSource.java @@ -60,7 +60,7 @@ public class TargetSource extends TargetObject { public void addTarget(UUID id, Ability source, Game game) { if (targets.size() < maxNumberOfTargets) { MageObject object = game.getObject(id); - if (object != null && object instanceof StackObject) { + if (object instanceof StackObject) { addTarget(((StackObject) object).getSourceId(), source, game, notTarget); } else { diff --git a/Mage/src/main/java/mage/watchers/common/CastSpellYourLastTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CastSpellYourLastTurnWatcher.java index 51ce34bcd3..97a51a225d 100644 --- a/Mage/src/main/java/mage/watchers/common/CastSpellYourLastTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CastSpellYourLastTurnWatcher.java @@ -37,7 +37,7 @@ public class CastSpellYourLastTurnWatcher extends Watcher { lastActivePlayer = game.getActivePlayerId(); if (event.getType() == GameEvent.EventType.SPELL_CAST) { UUID playerId = event.getPlayerId(); - if (playerId != null && lastActivePlayer != null && playerId.equals(lastActivePlayer)) { + if (playerId != null && playerId.equals(lastActivePlayer)) { amountOfSpellsCastOnCurrentTurn.putIfAbsent(playerId, 0); amountOfSpellsCastOnCurrentTurn.compute(playerId, (k, a) -> a + 1); }