From a15220d51ea0447f038d1f4784c6074bdcdb436a Mon Sep 17 00:00:00 2001 From: vraskulin Date: Wed, 15 Feb 2017 19:52:20 +0300 Subject: [PATCH] Bugfixes with != instead of equals and default toString calls --- .../main/java/org/mage/card/arcane/UI.java | 3 +- .../plugins/card/images/DownloadPictures.java | 4 +-- .../src/mage/player/human/HumanPlayer.java | 3 +- .../src/main/java/mage/server/Main.java | 5 +-- .../src/mage/cards/a/AdviceFromTheFae.java | 3 +- .../mage/cards/a/AlhammarretHighArbiter.java | 3 +- .../src/mage/cards/a/AllianceOfArms.java | 3 +- .../src/mage/cards/a/ArrogantBloodlord.java | 7 ++-- Mage.Sets/src/mage/cards/c/CanalCourier.java | 3 +- .../src/mage/cards/c/CityOfTraitors.java | 3 +- .../src/mage/cards/c/CollectiveVoyage.java | 3 +- Mage.Sets/src/mage/cards/c/CrownOfDoom.java | 3 +- .../src/mage/cards/d/DaxosOfMeletis.java | 3 +- .../src/mage/cards/d/DivineIntervention.java | 5 +-- Mage.Sets/src/mage/cards/d/Duneblast.java | 3 +- Mage.Sets/src/mage/cards/e/EnergyField.java | 3 +- Mage.Sets/src/mage/cards/e/Equipoise.java | 3 +- .../src/mage/cards/e/EyeOfSingularity.java | 3 +- .../src/mage/cards/f/FabricationModule.java | 3 +- Mage.Sets/src/mage/cards/g/GuardianBeast.java | 5 +-- .../src/mage/cards/h/HellcarverDemon.java | 3 +- Mage.Sets/src/mage/cards/h/HotSoup.java | 3 +- Mage.Sets/src/mage/cards/h/HydraOmnivore.java | 3 +- .../src/mage/cards/i/IllicitAuction.java | 3 +- .../mage/cards/k/KazuulTyrantOfTheCliffs.java | 3 +- .../mage/cards/k/KnowledgeExploitation.java | 2 +- .../mage/cards/k/KynaiosAndTiroOfMeletis.java | 3 +- .../mage/cards/l/LudevicNecroAlchemist.java | 5 +-- Mage.Sets/src/mage/cards/m/MagneticMine.java | 3 +- .../src/mage/cards/m/ManaChargedDragon.java | 3 +- Mage.Sets/src/mage/cards/m/ManaWeb.java | 3 +- Mage.Sets/src/mage/cards/m/MindsAglow.java | 3 +- .../mage/cards/m/MuragandaPetroglyphs.java | 3 +- Mage.Sets/src/mage/cards/m/MysticRemora.java | 3 +- Mage.Sets/src/mage/cards/n/NightDealings.java | 3 +- .../src/mage/cards/o/OrzhovAdvokist.java | 3 +- Mage.Sets/src/mage/cards/p/PainsReward.java | 3 +- .../src/mage/cards/p/PsychicPossession.java | 3 +- Mage.Sets/src/mage/cards/r/ReflectorMage.java | 3 +- .../src/mage/cards/r/RocketLauncher.java | 3 +- Mage.Sets/src/mage/cards/s/ScarredPuma.java | 3 +- Mage.Sets/src/mage/cards/s/SharedTrauma.java | 3 +- .../src/mage/cards/s/ShattergangBrothers.java | 3 +- Mage.Sets/src/mage/cards/s/SkullRend.java | 3 +- Mage.Sets/src/mage/cards/s/SpikeCannibal.java | 3 +- .../src/mage/cards/s/SpreadingPlague.java | 3 +- Mage.Sets/src/mage/cards/s/Sunforger.java | 2 +- .../src/mage/cards/t/TerritorialGorger.java | 3 +- .../mage/cards/t/TrostaniSelesnyasVoice.java | 3 +- .../src/mage/cards/u/UrborgSyphonMage.java | 3 +- Mage.Sets/src/mage/cards/v/Venom.java | 7 ++-- .../src/mage/cards/w/WeightOfConscience.java | 3 +- Mage.Sets/src/mage/cards/w/Worldslayer.java | 3 +- .../test/serverside/base/MageTestBase.java | 5 +-- .../serverside/base/MageTestPlayerBase.java | 5 +-- Mage/src/main/java/mage/MageInt.java | 4 ++- Mage/src/main/java/mage/ObjectColor.java | 32 ++++++++++--------- .../common/AttacksAloneTriggeredAbility.java | 3 +- ...nBattlefieldControlUnchangedCondition.java | 3 +- .../common/CantBeRegeneratedSourceEffect.java | 4 ++- .../abilities/effects/common/EpicEffect.java | 4 ++- .../src/main/java/mage/filter/FilterImpl.java | 5 +++ Mage/src/main/java/mage/game/GameImpl.java | 17 ++-------- Mage/src/main/java/mage/game/GameState.java | 16 ++-------- .../src/main/java/mage/game/ZonesHandler.java | 4 +-- .../main/java/mage/game/draft/DraftCube.java | 3 +- .../main/java/mage/game/draft/DraftImpl.java | 13 +++----- .../mage/game/draft/RichManBoosterDraft.java | 3 +- .../game/draft/RichManCubeBoosterDraft.java | 8 ++--- .../mage/game/permanent/PermanentImpl.java | 12 ++----- .../main/java/mage/players/PlayerImpl.java | 6 ++-- .../watchers/common/CastFromHandWatcher.java | 3 +- Mage/src/test/java/mage/ManaTest.java | 6 ++-- .../test/java/mage/counters/CounterTest.java | 4 ++- 74 files changed, 187 insertions(+), 147 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/UI.java b/Mage.Client/src/main/java/org/mage/card/arcane/UI.java index dd9f234861..4c9d2324ef 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/UI.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/UI.java @@ -18,6 +18,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -102,7 +103,7 @@ public class UI { Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute); if (o instanceof HTML.Tag) { HTML.Tag kind = (HTML.Tag) o; - if (kind == HTML.Tag.IMG) { + if (Objects.equals(kind, HTML.Tag.IMG)) { return new ImageView(elem) { @Override public URL getImageURL() { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java index 953f606511..bb8be1b4f5 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java @@ -296,10 +296,10 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab } } else if (card.getCardNumber().isEmpty() || "0".equals(card.getCardNumber())) { System.err.println("There was a critical error!"); - logger.error("Card has no collector ID and won't be sent to client: " + card); + logger.error("Card has no collector ID and won't be sent to client: " + card.getName()); } else if (card.getSetCode().isEmpty()) { System.err.println("There was a critical error!"); - logger.error("Card has no set name and won't be sent to client:" + card); + logger.error("Card has no set name and won't be sent to client:" + card.getName()); } }); numberWithoutTokens = allCards.size(); diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index d5749dce83..d95e3345d7 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -752,7 +752,8 @@ public class HumanPlayer extends PlayerImpl { return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getStep().getType()); } } catch (NullPointerException ex) { - logger.error("null pointer exception UserData = " + userData == null ? "null" : "not null"); + String isNull = userData == null ? "null" : "not null"; + logger.error("null pointer exception UserData = " + isNull); } return true; } diff --git a/Mage.Server/src/main/java/mage/server/Main.java b/Mage.Server/src/main/java/mage/server/Main.java index 18e2650663..0b1896361c 100644 --- a/Mage.Server/src/main/java/mage/server/Main.java +++ b/Mage.Server/src/main/java/mage/server/Main.java @@ -62,6 +62,7 @@ import org.w3c.dom.Element; import javax.management.MBeanServer; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.net.InetAddress; import java.net.MalformedURLException; import java.util.*; @@ -401,7 +402,7 @@ public class Main { try { classLoader.addURL(new File(pluginFolder, plugin.getJar()).toURI().toURL()); logger.debug("Loading game type: " + plugin.getClassName()); - return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance(); + return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).getConstructor().newInstance(); } catch (ClassNotFoundException ex) { logger.warn("Game type not found:" + plugin.getJar() + " - check plugin folder", ex); } catch (Exception ex) { @@ -414,7 +415,7 @@ public class Main { try { classLoader.addURL(new File(pluginFolder, plugin.getJar()).toURI().toURL()); logger.debug("Loading tournament type: " + plugin.getClassName()); - return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance(); + return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).getConstructor().newInstance(); } catch (ClassNotFoundException ex) { logger.warn("Tournament type not found:" + plugin.getName() + " / " + plugin.getJar() + " - check plugin folder", ex); } catch (Exception ex) { diff --git a/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java b/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java index f465ee2c4d..49927fb150 100644 --- a/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java +++ b/Mage.Sets/src/mage/cards/a/AdviceFromTheFae.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.Objects; import java.util.Set; import java.util.UUID; import mage.MageObject; @@ -104,7 +105,7 @@ class AdviceFromTheFaeEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(playerId)); - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { if (max < game.getBattlefield().countAll(filter, playerId, game)) { max = game.getBattlefield().countAll(filter, playerId, game); } diff --git a/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java b/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java index 9390e33105..1fdf190b7b 100644 --- a/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java +++ b/Mage.Sets/src/mage/cards/a/AlhammarretHighArbiter.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.MageObject; @@ -108,7 +109,7 @@ class AlhammarretHighArbiterEffect extends OneShotEffect { if (controller != null) { Cards revealedCards = new CardsImpl(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { Cards cards = new CardsImpl(opponent.getHand()); diff --git a/Mage.Sets/src/mage/cards/a/AllianceOfArms.java b/Mage.Sets/src/mage/cards/a/AllianceOfArms.java index 42dcff4fb9..3263ea3766 100644 --- a/Mage.Sets/src/mage/cards/a/AllianceOfArms.java +++ b/Mage.Sets/src/mage/cards/a/AllianceOfArms.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; @@ -90,7 +91,7 @@ class AllianceOfArmsEffect extends OneShotEffect { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { xSum += playerPaysXGenericMana(player, source, game); diff --git a/Mage.Sets/src/mage/cards/a/ArrogantBloodlord.java b/Mage.Sets/src/mage/cards/a/ArrogantBloodlord.java index 31b8c9d576..c871c7f353 100644 --- a/Mage.Sets/src/mage/cards/a/ArrogantBloodlord.java +++ b/Mage.Sets/src/mage/cards/a/ArrogantBloodlord.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -97,12 +98,12 @@ class ArrogantBloodlordTriggeredAbility extends TriggeredAbilityImpl { Permanent blocker = game.getPermanent(event.getSourceId()); Permanent blocked = game.getPermanent(event.getTargetId()); Permanent arrogantBloodlord = game.getPermanent(sourceId); - if (blocker != null && blocker != arrogantBloodlord + if (blocker != null && !Objects.equals(blocker, arrogantBloodlord) && blocker.getPower().getValue() < 2 - && blocked == arrogantBloodlord) { + && Objects.equals(blocked, arrogantBloodlord)) { return true; } - if (blocker != null && blocker == arrogantBloodlord + if (blocker != null && Objects.equals(blocker, arrogantBloodlord) && game.getPermanent(event.getTargetId()).getPower().getValue() < 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/CanalCourier.java b/Mage.Sets/src/mage/cards/c/CanalCourier.java index 3639cc5e72..f4f9b982ee 100644 --- a/Mage.Sets/src/mage/cards/c/CanalCourier.java +++ b/Mage.Sets/src/mage/cards/c/CanalCourier.java @@ -27,6 +27,7 @@ */ package mage.cards.c; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; @@ -108,7 +109,7 @@ class CanalCourierTriggeredAbility extends TriggeredAbilityImpl { Player attackedPlayer = game.getPlayer(sourceDefenderId); if (attackedPlayer != null) { for (UUID attacker : game.getCombat().getAttackers()) { - if (attacker != permanent.getId()) { + if (!Objects.equals(attacker, permanent.getId())) { UUID defenderId = game.getCombat().getDefenderId(attacker); Player attackedPlayer2 = game.getPlayer(defenderId); if (attackedPlayer2 != null && attackedPlayer.getId().equals(attackedPlayer2.getId())) { diff --git a/Mage.Sets/src/mage/cards/c/CityOfTraitors.java b/Mage.Sets/src/mage/cards/c/CityOfTraitors.java index 2e924e7433..e8d8af37f5 100644 --- a/Mage.Sets/src/mage/cards/c/CityOfTraitors.java +++ b/Mage.Sets/src/mage/cards/c/CityOfTraitors.java @@ -27,6 +27,7 @@ */ package mage.cards.c; +import java.util.Objects; import java.util.UUID; import mage.Mana; import mage.abilities.TriggeredAbilityImpl; @@ -88,7 +89,7 @@ class CityOfTraitorsTriggeredAbility extends TriggeredAbilityImpl { Permanent land = game.getPermanent(event.getTargetId()); return land.getCardType().contains(CardType.LAND) && land.getControllerId().equals(this.controllerId) - && event.getTargetId() != this.getSourceId(); + && !Objects.equals(event.getTargetId(), this.getSourceId()); } @Override diff --git a/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java b/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java index abc8fe8cb8..2b2e75acdd 100644 --- a/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java +++ b/Mage.Sets/src/mage/cards/c/CollectiveVoyage.java @@ -27,6 +27,7 @@ */ package mage.cards.c; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; @@ -90,7 +91,7 @@ class CollectiveVoyageEffect extends OneShotEffect { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { xSum += playerPaysXGenericMana(player, source, game); diff --git a/Mage.Sets/src/mage/cards/c/CrownOfDoom.java b/Mage.Sets/src/mage/cards/c/CrownOfDoom.java index 3488199e83..5c6dfd3212 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfDoom.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfDoom.java @@ -27,6 +27,7 @@ */ package mage.cards.c; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.ActivateIfConditionActivatedAbility; @@ -122,7 +123,7 @@ class CrownOfDoomEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player newController = game.getPlayer(getTargetPointer().getFirst(game, source)); - if (controller != null && newController != null && controller.getId() != newController.getId()) { + if (controller != null && newController != null && !Objects.equals(controller.getId(), newController.getId())) { // Duration.Custom = effect ends if Artifact leaves the current zone (battlefield) ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, newController.getId()); effect.setTargetPointer(new FixedTarget(source.getSourceId())); diff --git a/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java b/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java index 14558c392a..8f850baa6d 100644 --- a/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java +++ b/Mage.Sets/src/mage/cards/d/DaxosOfMeletis.java @@ -27,6 +27,7 @@ */ package mage.cards.d; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.MageObject; @@ -207,7 +208,7 @@ class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl implements AsT @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { return source.getControllerId().equals(affectedControllerId) - && objectId == ((FixedTarget) getTargetPointer()).getTarget() + && Objects.equals(objectId, ((FixedTarget) getTargetPointer()).getTarget()) && ((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1 == game.getState().getZoneChangeCounter(objectId) && (((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1 == game.getState().getZoneChangeCounter(objectId)) && game.getState().getZone(objectId).equals(Zone.STACK); diff --git a/Mage.Sets/src/mage/cards/d/DivineIntervention.java b/Mage.Sets/src/mage/cards/d/DivineIntervention.java index 8a534a13b4..9b1be523e1 100644 --- a/Mage.Sets/src/mage/cards/d/DivineIntervention.java +++ b/Mage.Sets/src/mage/cards/d/DivineIntervention.java @@ -27,6 +27,7 @@ */ package mage.cards.d; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -111,9 +112,9 @@ public class DivineIntervention extends CardImpl { for (StackObject stackObject : game.getStack()) { if (stackObject.getControllerId() != null && !firstOnStack) { - if (you != stackObject.getControllerId()) { + if (!Objects.equals(you, stackObject.getControllerId())) { onlyYouOnStack = false; - } else if (you == stackObject.getControllerId()) { + } else if (Objects.equals(you, stackObject.getControllerId())) { onlyOpponentOnStack = false; } diff --git a/Mage.Sets/src/mage/cards/d/Duneblast.java b/Mage.Sets/src/mage/cards/d/Duneblast.java index bae34873cc..fd03d8e1af 100644 --- a/Mage.Sets/src/mage/cards/d/Duneblast.java +++ b/Mage.Sets/src/mage/cards/d/Duneblast.java @@ -27,6 +27,7 @@ */ package mage.cards.d; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -93,7 +94,7 @@ class DuneblastEffect extends OneShotEffect { creatureToKeep = game.getPermanent(target.getFirstTarget()); } for(Permanent creature: game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { - if (creature != creatureToKeep) { + if (!Objects.equals(creature, creatureToKeep)) { creature.destroy(source.getSourceId(), game, false); } } diff --git a/Mage.Sets/src/mage/cards/e/EnergyField.java b/Mage.Sets/src/mage/cards/e/EnergyField.java index 5e601c6636..251373adc4 100644 --- a/Mage.Sets/src/mage/cards/e/EnergyField.java +++ b/Mage.Sets/src/mage/cards/e/EnergyField.java @@ -27,6 +27,7 @@ */ package mage.cards.e; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; @@ -101,7 +102,7 @@ class EnergyFieldEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER) { - if (event.getTargetId().equals(source.getControllerId()) && game.getControllerId(event.getSourceId()) != source.getControllerId()) { + if (event.getTargetId().equals(source.getControllerId()) && !Objects.equals(game.getControllerId(event.getSourceId()), source.getControllerId())) { return super.applies(event, source, game); } } diff --git a/Mage.Sets/src/mage/cards/e/Equipoise.java b/Mage.Sets/src/mage/cards/e/Equipoise.java index 36c171d9d3..7f3f526804 100644 --- a/Mage.Sets/src/mage/cards/e/Equipoise.java +++ b/Mage.Sets/src/mage/cards/e/Equipoise.java @@ -27,6 +27,7 @@ */ package mage.cards.e; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; @@ -94,7 +95,7 @@ class EquipoiseEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (controller != null && targetPlayer != null) { - if (targetPlayer != controller) { + if (!Objects.equals(targetPlayer, controller)) { phaseOutCardType(controller, targetPlayer, CardType.LAND, source, game); phaseOutCardType(controller, targetPlayer, CardType.ARTIFACT, source, game); phaseOutCardType(controller, targetPlayer, CardType.CREATURE, source, game); diff --git a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java index c79782be60..0a3c265f13 100644 --- a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java +++ b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java @@ -28,6 +28,7 @@ package mage.cards.e; import java.util.HashMap; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -191,7 +192,7 @@ class EyeOfSingularityTriggeredEffect extends OneShotEffect { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { String cardName = permanent.getName(); - if (cardName.equals(cn) && permanent.getId() != etbPermanent.getId()) { + if (cardName.equals(cn) && !Objects.equals(permanent.getId(), etbPermanent.getId())) { toDestroy.put(permanent.getId(), 1); } } diff --git a/Mage.Sets/src/mage/cards/f/FabricationModule.java b/Mage.Sets/src/mage/cards/f/FabricationModule.java index d994bac555..b19ee5d831 100644 --- a/Mage.Sets/src/mage/cards/f/FabricationModule.java +++ b/Mage.Sets/src/mage/cards/f/FabricationModule.java @@ -27,6 +27,7 @@ */ package mage.cards.f; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -97,7 +98,7 @@ class FabricationModuleTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getData().equals(CounterType.ENERGY.getName())) { - return event.getTargetId() == this.getControllerId(); + return Objects.equals(event.getTargetId(), this.getControllerId()); } return false; } diff --git a/Mage.Sets/src/mage/cards/g/GuardianBeast.java b/Mage.Sets/src/mage/cards/g/GuardianBeast.java index 5c20bdb1e7..cd5d602bd8 100644 --- a/Mage.Sets/src/mage/cards/g/GuardianBeast.java +++ b/Mage.Sets/src/mage/cards/g/GuardianBeast.java @@ -27,6 +27,7 @@ */ package mage.cards.g; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -139,14 +140,14 @@ class GuardianBeastConditionalEffect extends ContinuousRuleModifyingEffectImpl { return false; } - if (targetPermanent.getControllerId() != guardianBeast.getControllerId()) { + if (!Objects.equals(targetPermanent.getControllerId(), guardianBeast.getControllerId())) { return false; } StackObject spell = game.getStack().getStackObject(event.getSourceId()); if (event.getType() == EventType.LOSE_CONTROL || event.getType() == EventType.ATTACH || event.getType() == EventType.TARGET && spell != null && spell.getCardType().contains(CardType.ENCHANTMENT) && spell.getSubtype(game).contains("Aura")) { for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { - if (perm != null && perm.getId() == targetPermanent.getId() && !perm.getCardType().contains(CardType.CREATURE)) { + if (perm != null && Objects.equals(perm.getId(), targetPermanent.getId()) && !perm.getCardType().contains(CardType.CREATURE)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/h/HellcarverDemon.java b/Mage.Sets/src/mage/cards/h/HellcarverDemon.java index 0c8feae870..bb676686c1 100644 --- a/Mage.Sets/src/mage/cards/h/HellcarverDemon.java +++ b/Mage.Sets/src/mage/cards/h/HellcarverDemon.java @@ -27,6 +27,7 @@ */ package mage.cards.h; +import java.util.Objects; import java.util.UUID; import mage.constants.CardType; import mage.MageInt; @@ -95,7 +96,7 @@ class HellcarverDemonEffect extends OneShotEffect { Permanent hellcarverDemon = game.getPermanent(source.getSourceId()); for (Permanent permanent: game.getBattlefield().getActivePermanents(filterPermanents, source.getControllerId(), game)) { - if (permanent != hellcarverDemon) { + if (!Objects.equals(permanent, hellcarverDemon)) { permanent.sacrifice(source.getSourceId(), game); } } diff --git a/Mage.Sets/src/mage/cards/h/HotSoup.java b/Mage.Sets/src/mage/cards/h/HotSoup.java index 813bda70a5..41c6a54bc4 100644 --- a/Mage.Sets/src/mage/cards/h/HotSoup.java +++ b/Mage.Sets/src/mage/cards/h/HotSoup.java @@ -27,6 +27,7 @@ */ package mage.cards.h; +import java.util.Objects; import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; @@ -101,7 +102,7 @@ class HotSoupTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent equipment = game.getPermanent(this.getSourceId()); if (equipment != null && equipment.getAttachedTo() != null) { - if (event.getTargetId() == equipment.getAttachedTo()) { + if (Objects.equals(event.getTargetId(), equipment.getAttachedTo())) { for(Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(equipment.getAttachedTo())); diff --git a/Mage.Sets/src/mage/cards/h/HydraOmnivore.java b/Mage.Sets/src/mage/cards/h/HydraOmnivore.java index 2cb4eaf95a..b057b58f7d 100644 --- a/Mage.Sets/src/mage/cards/h/HydraOmnivore.java +++ b/Mage.Sets/src/mage/cards/h/HydraOmnivore.java @@ -27,6 +27,7 @@ */ package mage.cards.h; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.MageObject; @@ -90,7 +91,7 @@ class HydraOmnivoreEffect extends OneShotEffect { MageObject object = game.getObject(source.getSourceId()); if (object != null && amount > 0 && damagedOpponent != null) { for (UUID playerId :game.getOpponents(source.getControllerId())) { - if (playerId != damagedOpponent) { + if (!Objects.equals(playerId, damagedOpponent)) { Player opponent = game.getPlayer(playerId); if (opponent != null) { int dealtDamage = opponent.damage(amount, source.getSourceId(), game, false, true); diff --git a/Mage.Sets/src/mage/cards/i/IllicitAuction.java b/Mage.Sets/src/mage/cards/i/IllicitAuction.java index 91f2f951c7..965bf1613f 100644 --- a/Mage.Sets/src/mage/cards/i/IllicitAuction.java +++ b/Mage.Sets/src/mage/cards/i/IllicitAuction.java @@ -27,6 +27,7 @@ */ package mage.cards.i; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.common.continuous.GainControlTargetEffect; @@ -95,7 +96,7 @@ class IllicitAuctionEffect extends GainControlTargetEffect { game.informPlayers(winner.getLogName()+ " has bet 0 lifes"); Player currentPlayer = playerList.getNextInRange(controller, game); - while (currentPlayer != winner) { + while (!Objects.equals(currentPlayer, winner)) { String text = winner.getLogName() + " has bet " + highBid + " life" + (highBid > 1 ? "s" : "") + ". Top the bid?"; if (currentPlayer.chooseUse(Outcome.Detriment, text, source, game)) { int newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", game); diff --git a/Mage.Sets/src/mage/cards/k/KazuulTyrantOfTheCliffs.java b/Mage.Sets/src/mage/cards/k/KazuulTyrantOfTheCliffs.java index 1e5a4379d0..d72354ef41 100644 --- a/Mage.Sets/src/mage/cards/k/KazuulTyrantOfTheCliffs.java +++ b/Mage.Sets/src/mage/cards/k/KazuulTyrantOfTheCliffs.java @@ -27,6 +27,7 @@ */ package mage.cards.k; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -101,7 +102,7 @@ class KazuulTyrantOfTheCliffsTriggeredAbility extends TriggeredAbilityImpl { Permanent attacker = game.getPermanent(event.getSourceId()); Player defender = game.getPlayer(event.getTargetId()); Player you = game.getPlayer(controllerId); - if (attacker.getControllerId() != you.getId() && defender == you) { + if (!Objects.equals(attacker.getControllerId(), you.getId()) && Objects.equals(defender, you)) { this.getEffects().get(0).setTargetPointer(new FixedTarget(attacker.getControllerId())); return true; } diff --git a/Mage.Sets/src/mage/cards/k/KnowledgeExploitation.java b/Mage.Sets/src/mage/cards/k/KnowledgeExploitation.java index d45bb4d765..bcfa9baee2 100644 --- a/Mage.Sets/src/mage/cards/k/KnowledgeExploitation.java +++ b/Mage.Sets/src/mage/cards/k/KnowledgeExploitation.java @@ -90,7 +90,7 @@ class KnowledgeExploitationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - if (controller != null & opponent != null) { + if (controller != null && opponent != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterInstantOrSorceryCard()); if (controller.searchLibrary(target, game, opponent.getId())) { Card card = opponent.getLibrary().remove(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java b/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java index 5c5dcba548..1d802133f1 100644 --- a/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java +++ b/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java @@ -28,6 +28,7 @@ package mage.cards.k; import java.util.HashMap; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -127,7 +128,7 @@ class KynaiosAndTirosEffect extends OneShotEffect { } } } - if (!playedLand && currentPlayer != controller) { + if (!playedLand && !Objects.equals(currentPlayer, controller)) { noLandPlayers.put(currentPlayer.getId(), playedLand); } } diff --git a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java index 29901f2d75..bb323aeeaf 100644 --- a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java +++ b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java @@ -27,6 +27,7 @@ */ package mage.cards.l; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -93,10 +94,10 @@ class LudevicNecroAlchemistCondition implements Condition { } while (watcher != null && currentPlayer != null) { - if (currentPlayer != null && currentPlayer.getId() != sourcePlayerId && watcher.getLiveLost(currentPlayer.getId()) > 0) { + if (currentPlayer != null && !Objects.equals(currentPlayer.getId(), sourcePlayerId) && watcher.getLiveLost(currentPlayer.getId()) > 0) { return true; } - if (currentPlayer == firstPlayer) { + if (Objects.equals(currentPlayer, firstPlayer)) { return false; } currentPlayer = playerList.getNext(game); diff --git a/Mage.Sets/src/mage/cards/m/MagneticMine.java b/Mage.Sets/src/mage/cards/m/MagneticMine.java index 4b00173891..2d635ef8bf 100644 --- a/Mage.Sets/src/mage/cards/m/MagneticMine.java +++ b/Mage.Sets/src/mage/cards/m/MagneticMine.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.Objects; import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; @@ -86,7 +87,7 @@ class MagneticMineTriggeredAbility extends TriggeredAbilityImpl { if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getTarget().getCardType().contains(CardType.ARTIFACT) - && zEvent.getTarget().getId() != this.getSourceId()) { + && !Objects.equals(zEvent.getTarget().getId(), this.getSourceId())) { this.getTargets().get(0).add(zEvent.getTarget().getControllerId(), game); return true; } diff --git a/Mage.Sets/src/mage/cards/m/ManaChargedDragon.java b/Mage.Sets/src/mage/cards/m/ManaChargedDragon.java index cbbb5d2d59..98ee2da6f8 100644 --- a/Mage.Sets/src/mage/cards/m/ManaChargedDragon.java +++ b/Mage.Sets/src/mage/cards/m/ManaChargedDragon.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -129,7 +130,7 @@ class ManaChargedDragonEffect extends OneShotEffect { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { xSum += playerPaysXGenericMana(player, source, game); diff --git a/Mage.Sets/src/mage/cards/m/ManaWeb.java b/Mage.Sets/src/mage/cards/m/ManaWeb.java index 1897edb76a..33da1af77b 100644 --- a/Mage.Sets/src/mage/cards/m/ManaWeb.java +++ b/Mage.Sets/src/mage/cards/m/ManaWeb.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.Objects; import java.util.UUID; import mage.Mana; import mage.abilities.Ability; @@ -145,7 +146,7 @@ class ManaWebeffect extends OneShotEffect { boolean tappedLands = false; for (Permanent opponentPermanent : game.getBattlefield().getActivePermanents(filter, permanent.getControllerId(), game)) { - if (opponentPermanent.getControllerId() == permanent.getControllerId()) { + if (Objects.equals(opponentPermanent.getControllerId(), permanent.getControllerId())) { Mana opponentLandMana = new Mana(); for (ActivatedManaAbilityImpl ability : opponentPermanent.getAbilities().getAvailableActivatedManaAbilities(Zone.BATTLEFIELD, game)) { diff --git a/Mage.Sets/src/mage/cards/m/MindsAglow.java b/Mage.Sets/src/mage/cards/m/MindsAglow.java index 25a920c4cf..4810ea9247 100644 --- a/Mage.Sets/src/mage/cards/m/MindsAglow.java +++ b/Mage.Sets/src/mage/cards/m/MindsAglow.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; @@ -87,7 +88,7 @@ class MindsAglowEffect extends OneShotEffect { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { xSum += playerPaysXGenericMana(player, source, game); diff --git a/Mage.Sets/src/mage/cards/m/MuragandaPetroglyphs.java b/Mage.Sets/src/mage/cards/m/MuragandaPetroglyphs.java index 78181d7245..9721414ce6 100644 --- a/Mage.Sets/src/mage/cards/m/MuragandaPetroglyphs.java +++ b/Mage.Sets/src/mage/cards/m/MuragandaPetroglyphs.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.Objects; import java.util.UUID; import mage.MageObject; import mage.abilities.Abilities; @@ -98,7 +99,7 @@ class NoAbilityPredicate implements Predicate { } for (Ability ability : abilities) { - if (ability.getClass() != SpellAbility.class) { + if (!Objects.equals(ability.getClass(), SpellAbility.class)) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MysticRemora.java b/Mage.Sets/src/mage/cards/m/MysticRemora.java index 62c0dd8dc4..a88df4a9de 100644 --- a/Mage.Sets/src/mage/cards/m/MysticRemora.java +++ b/Mage.Sets/src/mage/cards/m/MysticRemora.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.Objects; import java.util.UUID; import mage.MageObject; import mage.abilities.costs.mana.ManaCostsImpl; @@ -104,7 +105,7 @@ class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl { if (spell != null && !spell.getCardType().contains(CardType.CREATURE)) { Player controller = game.getPlayer(game.getControllerId(this.controllerId)); Player player = game.getPlayer(spell.getControllerId()); - if (controller != player) { + if (!Objects.equals(controller, player)) { this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); } return true; diff --git a/Mage.Sets/src/mage/cards/n/NightDealings.java b/Mage.Sets/src/mage/cards/n/NightDealings.java index 0e9aad970a..e1d7520cff 100644 --- a/Mage.Sets/src/mage/cards/n/NightDealings.java +++ b/Mage.Sets/src/mage/cards/n/NightDealings.java @@ -27,6 +27,7 @@ */ package mage.cards.n; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -103,7 +104,7 @@ public class NightDealings extends CardImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { // to another player - if (this.getControllerId() != event.getTargetId()) { + if (!Objects.equals(this.getControllerId(), event.getTargetId())) { // a source you control UUID sourceControllerId = game.getControllerId(event.getSourceId()); if (sourceControllerId != null && sourceControllerId.equals(this.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java index f9120163a9..1bd58d36a1 100644 --- a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java +++ b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java @@ -28,6 +28,7 @@ package mage.cards.o; import java.util.ArrayList; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -121,7 +122,7 @@ class OrzhovAdvokistEffect extends OneShotEffect { } } for (UUID playerId : players) { - if (playerId != source.getControllerId()) { + if (!Objects.equals(playerId, source.getControllerId())) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(playerId)); game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter, true), source); diff --git a/Mage.Sets/src/mage/cards/p/PainsReward.java b/Mage.Sets/src/mage/cards/p/PainsReward.java index ad404c5461..eed733fb6e 100644 --- a/Mage.Sets/src/mage/cards/p/PainsReward.java +++ b/Mage.Sets/src/mage/cards/p/PainsReward.java @@ -27,6 +27,7 @@ */ package mage.cards.p; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -91,7 +92,7 @@ class PainsRewardEffect extends OneShotEffect { game.informPlayers(winner.getLogName() + " has bet " + highBid + " lifes"); Player currentPlayer = playerList.getNextInRange(controller, game); - while (currentPlayer != winner) { + while (!Objects.equals(currentPlayer, winner)) { String text = winner.getLogName() + " has bet " + highBid + " life" + (highBid > 1 ? "s" : "") + ". Top the bid?"; if (currentPlayer.chooseUse(Outcome.Detriment, text, source, game)) { int newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose amount of life to bid", game); diff --git a/Mage.Sets/src/mage/cards/p/PsychicPossession.java b/Mage.Sets/src/mage/cards/p/PsychicPossession.java index adfefd8af8..ff766577f3 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicPossession.java +++ b/Mage.Sets/src/mage/cards/p/PsychicPossession.java @@ -27,6 +27,7 @@ */ package mage.cards.p; +import java.util.Objects; import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; @@ -106,7 +107,7 @@ class PsychicPossessionTriggeredAbility extends TriggeredAbilityImpl { if (enchantment != null && enchantment.getAttachedTo() != null) { Player opponent = game.getPlayer(enchantment.getAttachedTo()); Player player = game.getPlayer(event.getPlayerId()); - if (opponent != null && player != null && player == opponent) { + if (opponent != null && player != null && Objects.equals(player, opponent)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/r/ReflectorMage.java b/Mage.Sets/src/mage/cards/r/ReflectorMage.java index 25f2ff182a..3f43c1514b 100644 --- a/Mage.Sets/src/mage/cards/r/ReflectorMage.java +++ b/Mage.Sets/src/mage/cards/r/ReflectorMage.java @@ -27,6 +27,7 @@ */ package mage.cards.r; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -151,7 +152,7 @@ class ExclusionRitualReplacementEffect extends ContinuousRuleModifyingEffectImpl if (spell != null && spell.isFaceDown(game)) { return false; // Face Down cast spell (Morph creature) has no name } - return card.getName().equals(creatureName) && ownerId == card.getOwnerId(); + return card.getName().equals(creatureName) && Objects.equals(ownerId, card.getOwnerId()); } return false; } diff --git a/Mage.Sets/src/mage/cards/r/RocketLauncher.java b/Mage.Sets/src/mage/cards/r/RocketLauncher.java index 43ec23ced0..050d69bbe0 100644 --- a/Mage.Sets/src/mage/cards/r/RocketLauncher.java +++ b/Mage.Sets/src/mage/cards/r/RocketLauncher.java @@ -27,6 +27,7 @@ */ package mage.cards.r; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; @@ -98,7 +99,7 @@ class RocketLauncherWatcher extends Watcher { changedControllerOR1stTurn = false; } if (event.getType() == GameEvent.EventType.LOST_CONTROL && - event.getSourceId()==cardId) { + Objects.equals(event.getSourceId(), cardId)) { changedControllerOR1stTurn = true; } } diff --git a/Mage.Sets/src/mage/cards/s/ScarredPuma.java b/Mage.Sets/src/mage/cards/s/ScarredPuma.java index 2332f6d0b4..05091edd44 100644 --- a/Mage.Sets/src/mage/cards/s/ScarredPuma.java +++ b/Mage.Sets/src/mage/cards/s/ScarredPuma.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.ObjectColor; @@ -95,7 +96,7 @@ public class ScarredPuma extends CardImpl { if (permanent.getId().equals(source.getSourceId())) { for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { //excludes itself (http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=23067) - if (creature.getId() != source.getSourceId()) { + if (!Objects.equals(creature.getId(), source.getSourceId())) { ObjectColor color = creature.getColor(game); if (color.isBlack() || color.isGreen()) { return false; diff --git a/Mage.Sets/src/mage/cards/s/SharedTrauma.java b/Mage.Sets/src/mage/cards/s/SharedTrauma.java index abc3dbee03..753a1693a6 100644 --- a/Mage.Sets/src/mage/cards/s/SharedTrauma.java +++ b/Mage.Sets/src/mage/cards/s/SharedTrauma.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; @@ -89,7 +90,7 @@ class SharedTraumaEffect extends OneShotEffect { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != controller.getId()) { + if (!Objects.equals(playerId, controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { xSum += playerPaysXGenericMana(player, source, game); diff --git a/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java b/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java index d7e9c419c1..a1772568d5 100644 --- a/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java +++ b/Mage.Sets/src/mage/cards/s/ShattergangBrothers.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -117,7 +118,7 @@ class ShattergangBrothersEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != source.getControllerId()) { + if (!Objects.equals(playerId, source.getControllerId())) { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(filter); diff --git a/Mage.Sets/src/mage/cards/s/SkullRend.java b/Mage.Sets/src/mage/cards/s/SkullRend.java index ff35dca3f6..21b297aa09 100644 --- a/Mage.Sets/src/mage/cards/s/SkullRend.java +++ b/Mage.Sets/src/mage/cards/s/SkullRend.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.Objects; import java.util.UUID; import mage.constants.CardType; @@ -79,7 +80,7 @@ public class SkullRend extends CardImpl { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != source.getControllerId()) { + if (!Objects.equals(playerId, source.getControllerId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { // damage diff --git a/Mage.Sets/src/mage/cards/s/SpikeCannibal.java b/Mage.Sets/src/mage/cards/s/SpikeCannibal.java index c64be49332..bc2ed4fea1 100644 --- a/Mage.Sets/src/mage/cards/s/SpikeCannibal.java +++ b/Mage.Sets/src/mage/cards/s/SpikeCannibal.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -102,7 +103,7 @@ class SpikeCannibalEffect extends OneShotEffect { if (sourcePermanent != null) { for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { - if (creature != sourcePermanent) { + if (!Objects.equals(creature, sourcePermanent)) { int numberCounters = creature.getCounters(game).getCount(CounterType.P1P1); if (numberCounters > 0) { creature.removeCounters(CounterType.P1P1.getName(), numberCounters, game); diff --git a/Mage.Sets/src/mage/cards/s/SpreadingPlague.java b/Mage.Sets/src/mage/cards/s/SpreadingPlague.java index 95fe8d4a1c..a28a71ab74 100644 --- a/Mage.Sets/src/mage/cards/s/SpreadingPlague.java +++ b/Mage.Sets/src/mage/cards/s/SpreadingPlague.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.Objects; import java.util.UUID; import mage.ObjectColor; import mage.abilities.Ability; @@ -93,7 +94,7 @@ class SpreadingPlagueEffect extends OneShotEffect { ObjectColor color = creature.getColor(game); for (Permanent permanent : game.getBattlefield().getActivePermanents(FILTER, source.getControllerId(), game)) { if (permanent.getColor(game).shares(color) - && permanent != creature) { + && !Objects.equals(permanent, creature)) { permanent.destroy(source.getSourceId(), game, true); } } diff --git a/Mage.Sets/src/mage/cards/s/Sunforger.java b/Mage.Sets/src/mage/cards/s/Sunforger.java index 1c79ff1fb2..f43b22ad5b 100644 --- a/Mage.Sets/src/mage/cards/s/Sunforger.java +++ b/Mage.Sets/src/mage/cards/s/Sunforger.java @@ -156,7 +156,7 @@ class SunforgerUnattachCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent attachment = game.getPermanent(sourceId); - if (attachment != null & attachment.getAttachedTo() != null) { + if (attachment != null && attachment.getAttachedTo() != null) { Permanent attachedTo = game.getPermanent(attachment.getAttachedTo()); if (attachedTo != null) { paid = attachedTo.removeAttachment(attachment.getId(), game); diff --git a/Mage.Sets/src/mage/cards/t/TerritorialGorger.java b/Mage.Sets/src/mage/cards/t/TerritorialGorger.java index 21cddf79fd..7e9674daf4 100644 --- a/Mage.Sets/src/mage/cards/t/TerritorialGorger.java +++ b/Mage.Sets/src/mage/cards/t/TerritorialGorger.java @@ -27,6 +27,7 @@ */ package mage.cards.t; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; @@ -92,7 +93,7 @@ class TerritorialGorgerTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getData().equals(CounterType.ENERGY.getName())) { - return event.getTargetId() == this.getControllerId(); + return Objects.equals(event.getTargetId(), this.getControllerId()); } return false; } diff --git a/Mage.Sets/src/mage/cards/t/TrostaniSelesnyasVoice.java b/Mage.Sets/src/mage/cards/t/TrostaniSelesnyasVoice.java index 1467b36fef..386f02d329 100644 --- a/Mage.Sets/src/mage/cards/t/TrostaniSelesnyasVoice.java +++ b/Mage.Sets/src/mage/cards/t/TrostaniSelesnyasVoice.java @@ -28,6 +28,7 @@ package mage.cards.t; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -102,7 +103,7 @@ class TrostaniSelesnyasVoiceTriggeredAbility extends TriggeredAbilityImpl { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent.getCardType().contains(CardType.CREATURE) && permanent.getControllerId().equals(this.controllerId) - && event.getTargetId() != this.getSourceId()) { + && !Objects.equals(event.getTargetId(), this.getSourceId())) { Effect effect = this.getEffects().get(0); // life is determined during resolution so it has to be retrieved there (e.g. Giant Growth before resolution) effect.setValue("lifeSource", event.getTargetId()); diff --git a/Mage.Sets/src/mage/cards/u/UrborgSyphonMage.java b/Mage.Sets/src/mage/cards/u/UrborgSyphonMage.java index 7cd3547817..b236b4db6a 100644 --- a/Mage.Sets/src/mage/cards/u/UrborgSyphonMage.java +++ b/Mage.Sets/src/mage/cards/u/UrborgSyphonMage.java @@ -27,6 +27,7 @@ */ package mage.cards.u; +import java.util.Objects; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -91,7 +92,7 @@ class UrborgSyphonMageEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - if (playerId != source.getControllerId()) { + if (!Objects.equals(playerId, source.getControllerId())) { Player player = game.getPlayer(playerId); if (player != null) { damage += player.damage(2, source.getSourceId(), game, false, true); diff --git a/Mage.Sets/src/mage/cards/v/Venom.java b/Mage.Sets/src/mage/cards/v/Venom.java index 08327d55e5..d9be09396d 100644 --- a/Mage.Sets/src/mage/cards/v/Venom.java +++ b/Mage.Sets/src/mage/cards/v/Venom.java @@ -27,6 +27,7 @@ */ package mage.cards.v; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -110,13 +111,13 @@ class VenomTriggeredAbility extends TriggeredAbilityImpl { if (enchantment != null && enchantment.getAttachedTo() != null) { Permanent enchantedCreature = game.getPermanent(enchantment.getAttachedTo()); if (enchantedCreature != null) { - if (blocker != null && blocker != enchantedCreature + if (blocker != null && !Objects.equals(blocker, enchantedCreature) && !blocker.getSubtype(game).contains("Wall") - && blocked == enchantedCreature) { + && Objects.equals(blocked, enchantedCreature)) { this.getEffects().get(0).setTargetPointer(new FixedTarget(blocker.getId())); return true; } - if (blocker != null && blocker == enchantedCreature + if (blocker != null && Objects.equals(blocker, enchantedCreature) && !blocked.getSubtype(game).contains("Wall")) { this.getEffects().get(0).setTargetPointer(new FixedTarget(blocked.getId())); return true; diff --git a/Mage.Sets/src/mage/cards/w/WeightOfConscience.java b/Mage.Sets/src/mage/cards/w/WeightOfConscience.java index 79218ba436..dad82f569f 100644 --- a/Mage.Sets/src/mage/cards/w/WeightOfConscience.java +++ b/Mage.Sets/src/mage/cards/w/WeightOfConscience.java @@ -28,6 +28,7 @@ package mage.cards.w; import java.util.HashSet; +import java.util.Objects; import java.util.Set; import java.util.UUID; import mage.abilities.Ability; @@ -171,7 +172,7 @@ class WeightOfConscienceTarget extends TargetControlledCreaturePermanent { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { for (Permanent permanent1 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, game)) { for (Permanent permanent2 : game.getBattlefield().getActivePermanents(filterUntapped, sourceControllerId, game)) { - if (permanent1 != permanent2 && CardUtil.shareSubtypes(permanent1, permanent2, game)) { + if (!Objects.equals(permanent1, permanent2) && CardUtil.shareSubtypes(permanent1, permanent2, game)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/w/Worldslayer.java b/Mage.Sets/src/mage/cards/w/Worldslayer.java index c39911075a..8a71eee020 100644 --- a/Mage.Sets/src/mage/cards/w/Worldslayer.java +++ b/Mage.Sets/src/mage/cards/w/Worldslayer.java @@ -28,6 +28,7 @@ package mage.cards.w; import java.util.List; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -125,7 +126,7 @@ class WorldslayerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { List permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game); for (Permanent permanent : permanents) { - if (permanent.getId() != source.getSourceId()) { + if (!Objects.equals(permanent.getId(), source.getSourceId())) { permanent.destroy(source.getSourceId(), game, false); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestBase.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestBase.java index 84fb5ef357..27d980f32f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestBase.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestBase.java @@ -28,6 +28,7 @@ import org.mage.test.player.TestPlayer; import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; +import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -135,7 +136,7 @@ public abstract class MageTestBase { try { classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL()); logger.info("Loading game type: " + plugin.getClassName()); - return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance(); + return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).getConstructor().newInstance(); } catch (ClassNotFoundException ex) { logger.warn("Game type not found:" + plugin.getJar() + " - check plugin folder"); } catch (Exception ex) { @@ -148,7 +149,7 @@ public abstract class MageTestBase { try { classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL()); logger.info("Loading tournament type: " + plugin.getClassName()); - return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance(); + return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).getConstructor().newInstance(); } catch (ClassNotFoundException ex) { logger.warn("Tournament type not found:" + plugin.getJar() + " - check plugin folder"); } catch (Exception ex) { diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java index 265495fbe9..698271e521 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java @@ -26,6 +26,7 @@ import org.mage.test.player.TestPlayer; import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; +import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -121,7 +122,7 @@ public abstract class MageTestPlayerBase { try { classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL()); logger.info("Loading game type: " + plugin.getClassName()); - return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance(); + return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).getConstructor().newInstance(); } catch (ClassNotFoundException ex) { logger.warn("Game type not found:" + plugin.getJar() + " - check plugin folder"); } catch (Exception ex) { @@ -134,7 +135,7 @@ public abstract class MageTestPlayerBase { try { classLoader.addURL(new File(pluginFolder + '/' + plugin.getJar()).toURI().toURL()); logger.info("Loading tournament type: " + plugin.getClassName()); - return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance(); + return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).getConstructor().newInstance(); } catch (ClassNotFoundException ex) { logger.warn("Tournament type not found:" + plugin.getJar() + " - check plugin folder"); } catch (Exception ex) { diff --git a/Mage/src/main/java/mage/MageInt.java b/Mage/src/main/java/mage/MageInt.java index f931b6577d..b4dbc0a8df 100644 --- a/Mage/src/main/java/mage/MageInt.java +++ b/Mage/src/main/java/mage/MageInt.java @@ -28,6 +28,8 @@ package mage; import java.io.Serializable; +import java.util.Objects; + import mage.util.Copyable; public class MageInt implements Serializable, Copyable { @@ -75,7 +77,7 @@ public class MageInt implements Serializable, Copyable { @Override public MageInt copy() { - if (this == EmptyMageInt) { + if (Objects.equals(this, EmptyMageInt)) { return this; } return new MageInt(baseValue, baseValueModified, boostedValue, cardValue); diff --git a/Mage/src/main/java/mage/ObjectColor.java b/Mage/src/main/java/mage/ObjectColor.java index fe73f3d829..c0f019be4a 100644 --- a/Mage/src/main/java/mage/ObjectColor.java +++ b/Mage/src/main/java/mage/ObjectColor.java @@ -30,6 +30,8 @@ package mage; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Objects; + import mage.constants.ColoredManaSymbol; import mage.util.Copyable; @@ -89,11 +91,11 @@ public class ObjectColor implements Serializable, Copyable, Compara */ public ObjectColor union(ObjectColor other) { ObjectColor newColor = new ObjectColor(); - newColor.white = white | other.white; - newColor.blue = blue | other.blue; - newColor.black = black | other.black; - newColor.red = red | other.red; - newColor.green = green | other.green; + newColor.white = white || other.white; + newColor.blue = blue || other.blue; + newColor.black = black || other.black; + newColor.red = red || other.red; + newColor.green = green || other.green; return newColor; } @@ -168,20 +170,20 @@ public class ObjectColor implements Serializable, Copyable, Compara } public boolean hasColor() { - return white | blue | black | red | green; + return white || blue || black || red || green; } public boolean isMulticolored() { if (isColorless()) { return false; } - if (white && (blue | black | red | green)) { + if (white && (blue || black || red || green)) { return true; } - if (blue && (black | red | green)) { + if (blue && (black || red || green)) { return true; } - if (black && (red | green)) { + if (black && (red || green)) { return true; } return red && green; @@ -307,22 +309,22 @@ public class ObjectColor implements Serializable, Copyable, Compara } public boolean contains(ObjectColor color) { - if (this == color) { + if (Objects.equals(this, color)) { return true; } - if (color.white & this.white) { + if (color.white && this.white) { return true; } - if (color.blue & this.blue) { + if (color.blue && this.blue) { return true; } - if (color.black & this.black) { + if (color.black && this.black) { return true; } - if (color.red & this.red) { + if (color.red && this.red) { return true; } - if (color.green & this.green) { + if (color.green && this.green) { return true; } return false; diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAloneTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAloneTriggeredAbility.java index bcbf272c1e..93dbc7022c 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAloneTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAloneTriggeredAbility.java @@ -27,6 +27,7 @@ */ package mage.abilities.common; +import java.util.Objects; import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; @@ -65,7 +66,7 @@ public class AttacksAloneTriggeredAbility extends TriggeredAbilityImpl { if(game.getActivePlayerId().equals(this.controllerId) ) { UUID creatureId = this.getSourceId(); if(creatureId != null) { - if(game.getCombat().attacksAlone() && creatureId == game.getCombat().getAttackers().get(0)) { + if(game.getCombat().attacksAlone() && Objects.equals(creatureId, game.getCombat().getAttackers().get(0))) { UUID defender = game.getCombat().getDefenderId(creatureId); if(defender != null) { for(Effect effect: getEffects()) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceOnBattlefieldControlUnchangedCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceOnBattlefieldControlUnchangedCondition.java index 0032e72812..8583256ef9 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceOnBattlefieldControlUnchangedCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceOnBattlefieldControlUnchangedCondition.java @@ -27,6 +27,7 @@ */ package mage.abilities.condition.common; +import java.util.Objects; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.condition.Condition; @@ -50,7 +51,7 @@ public class SourceOnBattlefieldControlUnchangedCondition implements Condition { controllerId = source.getControllerId(); } Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); - return (permanent != null && controllerId == source.getControllerId()); + return (permanent != null && Objects.equals(controllerId, source.getControllerId())); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CantBeRegeneratedSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CantBeRegeneratedSourceEffect.java index 34d107f71b..96bbda16b1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CantBeRegeneratedSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CantBeRegeneratedSourceEffect.java @@ -36,6 +36,8 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import java.util.Objects; + /** * * @author jeffwadsworth @@ -67,7 +69,7 @@ public class CantBeRegeneratedSourceEffect extends ContinuousRuleModifyingEffect @Override public boolean applies(GameEvent event, Ability source, Game game) { - return source.getSourceId() == event.getTargetId(); + return Objects.equals(source.getSourceId(), event.getTargetId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java b/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java index 87ddd2f748..48dd521d77 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/EpicEffect.java @@ -19,6 +19,8 @@ import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.players.Player; +import java.util.Objects; + /** * * @author jeffwadsworth @@ -112,7 +114,7 @@ class EpicReplacementEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (source.getControllerId() == event.getPlayerId()) { + if (Objects.equals(source.getControllerId(), event.getPlayerId())) { MageObject object = game.getObject(event.getSourceId()); if (object != null) { return true; diff --git a/Mage/src/main/java/mage/filter/FilterImpl.java b/Mage/src/main/java/mage/filter/FilterImpl.java index 5d6cd75e86..b48a94901e 100644 --- a/Mage/src/main/java/mage/filter/FilterImpl.java +++ b/Mage/src/main/java/mage/filter/FilterImpl.java @@ -78,4 +78,9 @@ public abstract class FilterImpl implements Filter { public void setMessage(String message) { this.message = message; } + + @Override + public String toString() { + return message; + } } diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 981b743f15..56fdedf86f 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -29,20 +29,9 @@ package mage.game; import java.io.IOException; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; -import java.util.Stack; -import java.util.UUID; + import mage.MageException; import mage.MageObject; import mage.abilities.Ability; @@ -2010,7 +1999,7 @@ public abstract class GameImpl implements Game, Serializable { } } for (Permanent permanent : worldEnchantment) { - if (newestPermanent != permanent) { + if (!Objects.equals(newestPermanent, permanent)) { movePermanentToGraveyardWithInfo(permanent); somethingHappened = true; } diff --git a/Mage/src/main/java/mage/game/GameState.java b/Mage/src/main/java/mage/game/GameState.java index 1a7e839531..4b545ea161 100644 --- a/Mage/src/main/java/mage/game/GameState.java +++ b/Mage/src/main/java/mage/game/GameState.java @@ -28,18 +28,8 @@ package mage.game; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; + import mage.MageObject; import mage.abilities.Abilities; import mage.abilities.Ability; @@ -360,7 +350,7 @@ public class GameState implements Serializable, Copyable { for (Player player : players.values()) { sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand"); - if (playerId == player.getId()) { + if (Objects.equals(playerId, player.getId())) { sb.append(player.getHand().getValue(game)); } else { sb.append(player.getHand().size()); diff --git a/Mage/src/main/java/mage/game/ZonesHandler.java b/Mage/src/main/java/mage/game/ZonesHandler.java index 9f293231bd..8187267237 100644 --- a/Mage/src/main/java/mage/game/ZonesHandler.java +++ b/Mage/src/main/java/mage/game/ZonesHandler.java @@ -184,9 +184,9 @@ public class ZonesHandler { ZoneChangeInfo subInfo = itr.next(); if (!maybeRemoveFromSourceZone(subInfo, game)) { itr.remove(); - } else if (subInfo.event.getTargetId() == meld.getTopHalfCard().getId()) { + } else if (Objects.equals(subInfo.event.getTargetId(), meld.getTopHalfCard().getId())) { meld.setTopLastZoneChangeCounter(meld.getTopHalfCard().getZoneChangeCounter(game)); - } else if (subInfo.event.getTargetId() == meld.getBottomHalfCard().getId()) { + } else if (Objects.equals(subInfo.event.getTargetId(), meld.getBottomHalfCard().getId())) { meld.setBottomLastZoneChangeCounter(meld.getBottomHalfCard().getZoneChangeCounter(game)); } } diff --git a/Mage/src/main/java/mage/game/draft/DraftCube.java b/Mage/src/main/java/mage/game/draft/DraftCube.java index 8a9c1cb647..bd64bfdd34 100644 --- a/Mage/src/main/java/mage/game/draft/DraftCube.java +++ b/Mage/src/main/java/mage/game/draft/DraftCube.java @@ -29,6 +29,7 @@ package mage.game.draft; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import mage.cards.Card; import mage.cards.repository.CardCriteria; @@ -146,7 +147,7 @@ public abstract class DraftCube { } for (int i = leftCubeCards.size() - 1; i >= 0; i--) { - if (leftCubeCards.get(i) == cardId) { + if (Objects.equals(leftCubeCards.get(i), cardId)) { leftCubeCards.remove(i); return; } diff --git a/Mage/src/main/java/mage/game/draft/DraftImpl.java b/Mage/src/main/java/mage/game/draft/DraftImpl.java index f0a73ce0d9..c76b6fd774 100644 --- a/Mage/src/main/java/mage/game/draft/DraftImpl.java +++ b/Mage/src/main/java/mage/game/draft/DraftImpl.java @@ -28,13 +28,8 @@ package mage.game.draft; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; + import mage.cards.Card; import mage.cards.ExpansionSet; import mage.game.draft.DraftOptions.TimingOption; @@ -197,7 +192,7 @@ public abstract class DraftImpl implements Draft { while (true) { List nextBooster = next.booster; next.setBooster(currentBooster); - if (nextId == startId) { + if (Objects.equals(nextId, startId)) { break; } currentBooster = nextBooster; @@ -218,7 +213,7 @@ public abstract class DraftImpl implements Draft { while (true) { List prevBooster = prev.booster; prev.setBooster(currentBooster); - if (prevId == startId) { + if (Objects.equals(prevId, startId)) { break; } currentBooster = prevBooster; diff --git a/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java b/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java index 2cf844e797..a18caf14dc 100644 --- a/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java +++ b/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java @@ -28,6 +28,7 @@ package mage.game.draft; import java.util.List; +import java.util.Objects; import java.util.UUID; import mage.cards.Card; import mage.cards.ExpansionSet; @@ -69,7 +70,7 @@ public class RichManBoosterDraft extends DraftImpl { while (true) { List nextBooster = sets.get(cardNum % sets.size()).createBooster(); next.setBooster(nextBooster); - if (nextId == startId) { + if (Objects.equals(nextId, startId)) { break; } nextId = table.getNext(); diff --git a/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java b/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java index 548b366ab8..724a4ac891 100644 --- a/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java +++ b/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java @@ -27,10 +27,8 @@ */ package mage.game.draft; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; + import mage.cards.Card; import mage.cards.ExpansionSet; import mage.game.draft.DraftCube.CardIdentity; @@ -90,7 +88,7 @@ public class RichManCubeBoosterDraft extends DraftImpl { List nextBooster = draftCube.createBooster(); next.setBooster(nextBooster); - if (nextId == startId) { + if (Objects.equals(nextId, startId)) { break; } nextId = table.getNext(); diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 3d93c69198..2160a426cb 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -27,14 +27,8 @@ */ package mage.game.permanent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; + import mage.MageObject; import mage.MageObjectReference; import mage.ObjectColor; @@ -667,7 +661,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { @Override public void attachTo(UUID permanentId, Game game) { - if (this.attachedTo != null && this.attachedTo != permanentId) { + if (this.attachedTo != null && !Objects.equals(this.attachedTo, permanentId)) { Permanent attachment = game.getPermanent(this.attachedTo); if (attachment != null) { attachment.removeAttachment(this.objectId, game); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 9f972c8c36..e162bc382d 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1291,7 +1291,7 @@ public abstract class PlayerImpl implements Player, Serializable { if (zone != Zone.BATTLEFIELD && game.getContinuousEffects().asThough(object.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, this.getId(), game)) { for (Ability ability : object.getAbilities()) { if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) { - if (ability.getManaCosts().isEmpty() && ability.getCosts().isEmpty() && ability instanceof SpellAbility && !(ability.getSourceId() == getCastSourceIdWithAlternateMana())) { + if (ability.getManaCosts().isEmpty() && ability.getCosts().isEmpty() && ability instanceof SpellAbility && !(Objects.equals(ability.getSourceId(), getCastSourceIdWithAlternateMana()))) { continue; // You can't play spells that have no costs, unless you can play them without paying their mana costs } ability.setControllerId(this.getId()); @@ -1679,7 +1679,7 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public boolean isLifeTotalCanChange() { - return canGainLife | canLoseLife; + return canGainLife || canLoseLife; } @Override @@ -3247,7 +3247,7 @@ public abstract class PlayerImpl implements Player, Serializable { // move cards to graveyard in order the owner decides if (!cards.isEmpty()) { Player choosingPlayer = this; - if (ownerId != this.getId()) { + if (!Objects.equals(ownerId, this.getId())) { choosingPlayer = game.getPlayer(ownerId); } if (choosingPlayer == null) { diff --git a/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java b/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java index 0174e82ce2..bf2d2f77b6 100644 --- a/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CastFromHandWatcher.java @@ -1,6 +1,7 @@ package mage.watchers.common; import java.util.HashSet; +import java.util.Objects; import java.util.Set; import java.util.UUID; import mage.constants.WatcherScope; @@ -32,7 +33,7 @@ public class CastFromHandWatcher extends Watcher { * reset if the game comes to a new step */ - if (step != null && game.getTurn().getStep() != step) { + if (step != null && !Objects.equals(game.getTurn().getStep(), step)) { spellsCastFromHand.clear(); step = null; } diff --git a/Mage/src/test/java/mage/ManaTest.java b/Mage/src/test/java/mage/ManaTest.java index 0303469052..b40b0a4562 100644 --- a/Mage/src/test/java/mage/ManaTest.java +++ b/Mage/src/test/java/mage/ManaTest.java @@ -10,6 +10,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import java.util.Objects; + /** * Custom unit tests for {link Mana}. * @@ -525,7 +527,7 @@ public class ManaTest { // then assertEquals(mana, copy); // are equal - assertFalse(mana == copy); // are not the same object + assertFalse(Objects.equals(mana, copy)); // are not the same object } @Test @@ -603,7 +605,7 @@ public class ManaTest { // then assertEquals(mana, newMana); - assertFalse(mana == newMana); + assertFalse(Objects.equals(mana, newMana)); } @Test diff --git a/Mage/src/test/java/mage/counters/CounterTest.java b/Mage/src/test/java/mage/counters/CounterTest.java index 6d0037f5f3..70c33aab49 100644 --- a/Mage/src/test/java/mage/counters/CounterTest.java +++ b/Mage/src/test/java/mage/counters/CounterTest.java @@ -4,6 +4,8 @@ import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; +import java.util.Objects; + /** * Custom unit tests for {@link Counter} */ @@ -58,7 +60,7 @@ public class CounterTest { // then assertEquals(copy, counter); - assertFalse(copy == counter); + assertFalse(Objects.equals(copy, counter)); } @Test