diff --git a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java index fc24968fc7..14ec6de8b2 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java @@ -85,7 +85,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener { } public void loadBooster(CardsView booster, BigCard bigCard) { - if (booster instanceof CardsView && booster.size() == 0) { + if (booster instanceof CardsView && booster.isEmpty()) { emptyGrid = true; } else { if (!emptyGrid) { diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java index 19ac164198..cb6c9779b1 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java @@ -126,7 +126,7 @@ public class ChoiceDialog extends IDialogPanel { } private void displayCards(CardsView cards, UUID gameId, BigCard bigCard) { - if (cards.size() == 0) { + if (cards.isEmpty()) { return; } diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/StackDialog.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/StackDialog.java index 9a8f65f618..9c239e29bc 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/StackDialog.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/StackDialog.java @@ -103,7 +103,7 @@ public class StackDialog extends IDialogPanel { private void displayStack(CardsView cards, UUID gameId, BigCard bigCard) { - if (cards == null || cards.size() == 0) { + if (cards == null || cards.isEmpty()) { return; } diff --git a/Mage.Client/src/main/java/mage/client/dialog/ResetPasswordDialog.java b/Mage.Client/src/main/java/mage/client/dialog/ResetPasswordDialog.java index fa5db9f4a1..868ee2818e 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/ResetPasswordDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/ResetPasswordDialog.java @@ -259,7 +259,7 @@ public class ResetPasswordDialog extends MageDialog { }// //GEN-END:initComponents private void btnGetAuthTokenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGetAuthTokenActionPerformed - if (this.txtEmail.getText().length() == 0) { + if (this.txtEmail.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter an email address."); return; } @@ -275,15 +275,15 @@ public class ResetPasswordDialog extends MageDialog { }//GEN-LAST:event_btnGetAuthTokenActionPerformed private void btnSubmitNewPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitNewPasswordActionPerformed - if (this.txtEmail.getText().length() == 0) { + if (this.txtEmail.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter an email address."); return; } - if (this.txtAuthToken.getText().length() == 0) { + if (this.txtAuthToken.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter an auth token."); return; } - if (this.txtPassword.getText().length() == 0) { + if (this.txtPassword.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter a new password."); return; } diff --git a/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java b/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java index b38caafc3c..295c360b98 100644 --- a/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java @@ -166,7 +166,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel { private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed if (!this.cbPlayerType.getSelectedItem().equals("Human")) { this.pnlPlayerName.setVisible(true); - if (this.txtPlayerName.getText().length() == 0) { + if (this.txtPlayerName.getText().isEmpty()) { this.txtPlayerName.setText("Computer " + this.lblPlayerNum.getText()); } } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java b/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java index 526eec50cb..cd62bb3041 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/GlowText.java @@ -153,7 +153,7 @@ public class GlowText extends JLabel { @Override public void paint(Graphics g) { - if (getText().length() == 0) { + if (getText().isEmpty()) { return; } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java b/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java index 6b62e3f738..c5d11d10a8 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/ManaSymbols.java @@ -217,7 +217,7 @@ public class ManaSymbols { loadSymbolsImages(symbolWidth); } Map sizedSymbols = manaImages.get(symbolWidth); - if (manaCost.length() == 0) { + if (manaCost.isEmpty()) { return; } manaCost = manaCost.replace("\\", ""); 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 41a2fe6bdd..0ff1ec0105 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 @@ -98,7 +98,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab ArrayList cards = getNeededCards(allCards); /* - * if (cards == null || cards.size() == 0) { + * if (cards == null || cards.isEmpty()) { * JOptionPane.showMessageDialog(null, * "All card pictures have been downloaded."); return; } */ diff --git a/Mage.Common/src/mage/remote/SessionImpl.java b/Mage.Common/src/mage/remote/SessionImpl.java index 4960fdfd74..a58b7442f7 100644 --- a/Mage.Common/src/mage/remote/SessionImpl.java +++ b/Mage.Common/src/mage/remote/SessionImpl.java @@ -27,22 +27,6 @@ */ package mage.remote; -import java.io.IOException; -import java.lang.reflect.UndeclaredThrowableException; -import java.net.Authenticator; -import java.net.ConnectException; -import java.net.MalformedURLException; -import java.net.PasswordAuthentication; -import java.net.SocketException; -import java.net.SocketTimeoutException; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.TimeUnit; import mage.MageException; import mage.cards.decks.DeckCardLists; import mage.cards.decks.InvalidDeckException; @@ -62,22 +46,9 @@ import mage.interfaces.ServerState; import mage.interfaces.callback.ClientCallback; import mage.players.net.UserData; import mage.utils.CompressUtil; -import mage.view.DraftPickView; -import mage.view.GameTypeView; -import mage.view.MatchView; -import mage.view.RoomUsersView; -import mage.view.TableView; -import mage.view.TournamentTypeView; -import mage.view.TournamentView; -import mage.view.UserView; +import mage.view.*; import org.apache.log4j.Logger; -import org.jboss.remoting.CannotConnectException; -import org.jboss.remoting.Client; -import org.jboss.remoting.ConnectionListener; -import org.jboss.remoting.ConnectionValidator; -import org.jboss.remoting.InvocationFailureException; -import org.jboss.remoting.InvokerLocator; -import org.jboss.remoting.Remoting; +import org.jboss.remoting.*; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; @@ -85,6 +56,12 @@ import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.remoting.transporter.TransporterClient; +import java.io.IOException; +import java.lang.reflect.UndeclaredThrowableException; +import java.net.*; +import java.util.*; +import java.util.concurrent.TimeUnit; + /** * * @author BetaSteward_at_googlemail.com diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java index 39b0266060..fff24fdf6b 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java @@ -185,7 +185,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ { if (logger.isInfoEnabled()) { printOutState(game); } - if (actions.size() == 0) { + if (actions.isEmpty()) { calculateActions(game); } act(game); @@ -351,7 +351,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ { /* * // Try to fix horizon effect if (root.combat == null || - * root.combat.getAttackers().size() == 0) { + * root.combat.getAttackers().isEmpty()) { * FilterCreatureForAttack attackFilter = new * FilterCreatureForAttack(); * attackFilter.getControllerId().add(playerId); List diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java index 1f3069ac0c..a49c7ca7a0 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer7.java @@ -105,7 +105,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 { case PRECOMBAT_MAIN: if (game.getActivePlayerId().equals(playerId)) { printOutState(game); - if (actions.size() == 0) { + if (actions.isEmpty()) { logger.info("Sim Calculate pre combat actions ----------------------------------------------------- "); calculatePreCombatActions(game); } @@ -122,7 +122,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 { case DECLARE_ATTACKERS: if (!game.getActivePlayerId().equals(playerId)) { printOutState(game); - if (actions.size() == 0) { + if (actions.isEmpty()) { logger.info("Sim Calculate declare attackers actions ----------------------------------------------------- "); calculatePreCombatActions(game); } @@ -142,7 +142,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 { case POSTCOMBAT_MAIN: // if (game.getActivePlayerId().equals(playerId)) { printOutState(game); - if (actions.size() == 0) { + if (actions.isEmpty()) { calculatePostCombatActions(game); } act(game); diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java index bc43063666..3141c5227e 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer2.java @@ -117,7 +117,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player { case COMBAT_DAMAGE: case END_COMBAT: case POSTCOMBAT_MAIN: - if (actions.size() == 0) { + if (actions.isEmpty()) { calculateActions(game); } act(game); @@ -131,7 +131,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player { } protected void act(Game game) { - if (actions == null || actions.size() == 0) + if (actions == null || actions.isEmpty()) pass(game); else { boolean usedStack = false; diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java index c01bed8a68..2ceb791e15 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/ComputerPlayer3.java @@ -78,7 +78,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player { return false; case PRECOMBAT_MAIN: if (game.getActivePlayerId().equals(playerId)) { - if (actions.size() == 0) { + if (actions.isEmpty()) { calculatePreCombatActions(game); } act(game); @@ -92,7 +92,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player { return false; case DECLARE_ATTACKERS: if (!game.getActivePlayerId().equals(playerId)) { - if (actions.size() == 0) { + if (actions.isEmpty()) { calculatePreCombatActions(game); } act(game); @@ -109,7 +109,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player { return false; case POSTCOMBAT_MAIN: if (game.getActivePlayerId().equals(playerId)) { - if (actions.size() == 0) { + if (actions.isEmpty()) { calculatePostCombatActions(game); } act(game); diff --git a/Mage.Server/src/main/java/mage/server/GmailClient.java b/Mage.Server/src/main/java/mage/server/GmailClient.java index 3edc2f307e..daf6b9d694 100644 --- a/Mage.Server/src/main/java/mage/server/GmailClient.java +++ b/Mage.Server/src/main/java/mage/server/GmailClient.java @@ -63,7 +63,7 @@ public class GmailClient { } public static boolean sendMessage(String email, String subject, String text) { - if (email.length() == 0) { + if (email.isEmpty()) { logger.info("Email is not sent because the address is empty"); return false; } diff --git a/Mage.Server/src/main/java/mage/server/MailClient.java b/Mage.Server/src/main/java/mage/server/MailClient.java index 9c7ef61458..16c8f3ae59 100644 --- a/Mage.Server/src/main/java/mage/server/MailClient.java +++ b/Mage.Server/src/main/java/mage/server/MailClient.java @@ -15,7 +15,7 @@ public class MailClient { private static final Logger logger = Logger.getLogger(Main.class); public static boolean sendMessage(String email, String subject, String text) { - if (email.length() == 0) { + if (email.isEmpty()) { logger.info("Email is not sent because the address is empty"); return false; } diff --git a/Mage.Server/src/main/java/mage/server/MailgunClient.java b/Mage.Server/src/main/java/mage/server/MailgunClient.java index 77ba777783..45b3557aa6 100644 --- a/Mage.Server/src/main/java/mage/server/MailgunClient.java +++ b/Mage.Server/src/main/java/mage/server/MailgunClient.java @@ -14,7 +14,7 @@ public class MailgunClient { private static final Logger logger = Logger.getLogger(Main.class); public static boolean sendMessage(String email, String subject, String text) { - if (email.length() == 0) { + if (email.isEmpty()) { logger.info("Email is not sent because the address is empty"); return false; } 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 4bae78ba57..0e40dd5d1a 100644 --- a/Mage.Server/src/main/java/mage/server/util/SystemUtil.java +++ b/Mage.Server/src/main/java/mage/server/util/SystemUtil.java @@ -55,7 +55,7 @@ public class SystemUtil { try { while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); - if (line.trim().length() == 0 || line.startsWith("#")) { + if (line.trim().isEmpty() || line.startsWith("#")) { continue; } diff --git a/Mage.Sets/src/mage/sets/avacynrestored/WildDefiance.java b/Mage.Sets/src/mage/sets/avacynrestored/WildDefiance.java index 858c6b9a85..3b6f2e3747 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/WildDefiance.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/WildDefiance.java @@ -95,7 +95,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI if (object != null && object instanceof Spell) { Card c = (Spell) object; if (c.getCardType().contains(CardType.INSTANT) || c.getCardType().contains(CardType.SORCERY)) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java b/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java index 3291410245..629ba1884b 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/NezumiGraverobber.java @@ -102,7 +102,7 @@ class NezumiGraverobberFlipEffect extends OneShotEffect { if (card != null) { Player player = game.getPlayer(card.getOwnerId()); if (player != null) { - if (player.getGraveyard().size() == 0) { + if (player.getGraveyard().isEmpty()) { return new FlipSourceEffect(new NighteyesTheDesecratorToken()).apply(game, source); } } diff --git a/Mage.Sets/src/mage/sets/commander/DesecratorHag.java b/Mage.Sets/src/mage/sets/commander/DesecratorHag.java index fd5824cead..675d7281d0 100644 --- a/Mage.Sets/src/mage/sets/commander/DesecratorHag.java +++ b/Mage.Sets/src/mage/sets/commander/DesecratorHag.java @@ -112,7 +112,7 @@ class DesecratorHagEffect extends OneShotEffect { } } } - if (cards.size() == 0) { + if (cards.isEmpty()) { return true; } if (cards.size() > 1 diff --git a/Mage.Sets/src/mage/sets/eventide/RekindledFlame.java b/Mage.Sets/src/mage/sets/eventide/RekindledFlame.java index 97606a925f..1b3d8767e8 100644 --- a/Mage.Sets/src/mage/sets/eventide/RekindledFlame.java +++ b/Mage.Sets/src/mage/sets/eventide/RekindledFlame.java @@ -85,7 +85,7 @@ class OpponentHasNoCardsInHandCondition implements Condition { if (player != null) { for (UUID playerId : game.getOpponents(source.getControllerId())) { Player opponent = game.getPlayer(playerId); - if (opponent != null && opponent.getHand().size() == 0) { + if (opponent != null && opponent.getHand().isEmpty()) { return true; } } diff --git a/Mage.Sets/src/mage/sets/limitedalpha/DingusEgg.java b/Mage.Sets/src/mage/sets/limitedalpha/DingusEgg.java index 0c197a4e18..69a87caf95 100644 --- a/Mage.Sets/src/mage/sets/limitedalpha/DingusEgg.java +++ b/Mage.Sets/src/mage/sets/limitedalpha/DingusEgg.java @@ -86,7 +86,7 @@ class DingusEggTriggeredAbility extends TriggeredAbilityImpl { if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getTarget().getCardType().contains(CardType.LAND)) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { UUID targetId = zEvent.getTarget().getControllerId(); for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(targetId)); diff --git a/Mage.Sets/src/mage/sets/odyssey/GorillaTitan.java b/Mage.Sets/src/mage/sets/odyssey/GorillaTitan.java index 401c7969f8..0d07fca333 100644 --- a/Mage.Sets/src/mage/sets/odyssey/GorillaTitan.java +++ b/Mage.Sets/src/mage/sets/odyssey/GorillaTitan.java @@ -84,7 +84,7 @@ class GorillaTitanCondition implements Condition { Player p = game.getPlayer(source.getControllerId()); if (p != null) { - return p.getGraveyard().size() == 0; + return p.getGraveyard().isEmpty(); } return false; } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/CloneShell.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/CloneShell.java index 850aa23754..52bd1e5a22 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/CloneShell.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/CloneShell.java @@ -102,7 +102,7 @@ class CloneShellEffect extends OneShotEffect { cards.add(card); } - if (cards.size() == 0) { + if (cards.isEmpty()) { return false; } diff --git a/Mage.Sets/src/mage/sets/seventhedition/AEtherFlash.java b/Mage.Sets/src/mage/sets/seventhedition/AEtherFlash.java index ea9bcd7ade..1e40e6aab3 100644 --- a/Mage.Sets/src/mage/sets/seventhedition/AEtherFlash.java +++ b/Mage.Sets/src/mage/sets/seventhedition/AEtherFlash.java @@ -89,7 +89,7 @@ class AEtherFlashTriggeredAbility extends TriggeredAbilityImpl { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanent(targetId); if (filter.match(permanent, getSourceId(), getControllerId(), game)) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(targetId)); } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/HollowbornBarghest.java b/Mage.Sets/src/mage/sets/shadowmoor/HollowbornBarghest.java index 593dcdc149..dcb6c8486c 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/HollowbornBarghest.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/HollowbornBarghest.java @@ -134,7 +134,7 @@ class HollowbornBarghestTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(controllerId).contains(event.getPlayerId())) { Player opponent = game.getPlayer(event.getPlayerId()); - if (opponent != null && opponent.getHand().size() == 0) { + if (opponent != null && opponent.getHand().isEmpty()) { opponent.loseLife(2, game); return true; } diff --git a/Mage.Sets/src/mage/sets/shardsofalara/ImmortalCoil.java b/Mage.Sets/src/mage/sets/shardsofalara/ImmortalCoil.java index 60ff87f1b9..2d9c085ee3 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/ImmortalCoil.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/ImmortalCoil.java @@ -100,7 +100,7 @@ class ImmortalCoilAbility extends StateTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { Player player = game.getPlayer(this.getControllerId()); - return player != null && player.getGraveyard().size() == 0; + return player != null && player.getGraveyard().isEmpty(); } @Override diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/Rivalry.java b/Mage.Sets/src/mage/sets/urzaslegacy/Rivalry.java index 4b79443702..1f516789ff 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/Rivalry.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/Rivalry.java @@ -94,7 +94,7 @@ class RivalryTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage.Sets/src/mage/sets/worldwake/QuestForTheNihilStone.java b/Mage.Sets/src/mage/sets/worldwake/QuestForTheNihilStone.java index 65f6c15be9..82d39a99f8 100644 --- a/Mage.Sets/src/mage/sets/worldwake/QuestForTheNihilStone.java +++ b/Mage.Sets/src/mage/sets/worldwake/QuestForTheNihilStone.java @@ -133,7 +133,7 @@ class QuestForTheNihilStoneTriggeredAbility2 extends TriggeredAbilityImpl { if (game.getOpponents(controllerId).contains(event.getPlayerId())) { Player opponent = game.getPlayer(event.getPlayerId()); if (opponent != null - && opponent.getHand().size() == 0 + && opponent.getHand().isEmpty() && quest.getCounters(game).getCount(CounterType.QUEST) >= 2) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(opponent.getId())); diff --git a/Mage.Sets/src/mage/sets/zendikar/GuulDrazSpecter.java b/Mage.Sets/src/mage/sets/zendikar/GuulDrazSpecter.java index 807449dbe7..20e512807c 100644 --- a/Mage.Sets/src/mage/sets/zendikar/GuulDrazSpecter.java +++ b/Mage.Sets/src/mage/sets/zendikar/GuulDrazSpecter.java @@ -90,7 +90,7 @@ class GuulDrazSpecterCondition implements Condition { Set opponents = game.getOpponents(source.getControllerId()); for (UUID opponentId : opponents) { - result |= game.getPlayer(opponentId).getHand().size() == 0; + result |= game.getPlayer(opponentId).getHand().isEmpty(); } return result; diff --git a/Mage/src/main/java/mage/abilities/common/BeginningOfCombatTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BeginningOfCombatTriggeredAbility.java index 873c67d7b4..76baa6b650 100644 --- a/Mage/src/main/java/mage/abilities/common/BeginningOfCombatTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BeginningOfCombatTriggeredAbility.java @@ -45,7 +45,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl { case YOU: boolean yours = event.getPlayerId().equals(this.controllerId); if (yours && setTargetPointer) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage/src/main/java/mage/abilities/common/BeginningOfDrawTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BeginningOfDrawTriggeredAbility.java index acb46c71a8..34b7a0af99 100644 --- a/Mage/src/main/java/mage/abilities/common/BeginningOfDrawTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BeginningOfDrawTriggeredAbility.java @@ -77,7 +77,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl { case YOU: boolean yours = event.getPlayerId().equals(this.controllerId); if (yours) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } @@ -86,7 +86,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl { return yours; case OPPONENT: if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } @@ -96,7 +96,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl { break; case NOT_YOU: if (!this.controllerId.equals(event.getPlayerId())) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } @@ -109,7 +109,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl { if (attachment != null && attachment.getAttachedTo() != null) { Permanent attachedTo = game.getPermanent(attachment.getAttachedTo()); if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } @@ -119,7 +119,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl { } break; case ANY: - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage/src/main/java/mage/abilities/common/BeginningOfPreCombatMainTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BeginningOfPreCombatMainTriggeredAbility.java index 1460e31ccf..207f9b9bf1 100644 --- a/Mage/src/main/java/mage/abilities/common/BeginningOfPreCombatMainTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BeginningOfPreCombatMainTriggeredAbility.java @@ -54,7 +54,7 @@ public class BeginningOfPreCombatMainTriggeredAbility extends TriggeredAbilityIm case YOU: boolean yours = event.getPlayerId().equals(this.controllerId); if (yours && setTargetPointer) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage/src/main/java/mage/abilities/common/BeginningOfUntapTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BeginningOfUntapTriggeredAbility.java index 35d68b69c0..bc685c9fa7 100644 --- a/Mage/src/main/java/mage/abilities/common/BeginningOfUntapTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BeginningOfUntapTriggeredAbility.java @@ -71,7 +71,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl { break; case OPPONENT: if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } @@ -82,7 +82,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl { case ANY: controller = game.getPlayer(this.getControllerId()); if (controller != null && controller.getInRange().contains(event.getPlayerId())) { - if (getTargets().size() == 0) { + if (getTargets().isEmpty()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/HellbentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/HellbentCondition.java index d65031ad88..fb2f226684 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/HellbentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/HellbentCondition.java @@ -41,7 +41,7 @@ public class HellbentCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return game.getPlayer(source.getControllerId()).getHand().size() == 0; + return game.getPlayer(source.getControllerId()).getHand().isEmpty(); } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/CostsImpl.java b/Mage/src/main/java/mage/abilities/costs/CostsImpl.java index 2d070ac91a..f17c7b9b2f 100644 --- a/Mage/src/main/java/mage/abilities/costs/CostsImpl.java +++ b/Mage/src/main/java/mage/abilities/costs/CostsImpl.java @@ -70,7 +70,7 @@ public class CostsImpl extends ArrayList implements Costs if (text != null) { return text; } - if (this.size() == 0) { + if (this.isEmpty()) { return ""; } diff --git a/Mage/src/main/java/mage/abilities/costs/mana/ManaCostsImpl.java b/Mage/src/main/java/mage/abilities/costs/mana/ManaCostsImpl.java index 9d9b89d874..2d14c311a7 100644 --- a/Mage/src/main/java/mage/abilities/costs/mana/ManaCostsImpl.java +++ b/Mage/src/main/java/mage/abilities/costs/mana/ManaCostsImpl.java @@ -262,11 +262,11 @@ public class ManaCostsImpl extends ArrayList implements M // First try only to pay colored mana with the pool for (ManaCost cost : this) { if (!cost.isPaid() && cost instanceof MonoHybridManaCost) { - if (((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0) - || ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0) - || ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0) - || ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0) - || ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) { + if (((cost.containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0) + || ((cost.containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0) + || ((cost.containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0) + || ((cost.containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0) + || ((cost.containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) { cost.assignPayment(game, ability, pool, costToPay); if (pool.count() == 0) { return; @@ -315,12 +315,12 @@ public class ManaCostsImpl extends ArrayList implements M public final void load(String mana) { this.clear(); if (costs.containsKey(mana)) { - ManaCosts savedCosts = costs.get(mana); + ManaCosts savedCosts = costs.get(mana); for (ManaCost cost : savedCosts) { - this.add((T) cost.copy()); + this.add(cost.copy()); } } else { - if (mana == null || mana.length() == 0) { + if (mana == null || mana.isEmpty()) { return; } String[] symbols = mana.split("^\\{|\\}\\{|\\}$"); @@ -347,11 +347,11 @@ public class ManaCostsImpl extends ArrayList implements M this.add(new VariableManaCost(modifierForX)); } //TODO: handle multiple {X} and/or {Y} symbols } else if (Character.isDigit(symbol.charAt(0))) { - this.add((T) new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2)))); + this.add(new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2)))); } else if (symbol.contains("P")) { - this.add((T) new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)))); + this.add(new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)))); } else { - this.add((T) new HybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)), ColoredManaSymbol.lookup(symbol.charAt(2)))); + this.add(new HybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)), ColoredManaSymbol.lookup(symbol.charAt(2)))); } } } @@ -392,7 +392,7 @@ public class ManaCostsImpl extends ArrayList implements M if (text != null) { return text; } - if (this.size() == 0) { + if (this.isEmpty()) { return ""; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CounterUnlessPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CounterUnlessPaysEffect.java index 51ea80d664..a409e5b1fd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CounterUnlessPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CounterUnlessPaysEffect.java @@ -110,7 +110,7 @@ public class CounterUnlessPaysEffect extends OneShotEffect { } StringBuilder sb = new StringBuilder(); - if (mode.getTargets().size() == 0) { + if (mode.getTargets().isEmpty()) { sb.append("counter it"); } else { sb.append("Counter target ").append(mode.getTargets().get(0).getTargetName()); diff --git a/Mage/src/main/java/mage/cards/decks/importer/DckDeckImporter.java b/Mage/src/main/java/mage/cards/decks/importer/DckDeckImporter.java index 24adc25b3d..800c3813fc 100644 --- a/Mage/src/main/java/mage/cards/decks/importer/DckDeckImporter.java +++ b/Mage/src/main/java/mage/cards/decks/importer/DckDeckImporter.java @@ -45,7 +45,7 @@ public class DckDeckImporter extends DeckImporter { @Override protected void readLine(String line, DeckCardLists deckList) { - if (line.length() == 0 || line.startsWith("#")) { + if (line.isEmpty() || line.startsWith("#")) { return; } diff --git a/Mage/src/main/java/mage/cards/decks/importer/DecDeckImporter.java b/Mage/src/main/java/mage/cards/decks/importer/DecDeckImporter.java index b1b095cf60..0dee3e9980 100644 --- a/Mage/src/main/java/mage/cards/decks/importer/DecDeckImporter.java +++ b/Mage/src/main/java/mage/cards/decks/importer/DecDeckImporter.java @@ -40,7 +40,7 @@ public class DecDeckImporter extends DeckImporter { @Override protected void readLine(String line, DeckCardLists deckList) { - if (line.length() == 0 || line.startsWith("//")) { + if (line.isEmpty() || line.startsWith("//")) { return; } diff --git a/Mage/src/main/java/mage/cards/decks/importer/DekDeckImporter.java b/Mage/src/main/java/mage/cards/decks/importer/DekDeckImporter.java index 885b569210..f66158ff34 100644 --- a/Mage/src/main/java/mage/cards/decks/importer/DekDeckImporter.java +++ b/Mage/src/main/java/mage/cards/decks/importer/DekDeckImporter.java @@ -13,7 +13,7 @@ public class DekDeckImporter extends DeckImporter { @Override protected void readLine(String line, DeckCardLists deckList) { - if (line.length() == 0 || line.startsWith("#") || !line.contains(" 0) { + if (line.isEmpty() && nonEmptyLinesTotal > 0) { sideboard = true; return; } else { diff --git a/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java b/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java index e175fc7fe4..11363f2eba 100644 --- a/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java +++ b/Mage/src/main/java/mage/filter/common/FilterPermanentOrPlayerWithCounter.java @@ -55,11 +55,11 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer @Override public boolean match(MageItem o, Game game) { if (o instanceof Player) { - if (((Player)o).getCounters().size() == 0) { + if (((Player)o).getCounters().isEmpty()) { return false; } } else if (o instanceof Permanent) { - if (((Permanent)o).getCounters(game).size() == 0) { + if (((Permanent)o).getCounters(game).isEmpty()) { return false; } } diff --git a/Mage/src/main/java/mage/game/tournament/TournamentSwiss.java b/Mage/src/main/java/mage/game/tournament/TournamentSwiss.java index e755d47a6f..54337d71cc 100644 --- a/Mage/src/main/java/mage/game/tournament/TournamentSwiss.java +++ b/Mage/src/main/java/mage/game/tournament/TournamentSwiss.java @@ -28,7 +28,7 @@ package mage.game.tournament; import java.util.List; -import java.util.Map; +import java.util.Map.Entry; import java.util.UUID; import mage.constants.TournamentPlayerState; @@ -49,7 +49,7 @@ public abstract class TournamentSwiss extends TournamentImpl { @Override protected void runTournament() { - for (Map.Entry entry : players.entrySet()) { + for (Entry entry : players.entrySet()) { if (entry.getValue().getPlayer().autoLoseGame()) { entry.getValue().setEliminated(); entry.getValue().setResults("Auto Eliminated"); diff --git a/Mage/src/main/java/mage/players/ManaPool.java b/Mage/src/main/java/mage/players/ManaPool.java index 0fd3ebad7e..7ab223a4bc 100644 --- a/Mage/src/main/java/mage/players/ManaPool.java +++ b/Mage/src/main/java/mage/players/ManaPool.java @@ -474,4 +474,8 @@ public class ManaPool implements Serializable { } return false; } + + public boolean isEmpty(){ + return count() == 0; + } } diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 73dce6dae9..00a7ae3a59 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2536,7 +2536,7 @@ public abstract class PlayerImpl implements Player, Serializable { } } - if (manaCosts.size() == 0) { + if (manaCosts.isEmpty()) { return true; } else { if (available == null) { @@ -2567,7 +2567,7 @@ public abstract class PlayerImpl implements Player, Serializable { } } - if (manaCosts.size() == 0) { + if (manaCosts.isEmpty()) { return true; } else { for (Mana mana : manaCosts.getOptions()) { @@ -2604,7 +2604,7 @@ public abstract class PlayerImpl implements Player, Serializable { } } - if (manaCosts.size() == 0) { + if (manaCosts.isEmpty()) { return true; } else { for (Mana mana : manaCosts.getOptions()) { diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerWithCounter.java b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerWithCounter.java index ae63a8aba9..c8f0497e31 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerWithCounter.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayerWithCounter.java @@ -80,13 +80,13 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer public boolean canTarget(UUID id, Game game) { Permanent permanent = game.getPermanent(id); if (permanent != null) { - if (permanent.getCounters(game).size() == 0) { + if (permanent.getCounters(game).isEmpty()) { return false; } } Player player = game.getPlayer(id); if (player != null) { - if (player.getCounters().size() == 0) { + if (player.getCounters().isEmpty()) { return false; } } @@ -97,13 +97,13 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer public boolean canTarget(UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); if (permanent != null) { - if (permanent.getCounters(game).size() == 0) { + if (permanent.getCounters(game).isEmpty()) { return false; } } Player player = game.getPlayer(id); if (player != null) { - if (player.getCounters().size() == 0) { + if (player.getCounters().isEmpty()) { return false; } }