From 11dc1e10f14a4dc34cd72c7404789146b394322f Mon Sep 17 00:00:00 2001 From: vraskulin Date: Tue, 28 Feb 2017 13:46:54 +0300 Subject: [PATCH] Few lambda's and removed explicit type from creating lists and hashmaps --- .../src/main/java/mage/client/MageFrame.java | 96 ++++------------ .../components/ability/AbilityPicker.java | 6 +- .../client/components/ext/dlg/DlgParams.java | 2 +- .../components/ext/dlg/impl/ChoiceDialog.java | 8 +- .../mage/client/deckeditor/CardSelector.java | 24 ++-- .../viewer/CollectionViewerPane.java | 11 +- .../mage/client/table/NewPlayerPanel.java | 21 ++-- .../client/table/TournamentPlayerPanel.java | 12 +- .../unusedFiles/DelayedViewerThread.java | 4 +- .../mage/client/util/gui/ArrowBuilder.java | 18 +-- .../mage/card/arcane/ModernCardRenderer.java | 2 +- .../card/dl/beans/EventListenerList.java | 20 ++-- .../collections/ListenableCollections.java | 19 +--- .../beans/properties/CompoundProperties.java | 10 +- .../properties/bound/BoundProperties.java | 18 ++- .../bound/PropertyChangeMapListener.java | 12 +- .../bound/PropertyChangeSetListener.java | 10 +- .../sources/AltMtgOnlTokensImageSource.java | 11 +- .../dl/sources/MtgOnlTokensImageSource.java | 11 +- .../mage/client/game/MultiConnectTest.java | 20 +--- .../mage/client/game/StartMultiGamesTest.java | 21 ++-- Mage.Common/src/mage/db/EntityManager.java | 4 +- Mage.Common/src/mage/db/Statistics.java | 8 +- Mage.Common/src/mage/db/model/Log.java | 3 +- .../mage/server/console/ConnectDialog.java | 50 ++------- .../mage/server/console/ConsoleFrame.java | 80 ++++--------- .../mage/server/console/ConsolePanel.java | 62 +++-------- .../src/mage/player/ai/Attackers2.java | 5 +- .../src/mage/player/ai/util/CombatInfo.java | 4 +- .../src/mage/player/ai/util/CombatUtil.java | 14 +-- .../java/mage/player/ai/CombatEvaluator.java | 9 +- .../java/mage/player/ai/ComputerPlayer.java | 8 +- .../player/ai/simulators/ActionSimulator.java | 9 +- .../ai/simulators/CombatGroupSimulator.java | 9 +- .../player/ai/simulators/CombatSimulator.java | 22 ++-- .../java/mage/player/ai/utils/RateCard.java | 4 +- .../src/mage/player/ai/MCTSPlayer.java | 14 +-- .../src/mage/player/ai/Attackers.java | 5 +- .../src/mage/player/ai/ComputerPlayer2.java | 15 ++- .../src/mage/player/ai/ComputerPlayer3.java | 5 +- .../src/mage/player/ai/SimulatedPlayer.java | 19 ++-- .../src/mage/player/ai/SimulationNode.java | 15 +-- Mage.Sets/src/mage/cards/a/AvengingArrow.java | 11 +- .../mage/cards/b/BeastbreakerOfBalaGed.java | 6 +- Mage.Sets/src/mage/cards/b/BrimstoneMage.java | 8 +- .../src/mage/cards/c/CapriciousEfreet.java | 13 ++- Mage.Sets/src/mage/cards/c/CaravanEscort.java | 8 +- .../src/mage/cards/c/CathedralMembrane.java | 2 +- .../src/mage/cards/c/CoralhelmCommander.java | 10 +- Mage.Sets/src/mage/cards/c/Counterflux.java | 14 +-- Mage.Sets/src/mage/cards/c/Counterlash.java | 10 +- .../src/mage/cards/d/DescentOfTheDragons.java | 7 +- .../src/mage/cards/d/DjinnIlluminatus.java | 20 +--- Mage.Sets/src/mage/cards/d/DoublingChant.java | 12 +- .../src/mage/cards/e/EatenBySpiders.java | 11 +- Mage.Sets/src/mage/cards/e/EchoMage.java | 7 +- .../src/mage/cards/e/EmptyShrineKannushi.java | 9 +- .../src/mage/cards/e/EnclaveCryptologist.java | 10 +- .../src/mage/cards/e/ExecutionersSwing.java | 13 ++- .../src/mage/cards/e/EyeOfSingularity.java | 9 +- Mage.Sets/src/mage/cards/f/FaithsReward.java | 7 +- Mage.Sets/src/mage/cards/f/FellShepherd.java | 15 +-- Mage.Sets/src/mage/cards/f/Fireball.java | 11 +- .../src/mage/cards/f/FulgentDistraction.java | 13 ++- .../src/mage/cards/g/GargoyleSentinel.java | 17 +-- .../src/mage/cards/g/GiltspireAvenger.java | 9 +- Mage.Sets/src/mage/cards/g/GravityWell.java | 18 +-- .../src/mage/cards/h/HalimarWavewatch.java | 6 +- .../src/mage/cards/h/HarmonicConvergence.java | 17 ++- .../src/mage/cards/i/IkiralOutrider.java | 8 +- .../src/mage/cards/j/JoragaTreespeaker.java | 13 ++- .../src/mage/cards/k/KabiraVindicator.java | 10 +- .../src/mage/cards/k/KarganDragonlord.java | 10 +- .../src/mage/cards/k/KazanduTuskcaller.java | 8 +- Mage.Sets/src/mage/cards/k/KillingWave.java | 8 +- .../src/mage/cards/k/KnightOfCliffhaven.java | 6 +- .../mage/cards/k/KynaiosAndTiroOfMeletis.java | 9 +- Mage.Sets/src/mage/cards/l/LeoninArbiter.java | 15 +-- .../mage/cards/l/LordOfShatterskullPass.java | 13 ++- Mage.Sets/src/mage/cards/m/MarchOfSouls.java | 9 +- Mage.Sets/src/mage/cards/m/MazesEnd.java | 15 +-- Mage.Sets/src/mage/cards/m/Mindreaver.java | 9 +- .../src/mage/cards/m/MitoticManipulation.java | 15 +-- .../src/mage/cards/m/MurderousSpoils.java | 9 +- Mage.Sets/src/mage/cards/n/NaturesWill.java | 15 +-- .../src/mage/cards/n/NirkanaCutthroat.java | 6 +- Mage.Sets/src/mage/cards/n/NullChampion.java | 6 +- .../mage/cards/o/OngoingInvestigation.java | 13 ++- Mage.Sets/src/mage/cards/o/Outwit.java | 2 +- .../src/mage/cards/p/PyxisOfPandemonium.java | 19 +--- Mage.Sets/src/mage/cards/r/Reciprocate.java | 9 +- .../src/mage/cards/r/ReverseTheSands.java | 9 +- Mage.Sets/src/mage/cards/s/SecondSunrise.java | 13 ++- Mage.Sets/src/mage/cards/s/ShoalSerpent.java | 14 +-- .../src/mage/cards/s/SkywatcherAdept.java | 6 +- .../src/mage/cards/s/SpellContortion.java | 11 +- .../src/mage/cards/s/StudentOfWarfare.java | 6 +- .../src/mage/cards/t/TheBattleOfYavin.java | 9 +- .../src/mage/cards/t/TheGreatAurora.java | 14 +-- .../src/mage/cards/t/ThoughtsOfRuin.java | 9 +- Mage.Sets/src/mage/cards/t/ThranTurbine.java | 7 +- Mage.Sets/src/mage/cards/t/TideOfWar.java | 9 +- .../src/mage/cards/t/TranscendentMaster.java | 11 +- Mage.Sets/src/mage/cards/t/TritonTactics.java | 15 +-- Mage.Sets/src/mage/cards/t/TurnToSlag.java | 12 +- .../src/mage/cards/w/WarleadersHelix.java | 11 +- .../src/mage/cards/w/WhimsOfTheFates.java | 10 +- .../java/com/xmage/ws/util/IPHolderUtil.java | 4 +- .../com/xmage/ws/util/json/JSONParser.java | 2 +- .../org/mage/test/cards/copy/CloneTest.java | 6 +- .../mage/test/load/LoadCallbackClient.java | 29 +++-- .../java/org/mage/test/load/LoadTest.java | 19 ++-- .../mage/test/serverside/PlayGameTest.java | 6 +- .../test/serverside/TestPlayRandomGame.java | 6 +- .../test/serverside/base/MageTestBase.java | 8 +- .../serverside/base/MageTestPlayerBase.java | 9 +- .../magefree/update/helpers/FileHelper.java | 18 +-- .../abilities/effects/ContinuousEffects.java | 2 +- .../CopySpellForEachItCouldTargetEffect.java | 12 +- .../main/java/mage/cards/ExpansionSet.java | 18 +-- .../main/java/mage/game/CardAttribute.java | 7 +- .../mage/game/GameCanadianHighlanderImpl.java | 105 +++++++++--------- Mage/src/main/java/mage/game/GameImpl.java | 57 ++-------- Mage/src/main/java/mage/game/GameState.java | 24 +--- .../mage/game/permanent/PermanentImpl.java | 24 +--- .../mage/game/tournament/TournamentImpl.java | 32 +----- .../tournament/pairing/RoundPairings.java | 2 +- .../SwissPairingMinimalWeightMatching.java | 15 +-- .../pairing/SwissPairingSimple.java | 10 +- .../targetpointer/SecondTargetPointer.java | 9 +- 130 files changed, 725 insertions(+), 1105 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 529c630d99..bec3728b3d 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -27,84 +27,19 @@ */ package mage.client; -import java.awt.AWTEvent; -import java.awt.AlphaComposite; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.SplashScreen; -import java.awt.Toolkit; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.ItemEvent; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.beans.PropertyVetoException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.prefs.Preferences; -import javax.imageio.ImageIO; -import javax.swing.AbstractButton; -import javax.swing.ImageIcon; -import javax.swing.InputMap; -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JDesktopPane; -import javax.swing.JEditorPane; -import javax.swing.JFrame; -import javax.swing.JInternalFrame; -import javax.swing.JLabel; -import javax.swing.JLayeredPane; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JToggleButton; -import javax.swing.KeyStroke; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; import mage.cards.decks.Deck; import mage.cards.repository.CardCriteria; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; import mage.client.cards.BigCard; import mage.client.chat.ChatPanelBasic; -import mage.client.components.MageComponents; -import mage.client.components.MageDesktopManager; -import mage.client.components.MageJDesktop; -import mage.client.components.MageRoundPane; -import mage.client.components.MageUI; +import mage.client.components.*; import mage.client.components.ext.dlg.DialogManager; import mage.client.components.tray.MageTray; import mage.client.constants.Constants.DeckEditorMode; import mage.client.deckeditor.DeckEditorPane; import mage.client.deckeditor.collection.viewer.CollectionViewerPane; -import mage.client.dialog.AboutDialog; -import mage.client.dialog.ConnectDialog; -import mage.client.dialog.ErrorDialog; -import mage.client.dialog.FeedbackDialog; -import mage.client.dialog.GameEndDialog; -import mage.client.dialog.MageDialog; -import mage.client.dialog.PreferencesDialog; -import mage.client.dialog.TableWaitingDialog; -import mage.client.dialog.UserRequestDialog; +import mage.client.dialog.*; import mage.client.draft.DraftPane; import mage.client.draft.DraftPanel; import mage.client.game.GamePane; @@ -114,11 +49,7 @@ import mage.client.preference.MagePreferences; import mage.client.remote.CallbackClientImpl; import mage.client.table.TablesPane; import mage.client.tournament.TournamentPane; -import mage.client.util.EDTExceptionHandler; -import mage.client.util.GUISizeHelper; -import mage.client.util.ImageCaches; -import mage.client.util.SettingsManager; -import mage.client.util.SystemUtil; +import mage.client.util.*; import mage.client.util.audio.MusicPlayer; import mage.client.util.gui.ArrowBuilder; import mage.client.util.gui.countryBox.CountryUtil; @@ -145,6 +76,25 @@ import org.mage.plugins.card.images.DownloadPictures; import org.mage.plugins.card.info.CardInfoPaneImpl; import org.mage.plugins.card.utils.impl.ImageManagerImpl; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import java.beans.PropertyVetoException; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.prefs.Preferences; + /** * @author BetaSteward_at_googlemail.com */ @@ -472,7 +422,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { String filename = "/background.jpg"; try { if (Plugins.getInstance().isThemePluginLoaded()) { - backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap()); + backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<>()); } else { InputStream is = this.getClass().getResourceAsStream(filename); BufferedImage background = ImageIO.read(is); diff --git a/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java b/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java index 5617acd492..d2c4262e4f 100644 --- a/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java +++ b/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java @@ -92,7 +92,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener { } public void show(AbilityPickerView choices, Point p) { - this.choices = new ArrayList(); + this.choices = new ArrayList<>(); this.selected = true; // to stop previous modal for (Map.Entry choice : choices.getChoices().entrySet()) { @@ -236,7 +236,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener { public static class ImageRenderer2 extends JEditorPane implements ListCellRenderer { - public final Map cache = new HashMap(); + public final Map cache = new HashMap<>(); @Override public Component getListCellRendererComponent( @@ -398,7 +398,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener { JFrame jframe = new JFrame("Test"); - List objectList = new ArrayList(); + List objectList = new ArrayList<>(); objectList.add("T: add {R} to your mana pool. 111111111111111111111111111"); objectList.add("T: add {B} to your mana pool. {source} deals 1 damage to you."); objectList.add("{T}: add {B} to your mana pool"); diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DlgParams.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DlgParams.java index 2bc7a82fba..0eeac96eb3 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DlgParams.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DlgParams.java @@ -38,7 +38,7 @@ public class DlgParams { boolean isAI = false; - public HashSet manaChoices = new HashSet(); + public HashSet manaChoices = new HashSet<>(); public int getPlayerID() { return playerID; 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 d298cc4cc2..10324cd923 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 @@ -9,18 +9,18 @@ import mage.client.components.ext.dlg.DialogManager; import mage.client.components.ext.dlg.DlgParams; import mage.client.components.ext.dlg.IDialogPanel; import mage.client.plugins.impl.Plugins; -import mage.client.util.audio.AudioManager; import mage.client.util.Command; import mage.client.util.SettingsManager; +import mage.client.util.audio.AudioManager; import mage.view.CardView; import mage.view.CardsView; +import org.mage.card.arcane.CardPanel; import org.mage.plugins.card.utils.impl.ImageManagerImpl; import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.UUID; -import org.mage.card.arcane.CardPanel; /** * @author mw, noxx @@ -130,7 +130,7 @@ public class ChoiceDialog extends IDialogPanel { return; } - java.util.List toRemove = new ArrayList(); + java.util.List toRemove = new ArrayList<>(); for (int i = getComponentCount() - 1; i > 0; i--) { Component o = getComponent(i); if (o instanceof MageCard) { @@ -141,7 +141,7 @@ public class ChoiceDialog extends IDialogPanel { remove(toRemove.get(i)); } - java.util.List cardList = new ArrayList(cards.values()); + java.util.List cardList = new ArrayList<>(cards.values()); int width = SettingsManager.getInstance().getCardSize().width; int height = SettingsManager.getInstance().getCardSize().height; diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java index 2c1d985d30..91c7705628 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java @@ -33,19 +33,6 @@ */ package mage.client.deckeditor; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.*; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.DefaultTableCellRenderer; import mage.MageObject; import mage.ObjectColor; import mage.cards.Card; @@ -72,6 +59,13 @@ import mage.filter.predicate.other.ExpansionSetPredicate; import mage.view.CardView; import mage.view.CardsView; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; +import java.awt.event.*; +import java.util.*; +import java.util.List; + /** * * @author BetaSteward_at_googlemail.com, nantuko @@ -442,7 +436,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene tbWhite = new javax.swing.JToggleButton(); tbColorless = new javax.swing.JToggleButton(); jSeparator1 = new javax.swing.JToolBar.Separator(); - cbExpansionSet = new javax.swing.JComboBox(); + cbExpansionSet = new javax.swing.JComboBox<>(); jSeparator2 = new javax.swing.JToolBar.Separator(); btnBooster = new javax.swing.JButton(); btnClear = new javax.swing.JButton(); @@ -457,7 +451,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene jSeparator6 = new javax.swing.JToolBar.Separator(); chkPiles = new javax.swing.JCheckBox(); jSeparator3 = new javax.swing.JToolBar.Separator(); - cbSortBy = new javax.swing.JComboBox(); + cbSortBy = new javax.swing.JComboBox<>(); jSeparator4 = new javax.swing.JToolBar.Separator(); jToggleListView = new javax.swing.JToggleButton(); jToggleCardView = new javax.swing.JToggleButton(); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPane.java b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPane.java index c3115146ba..f851570985 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPane.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/CollectionViewerPane.java @@ -27,13 +27,14 @@ */ package mage.client.deckeditor.collection.viewer; -import java.awt.Component; -import java.util.HashMap; -import java.util.Map; -import javax.swing.JComponent; import mage.client.MagePane; import mage.client.plugins.impl.Plugins; +import javax.swing.*; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + /** * Collection viewer pane. * Contains background and components container. @@ -46,7 +47,7 @@ public class CollectionViewerPane extends MagePane { boolean initialized = false; this.setTitle("Collection Viewer"); if (Plugins.getInstance().isThemePluginLoaded()) { - Map uiComponents = new HashMap(); + Map uiComponents = new HashMap<>(); JComponent container = Plugins.getInstance().updateTablePanel(uiComponents); if (container != null) { collectionViewerPanel = new CollectionViewerPanel(); diff --git a/Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java b/Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java index f7c7a85a98..0f9cdc31ba 100644 --- a/Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/NewPlayerPanel.java @@ -34,14 +34,15 @@ package mage.client.table; -import java.io.File; -import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; import mage.client.MageFrame; import mage.client.deck.generator.DeckGenerator; import mage.client.util.Config; +import javax.swing.*; +import javax.swing.filechooser.FileFilter; +import java.io.File; +import java.io.IOException; + /** * * @author BetaSteward_at_googlemail.com @@ -150,18 +151,10 @@ public class NewPlayerPanel extends javax.swing.JPanel { lblPlayerDeck.setText("Deck:"); btnPlayerDeck.setText("..."); - btnPlayerDeck.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnPlayerDeckActionPerformed(evt); - } - }); + btnPlayerDeck.addActionListener(evt -> btnPlayerDeckActionPerformed(evt)); btnGenerate.setText("Generate"); - btnGenerate.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnGenerateActionPerformed(evt); - } - }); + btnGenerate.addActionListener(evt -> btnGenerateActionPerformed(evt)); lblLevel.setText("Skill:"); 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 97b866a4fa..91796275a6 100644 --- a/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java @@ -34,12 +34,12 @@ package mage.client.table; -import java.util.UUID; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComboBox; import mage.cards.decks.DeckCardLists; import mage.client.SessionHandler; +import javax.swing.*; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -99,11 +99,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel { jLabel1.setText("Type:"); cbPlayerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - cbPlayerType.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cbPlayerTypeActionPerformed(evt); - } - }); + cbPlayerType.addActionListener(evt -> cbPlayerTypeActionPerformed(evt)); lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N lblPlayerNum.setText("Player Num:"); diff --git a/Mage.Client/src/main/java/mage/client/unusedFiles/DelayedViewerThread.java b/Mage.Client/src/main/java/mage/client/unusedFiles/DelayedViewerThread.java index 8d0318e4ea..33c2071179 100644 --- a/Mage.Client/src/main/java/mage/client/unusedFiles/DelayedViewerThread.java +++ b/Mage.Client/src/main/java/mage/client/unusedFiles/DelayedViewerThread.java @@ -2,7 +2,7 @@ package mage.client.unusedFiles; //package mage.client.thread; -import java.awt.Component; +import java.awt.*; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -18,7 +18,7 @@ public class DelayedViewerThread extends Thread { private final Map delayedViewers; protected DelayedViewerThread() { - delayedViewers = new HashMap(); + delayedViewers = new HashMap<>(); start(); } diff --git a/Mage.Client/src/main/java/mage/client/util/gui/ArrowBuilder.java b/Mage.Client/src/main/java/mage/client/util/gui/ArrowBuilder.java index df4650ea3b..7c3054ae9b 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/ArrowBuilder.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/ArrowBuilder.java @@ -30,9 +30,9 @@ public class ArrowBuilder { /** * Stores arrow panels per game */ - private final Map arrowPanels = new HashMap(); + private final Map arrowPanels = new HashMap<>(); - private final Map>> map = new HashMap>>(); + private final Map>> map = new HashMap<>(); private int currentWidth; private int currentHeight; @@ -103,16 +103,8 @@ public class ArrowBuilder { synchronized (map) { p.add(arrow); - Map> innerMap = map.get(gameId); - if (innerMap == null) { - innerMap = new HashMap>(); - map.put(gameId, innerMap); - } - java.util.List arrows = innerMap.get(type); - if (arrows == null) { - arrows = new ArrayList(); - innerMap.put(type, arrows); - } + Map> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<>()); + java.util.List arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<>()); arrows.add(arrow); } @@ -149,7 +141,7 @@ public class ArrowBuilder { for (Arrow arrow : arrows) { p.remove(arrow); } - innerMap.put(type, new ArrayList()); + innerMap.put(type, new ArrayList<>()); } p.revalidate(); p.repaint(); diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java index bc6e75ee8c..fd84341897 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java @@ -767,7 +767,7 @@ public class ModernCardRenderer extends CardRenderer { // Add the keyword rule if there are any keywords if (!textboxKeywords.isEmpty()) { String keywordRulesString = getKeywordRulesString(); - TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList()); + TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList<>()); allRules.add(0, keywordsRule); } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/EventListenerList.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/EventListenerList.java index 18dc8d852a..8dc68a4bf1 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/EventListenerList.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/EventListenerList.java @@ -9,12 +9,10 @@ import com.google.common.base.Function; import com.google.common.collect.AbstractIterator; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import java.util.ArrayList; -import static java.util.Arrays.*; -import java.util.EventListener; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; + +import java.util.*; + +import static java.util.Arrays.asList; /** * The class EventListenerList. @@ -35,13 +33,13 @@ public class EventListenerList extends javax.swing.event.EventListenerList { */ public Iterable getIterable(final Class... listenerClass) { //transform class -> iterable - List> l = Lists.transform(asList(listenerClass), new ClassToIterableFunction()); + List> l = Lists.transform(asList(listenerClass), new ClassToIterableFunction<>()); //compose iterable (use an arraylist to memoize the function's results) - final Iterable it = Iterables.concat(new ArrayList>(l)); + final Iterable it = Iterables.concat(new ArrayList<>(l)); //transform to singleton iterators - return () -> new SingletonIterator(it.iterator()); + return () -> new SingletonIterator<>(it.iterator()); } /** @@ -92,7 +90,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList { private class ClassToIterableFunction implements Function, Iterable> { public Iterable apply(final Class from) { - return () -> new ListenerIterator(from); + return () -> new ListenerIterator<>(from); } } @@ -103,7 +101,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList { private static class SingletonIterator extends AbstractIterator { private final Iterator it; - private final HashSet previous = new HashSet(); + private final HashSet previous = new HashSet<>(); public SingletonIterator(Iterator it) { this.it = it; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/collections/ListenableCollections.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/collections/ListenableCollections.java index a4a9bb0c4b..63ab9809d6 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/collections/ListenableCollections.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/collections/ListenableCollections.java @@ -8,16 +8,7 @@ package org.mage.plugins.card.dl.beans.collections; import java.io.Serializable; -import java.util.AbstractList; -import java.util.AbstractMap; -import java.util.AbstractSequentialList; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.RandomAccess; -import java.util.Set; +import java.util.*; /** @@ -34,18 +25,18 @@ public final class ListenableCollections { public static List listenableList(List list, ListListener listener) { if (list instanceof RandomAccess) { - return new ListenableList(list, listener); + return new ListenableList<>(list, listener); } else { - return new ListenableSequentialList(list, listener); + return new ListenableSequentialList<>(list, listener); } } public static Set listenableSet(Set set, SetListener listener) { - return new ListenableSet(set, listener); + return new ListenableSet<>(set, listener); } public static Map listenableMap(Map map, MapListener listener) { - return new ListenableMap(map, listener); + return new ListenableMap<>(map, listener); } public interface ListListener extends Serializable { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/CompoundProperties.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/CompoundProperties.java index 5a6f021913..aa9350feae 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/CompoundProperties.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/CompoundProperties.java @@ -7,13 +7,9 @@ package org.mage.plugins.card.dl.beans.properties; -import static java.util.Arrays.*; +import java.util.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; +import static java.util.Arrays.asList; /** @@ -31,7 +27,7 @@ public class CompoundProperties extends AbstractProperties { } public CompoundProperties(List delegates) { - this.delegates = new ArrayList(delegates); + this.delegates = new ArrayList<>(delegates); Collections.reverse(this.delegates); } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/BoundProperties.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/BoundProperties.java index 79d553ab28..318bba5da9 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/BoundProperties.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/BoundProperties.java @@ -7,17 +7,15 @@ package org.mage.plugins.card.dl.beans.properties.bound; -import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableList; -import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableMap; -import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableSet; +import org.mage.plugins.card.dl.beans.PropertyChangeSupport; +import org.mage.plugins.card.dl.beans.properties.AbstractProperties; +import org.mage.plugins.card.dl.beans.properties.Property; import java.util.List; import java.util.Map; import java.util.Set; -import org.mage.plugins.card.dl.beans.PropertyChangeSupport; -import org.mage.plugins.card.dl.beans.properties.AbstractProperties; -import org.mage.plugins.card.dl.beans.properties.Property; +import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.*; /** @@ -39,18 +37,18 @@ public class BoundProperties extends AbstractProperties { } public Property property(String name, Property property) { - return new BoundProperty(s, name, property); + return new BoundProperty<>(s, name, property); } public List list(String name, List list) { - return listenableList(list, new PropertyChangeListListener(s, name)); + return listenableList(list, new PropertyChangeListListener<>(s, name)); } public Set set(String name, Set set) { - return listenableSet(set, new PropertyChangeSetListener(s, set, name)); + return listenableSet(set, new PropertyChangeSetListener<>(s, set, name)); } public Map map(String name, Map map) { - return listenableMap(map, new PropertyChangeMapListener(s, map, name)); + return listenableMap(map, new PropertyChangeMapListener<>(s, map, name)); } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeMapListener.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeMapListener.java index e0c9bedfe4..65d14ebf42 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeMapListener.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeMapListener.java @@ -7,12 +7,12 @@ package org.mage.plugins.card.dl.beans.properties.bound; -import java.beans.PropertyChangeEvent; -import java.util.Map; - import org.mage.plugins.card.dl.beans.PropertyChangeSupport; import org.mage.plugins.card.dl.beans.collections.ListenableCollections.MapListener; +import java.beans.PropertyChangeEvent; +import java.util.Map; + /** * The class PropertyChangeMapListener. This listener alway fires events with {@link Map} -> {@link Map} as the @@ -35,15 +35,15 @@ public class PropertyChangeMapListener implements MapListener { } public void put(K key, V newValue) { - s.firePropertyChange(new MapPutEvent(s.getSourceBean(), propertyName, map, key, newValue)); + s.firePropertyChange(new MapPutEvent<>(s.getSourceBean(), propertyName, map, key, newValue)); } public void set(K key, V oldValue, V newValue) { - s.firePropertyChange(new MapSetEvent(s.getSourceBean(), propertyName, map, key, oldValue, newValue)); + s.firePropertyChange(new MapSetEvent<>(s.getSourceBean(), propertyName, map, key, oldValue, newValue)); } public void remove(K key, V oldValue) { - s.firePropertyChange(new MapRemoveEvent(s.getSourceBean(), propertyName, map, key, oldValue)); + s.firePropertyChange(new MapRemoveEvent<>(s.getSourceBean(), propertyName, map, key, oldValue)); } public static abstract class MapEvent extends PropertyChangeEvent { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeSetListener.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeSetListener.java index 6d23fd4361..de2c9bde42 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeSetListener.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/beans/properties/bound/PropertyChangeSetListener.java @@ -7,12 +7,12 @@ package org.mage.plugins.card.dl.beans.properties.bound; -import java.beans.PropertyChangeEvent; -import java.util.Set; - import org.mage.plugins.card.dl.beans.PropertyChangeSupport; import org.mage.plugins.card.dl.beans.collections.ListenableCollections.SetListener; +import java.beans.PropertyChangeEvent; +import java.util.Set; + /** * The class PropertyChangeSetListener. This listener always fires events with {@link Set} -> {@link Set} as the @@ -35,11 +35,11 @@ public class PropertyChangeSetListener implements SetListener { } public void add(E newValue) { - s.firePropertyChange(new SetAddEvent(s.getSourceBean(), propertyName, set, newValue)); + s.firePropertyChange(new SetAddEvent<>(s.getSourceBean(), propertyName, set, newValue)); } public void remove(E oldValue) { - s.firePropertyChange(new SetRemoveEvent(s.getSourceBean(), propertyName, set, oldValue)); + s.firePropertyChange(new SetRemoveEvent<>(s.getSourceBean(), propertyName, set, oldValue)); } public static abstract class SetEvent extends PropertyChangeEvent { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java index a52cc67102..1723c987db 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/AltMtgOnlTokensImageSource.java @@ -27,11 +27,12 @@ */ package org.mage.plugins.card.dl.sources; -import java.io.IOException; -import java.util.HashMap; import org.apache.log4j.Logger; import org.mage.plugins.card.images.CardDownloadData; +import java.io.IOException; +import java.util.HashMap; + /** * * @author spjspj @@ -104,9 +105,9 @@ public class AltMtgOnlTokensImageSource implements CardImageSource { if (copyUrlToImage != null) { return; } - copyUrlToImage = new HashMap(); - copyImageToUrl = new HashMap(); - copyUrlToImageDone = new HashMap(); + copyUrlToImage = new HashMap<>(); + copyImageToUrl = new HashMap<>(); + copyUrlToImageDone = new HashMap<>(); copyUrlToImage.put("SCG_CC_002-Penguin.jpg", "BIRD.WU.BIRD.CREATURE.1.1.full.jpg"); copyUrlToImage.put("SCG_CC_005-Vampire.jpg", "VAMPIRE.B.VAMPIRE.CREATURE.1.1.full.jpg"); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java index e6493b3d2c..bb42786cb7 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/MtgOnlTokensImageSource.java @@ -27,11 +27,12 @@ */ package org.mage.plugins.card.dl.sources; -import java.io.IOException; -import java.util.HashMap; import org.apache.log4j.Logger; import org.mage.plugins.card.images.CardDownloadData; +import java.io.IOException; +import java.util.HashMap; + /** * * @author spjspj @@ -104,9 +105,9 @@ public class MtgOnlTokensImageSource implements CardImageSource { if (copyUrlToImage != null) { return; } - copyUrlToImage = new HashMap(); - copyImageToUrl = new HashMap(); - copyUrlToImageDone = new HashMap(); + copyUrlToImage = new HashMap<>(); + copyImageToUrl = new HashMap<>(); + copyUrlToImageDone = new HashMap<>(); copyUrlToImage.put("Angel_B_3_3.jpg", "ANGEL.B.ANGEL.CREATURE.3.3.full.jpg"); copyUrlToImage.put("Angel_W_3_3.jpg", "ANGEL.W.ANGEL.CREATURE.3.3.full.jpg"); copyUrlToImage.put("Angel_W_4_4.jpg", "ANGEL.W.ANGEL.CREATURE.4.4.full.jpg"); diff --git a/Mage.Client/src/test/java/mage/client/game/MultiConnectTest.java b/Mage.Client/src/test/java/mage/client/game/MultiConnectTest.java index 9db5d602ef..51d99cfe16 100644 --- a/Mage.Client/src/test/java/mage/client/game/MultiConnectTest.java +++ b/Mage.Client/src/test/java/mage/client/game/MultiConnectTest.java @@ -105,20 +105,12 @@ public class MultiConnectTest { } private void connect(final int index) throws Exception { - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread t, Throwable e) { - logger.fatal(null, e); - } - }); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - String username = "player" + index; - ClientMock client = new ClientMock(username); - client.connect(); - latch.countDown(); - } + Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.fatal(null, e)); + SwingUtilities.invokeLater(() -> { + String username = "player" + index; + ClientMock client = new ClientMock(username); + client.connect(); + latch.countDown(); }); } diff --git a/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java b/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java index ae98d45766..10e2d072f9 100644 --- a/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java +++ b/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java @@ -1,12 +1,13 @@ package mage.client.game; -import javax.swing.SwingUtilities; import mage.client.MageFrame; import mage.client.components.MageComponents; import mage.client.components.MageUI; import org.apache.log4j.Logger; import org.junit.Ignore; +import javax.swing.*; + /** * @author ayratn */ @@ -42,18 +43,12 @@ public class StartMultiGamesTest { private void startGame() throws Exception { frame = null; - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread t, Throwable e) { - logger.fatal(null, e); - } - }); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - synchronized (sync) { - frame = new MageFrame(); - frame.setVisible(true); - sync.notify(); - } + Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.fatal(null, e)); + SwingUtilities.invokeLater(() -> { + synchronized (sync) { + frame = new MageFrame(); + frame.setVisible(true); + sync.notify(); } }); synchronized (sync) { diff --git a/Mage.Common/src/mage/db/EntityManager.java b/Mage.Common/src/mage/db/EntityManager.java index aea98be0c0..3938b9ab1c 100644 --- a/Mage.Common/src/mage/db/EntityManager.java +++ b/Mage.Common/src/mage/db/EntityManager.java @@ -49,7 +49,7 @@ public enum EntityManager { } public List getAllLogs() { - List logs = new ArrayList(); + List logs = new ArrayList<>(); try { logs = logDao.queryForAll(); } catch (SQLException ex) { @@ -64,7 +64,7 @@ public enum EntityManager { } public List getAllFeedbacks() { - List feedbacks = new ArrayList(); + List feedbacks = new ArrayList<>(); try { feedbacks = feedbackDao.queryForAll(); } catch (SQLException ex) { diff --git a/Mage.Common/src/mage/db/Statistics.java b/Mage.Common/src/mage/db/Statistics.java index aaa36896db..cdfe7d2d7b 100644 --- a/Mage.Common/src/mage/db/Statistics.java +++ b/Mage.Common/src/mage/db/Statistics.java @@ -33,7 +33,7 @@ public final class Statistics { private static List displayTop3(Map nicknames) { Collection values = nicknames.values(); - List games = new ArrayList(); + List games = new ArrayList<>(); games.addAll(values); Collections.sort(games, new Comparator() { @Override @@ -43,7 +43,7 @@ public final class Statistics { }); // Top-3 - List numbersToFind = new ArrayList(); + List numbersToFind = new ArrayList<>(); for (Integer numberOfGames : games) { numbersToFind.add(numberOfGames); if (numbersToFind.size() == 3) { @@ -51,7 +51,7 @@ public final class Statistics { } } - Map players = new LinkedHashMap(); + Map players = new LinkedHashMap<>(); for (Map.Entry entry : nicknames.entrySet()) { if (check(numbersToFind, entry.getValue())) { players.put(entry.getValue(), entry.getKey()); @@ -70,7 +70,7 @@ public final class Statistics { private static Map displayCommonNumbers(List logs) { int count = 0; - Map nicknames = new HashMap(); + Map nicknames = new HashMap<>(); for (Log log : logs) { if (log.getKey().equals("gameStarted")) { if (log.getArguments() != null) { diff --git a/Mage.Common/src/mage/db/model/Log.java b/Mage.Common/src/mage/db/model/Log.java index 21de8e0292..ff11495f1d 100644 --- a/Mage.Common/src/mage/db/model/Log.java +++ b/Mage.Common/src/mage/db/model/Log.java @@ -2,6 +2,7 @@ package mage.db.model; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; + import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -54,7 +55,7 @@ public class Log { } public List getArguments() { - ArrayList arguments = new ArrayList(); + ArrayList arguments = new ArrayList<>(); if (arg0 != null) { arguments.add(arg0); } diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java b/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java index 6851c2c1c3..a2f15557d0 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConnectDialog.java @@ -34,7 +34,12 @@ package mage.server.console; -import java.awt.Cursor; +import mage.remote.Connection; +import mage.remote.Connection.ProxyType; +import org.apache.log4j.Logger; + +import javax.swing.*; +import java.awt.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; @@ -43,13 +48,6 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import javax.swing.SwingWorker; -import mage.remote.Connection; -import mage.remote.Connection.ProxyType; -import org.apache.log4j.Logger; /** * @@ -166,40 +164,20 @@ public class ConnectDialog extends JDialog { }); btnConnect.setText("Connect"); - btnConnect.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnConnectActionPerformed(evt); - } - }); + btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt)); btnCancel.setText("Cancel"); - btnCancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); + btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt)); chkAutoConnect.setText("Automatically connect to this server next time"); - chkAutoConnect.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - chkAutoConnectActionPerformed(evt); - } - }); + chkAutoConnect.addActionListener(evt -> chkAutoConnectActionPerformed(evt)); jButton1.setText("Find..."); jButton1.setToolTipText("Find public server"); jButton1.setName("findServerBtn"); // NOI18N - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - findPublicServerActionPerformed(evt); - } - }); + jButton1.addActionListener(evt -> findPublicServerActionPerformed(evt)); - cbProxyType.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cbProxyTypeActionPerformed(evt); - } - }); + cbProxyType.addActionListener(evt -> cbProxyTypeActionPerformed(evt)); lblProxyType.setLabelFor(cbProxyType); lblProxyType.setText("Proxy:"); @@ -254,11 +232,7 @@ public class ConnectDialog extends JDialog { lblProxyPassword.setText("Password:"); - txtPasswordField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - txtPasswordFieldActionPerformed(evt); - } - }); + txtPasswordField.addActionListener(evt -> txtPasswordFieldActionPerformed(evt)); javax.swing.GroupLayout pnlProxyAuthLayout = new javax.swing.GroupLayout(pnlProxyAuth); pnlProxyAuth.setLayout(pnlProxyAuthLayout); diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java index 1e2a0a92e5..3843dd04f1 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java @@ -34,16 +34,6 @@ package mage.server.console; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; import mage.interfaces.MageClient; import mage.interfaces.callback.ClientCallback; import mage.remote.Connection; @@ -52,6 +42,14 @@ import mage.remote.SessionImpl; import mage.utils.MageVersion; import org.apache.log4j.Logger; +import javax.swing.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.prefs.Preferences; + /** * * @author BetaSteward_at_googlemail.com @@ -101,12 +99,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { logger.fatal("", ex); } - pingTaskExecutor.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - session.ping(); - } - }, 60, 60, TimeUnit.SECONDS); + pingTaskExecutor.scheduleAtFixedRate(() -> session.ping(), 60, 60, TimeUnit.SECONDS); } public boolean connect(Connection connection) { @@ -157,11 +150,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { btnConnect.setFocusable(false); btnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnConnect.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnConnect.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnConnectActionPerformed(evt); - } - }); + btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt)); jToolBar1.add(btnConnect); btnSendMessage.setActionCommand("SendMessage"); @@ -170,11 +159,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { btnSendMessage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnSendMessage.setText("Send Message"); btnSendMessage.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnSendMessage.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnSendMessageActionPerformed(evt); - } - }); + btnSendMessage.addActionListener(evt -> btnSendMessageActionPerformed(evt)); jToolBar1.add(btnSendMessage); lblStatus.setText("Not Connected"); @@ -224,12 +209,9 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { logger.info("Starting MAGE server console version " + version); logger.info("Logging level: " + logger.getEffectiveLevel()); - java.awt.EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - new ConsoleFrame().setVisible(true); - logger.info("Started MAGE server console"); - } + java.awt.EventQueue.invokeLater(() -> { + new ConsoleFrame().setVisible(true); + logger.info("Started MAGE server console"); }); } @@ -252,12 +234,9 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { enableButtons(); } else { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - setStatusText(message); - enableButtons(); - } + SwingUtilities.invokeLater(() -> { + setStatusText(message); + enableButtons(); }); } } @@ -270,13 +249,10 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { disableButtons(); } else { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - consolePanel1.stop(); - setStatusText("Not connected"); - disableButtons(); - } + SwingUtilities.invokeLater(() -> { + consolePanel1.stop(); + setStatusText("Not connected"); + disableButtons(); }); } } @@ -287,12 +263,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { JOptionPane.showMessageDialog(this, message); } else { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - JOptionPane.showMessageDialog(getFrame(), message); - } - }); + SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message)); } } @@ -302,12 +273,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient { JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE); } else { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - JOptionPane.showMessageDialog(getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE); - } - }); + SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE)); } } diff --git a/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java b/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java index 5e2b590c2b..0d820cc517 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/ConsolePanel.java @@ -33,25 +33,23 @@ */ package mage.server.console; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN; -import static javax.swing.JTable.AUTO_RESIZE_OFF; -import javax.swing.SwingWorker; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableRowSorter; import mage.remote.Session; import mage.view.TableView; import mage.view.UserView; import org.apache.log4j.Logger; +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableRowSorter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; + +import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN; +import static javax.swing.JTable.AUTO_RESIZE_OFF; + /** * * @author BetaSteward_at_googlemail.com @@ -161,42 +159,22 @@ public class ConsolePanel extends javax.swing.JPanel { jPanel4.setVerifyInputWhenFocusTarget(false); btnDisconnect.setText("Disconnect"); - btnDisconnect.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnDisconnectActionPerformed(evt); - } - }); + btnDisconnect.addActionListener(evt -> btnDisconnectActionPerformed(evt)); btnEndSession.setText("End session"); - btnEndSession.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnEndSessionActionPerformed(evt); - } - }); + btnEndSession.addActionListener(evt -> btnEndSessionActionPerformed(evt)); btnMuteUser.setText("Mute user"); btnMuteUser.setActionCommand("Mute 1h"); - btnMuteUser.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnMuteUserActionPerformed(evt); - } - }); + btnMuteUser.addActionListener(evt -> btnMuteUserActionPerformed(evt)); btnDeActivate.setText("(de)activate"); btnDeActivate.setActionCommand("Mute 1h"); - btnDeActivate.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnDeActivateActionPerformed(evt); - } - }); + btnDeActivate.addActionListener(evt -> btnDeActivateActionPerformed(evt)); btnLockUser.setText("Lock user"); btnLockUser.setActionCommand("Mute 1h"); - btnLockUser.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnLockUserActionPerformed(evt); - } - }); + btnLockUser.addActionListener(evt -> btnLockUserActionPerformed(evt)); lblMinutes.setText("Minutes"); @@ -277,11 +255,7 @@ public class ConsolePanel extends javax.swing.JPanel { ); btnRemoveTable.setText("Remove Table"); - btnRemoveTable.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnRemoveTableActionPerformed(evt); - } - }); + btnRemoveTable.addActionListener(evt -> btnRemoveTableActionPerformed(evt)); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/Attackers2.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/Attackers2.java index aa9da00613..0c880b10da 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/Attackers2.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/Attackers2.java @@ -28,10 +28,11 @@ package mage.player.ai; +import mage.game.permanent.Permanent; + import java.util.ArrayList; import java.util.List; import java.util.TreeMap; -import mage.game.permanent.Permanent; /** * @@ -40,7 +41,7 @@ import mage.game.permanent.Permanent; public class Attackers2 extends TreeMap> { public List getAttackers() { - List attackers = new ArrayList(); + List attackers = new ArrayList<>(); for (List l: this.values()) { for (Permanent permanent: l) { attackers.add(permanent); diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatInfo.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatInfo.java index 0a0377ce26..f77f38df7f 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatInfo.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatInfo.java @@ -12,12 +12,12 @@ import java.util.Map; */ public class CombatInfo { - private Map> combat = new HashMap>(); + private Map> combat = new HashMap<>(); public void addPair(Permanent attacker, Permanent blocker) { List blockers = combat.get(attacker); if (blockers == null) { - blockers = new ArrayList(); + blockers = new ArrayList<>(); combat.put(attacker, blockers); } blockers.add(blocker); diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatUtil.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatUtil.java index 889f4eefe9..eaaa3a375f 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatUtil.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/util/CombatUtil.java @@ -23,7 +23,7 @@ import java.util.*; */ public final class CombatUtil { - private static final List emptyList = new ArrayList(); + private static final List emptyList = new ArrayList<>(); private static final Logger log = Logger.getLogger(CombatUtil.class); @@ -32,8 +32,8 @@ public final class CombatUtil { public static List canKillOpponent(Game game, List attackersList, List blockersList, Player defender) { - List blockableAttackers = new ArrayList(blockersList); - List unblockableAttackers = new ArrayList(); + List blockableAttackers = new ArrayList<>(blockersList); + List unblockableAttackers = new ArrayList<>(); for (Permanent attacker : attackersList) { if (!canBeBlocked(game, attacker, blockersList)) { unblockableAttackers.add(attacker); @@ -44,7 +44,7 @@ public final class CombatUtil { sortByPower(blockableAttackers, true); // imagine that most powerful will be blocked as 1-vs-1 - List attackersThatWontBeBlocked = new ArrayList(blockableAttackers); + List attackersThatWontBeBlocked = new ArrayList<>(blockableAttackers); for (int i = 0; (i < blockersList.size() && i < blockableAttackers.size()); i++) { attackersThatWontBeBlocked.remove(blockableAttackers.get(i)); } @@ -147,7 +147,7 @@ public final class CombatUtil { * @return true if attacker can be blocked by any blocker */ public static List getPossibleBlockers(Game game, Permanent attacker, List blockersList) { - List canBlock = new ArrayList(); + List canBlock = new ArrayList<>(); for (Permanent blocker : blockersList) { if (blocker.canBlock(attacker.getId(), game)) { canBlock.add(blocker); @@ -184,7 +184,7 @@ public final class CombatUtil { } private static List getBlockersThatWillSurvive(Game game, UUID attackerId, UUID defenderId, Permanent attacker, List possibleBlockers) { - List blockers = new ArrayList(); + List blockers = new ArrayList<>(); for (Permanent blocker : possibleBlockers) { SurviveInfo info = willItSurvive(game, attackerId, defenderId, attacker, blocker); //if (info.isAttackerDied() && !info.isBlockerDied()) { @@ -321,7 +321,7 @@ public final class CombatUtil { } private static List getBlockersThatWillSurvive2(Game game, UUID attackerId, UUID defenderId, Permanent attacker, List possibleBlockers) { - List blockers = new ArrayList(); + List blockers = new ArrayList<>(); for (Permanent blocker : possibleBlockers) { SurviveInfo info = willItSurvive2(game, attackerId, defenderId, attacker, blocker); //if (info.isAttackerDied() && !info.isBlockerDied()) { diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java index 31fa1953a8..12032f470b 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java @@ -28,15 +28,16 @@ package mage.player.ai; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.TrampleAbility; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -44,7 +45,7 @@ import mage.game.permanent.Permanent; public class CombatEvaluator { //preserve calculations for efficiency - private Map values = new HashMap(); + private Map values = new HashMap<>(); public int evaluate(Permanent creature, Game game) { if (!values.containsKey(creature.getId())) { diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index b270e765c0..de54f2db07 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -617,9 +617,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } if (target.getOriginalTarget() instanceof TargetSpell) { if (!game.getStack().isEmpty()) { - Iterator it = game.getStack().iterator(); - while (it.hasNext()) { - StackObject o = it.next(); + for (StackObject o : game.getStack()) { if (o instanceof Spell && !source.getId().equals(o.getStackAbility().getId())) { target.addTarget(o.getId(), source, game); return true; @@ -651,9 +649,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { } } if (!game.getStack().isEmpty()) { - Iterator it = game.getStack().iterator(); - while (it.hasNext()) { - StackObject stackObject = it.next(); + for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell && source != null && !source.getId().equals(stackObject.getStackAbility().getId())) { if (((TargetSpellOrPermanent) target).getFilter().match(stackObject, game)) { target.addTarget(stackObject.getId(), source, game); diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/ActionSimulator.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/ActionSimulator.java index 54368cc841..b18c34dec5 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/ActionSimulator.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/ActionSimulator.java @@ -28,8 +28,6 @@ package mage.player.ai.simulators; -import java.util.ArrayList; -import java.util.List; import mage.abilities.ActivatedAbility; import mage.cards.Card; import mage.game.Game; @@ -38,6 +36,9 @@ import mage.player.ai.ComputerPlayer; import mage.player.ai.PermanentEvaluator; import mage.players.Player; +import java.util.ArrayList; +import java.util.List; + /** * * @author BetaSteward_at_googlemail.com @@ -45,8 +46,8 @@ import mage.players.Player; public class ActionSimulator { private ComputerPlayer player; - private List playableInstants = new ArrayList(); - private List playableAbilities = new ArrayList(); + private List playableInstants = new ArrayList<>(); + private List playableAbilities = new ArrayList<>(); private Game game; diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java index 026f7dac5b..625ca01c98 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java @@ -28,20 +28,21 @@ package mage.player.ai.simulators; +import mage.game.Game; +import mage.game.permanent.Permanent; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * * @author BetaSteward_at_googlemail.com */ public class CombatGroupSimulator implements Serializable { - public List attackers = new ArrayList(); - public List blockers = new ArrayList(); + public List attackers = new ArrayList<>(); + public List blockers = new ArrayList<>(); public UUID defenderId; public boolean defenderIsPlaneswalker; public int unblockedDamage; diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatSimulator.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatSimulator.java index d2eb5ffdf9..e0f6ee30ef 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatSimulator.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatSimulator.java @@ -28,30 +28,26 @@ package mage.player.ai.simulators; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - import mage.counters.CounterType; import mage.game.Game; import mage.game.combat.CombatGroup; import mage.game.permanent.Permanent; import mage.players.Player; +import java.io.Serializable; +import java.util.*; +import java.util.Map.Entry; + /** * * @author BetaSteward_at_googlemail.com */ public class CombatSimulator implements Serializable { - public List groups = new ArrayList(); - public List defenders = new ArrayList(); - public Map playersLife = new HashMap(); - public Map planeswalkerLoyalty = new HashMap(); + public List groups = new ArrayList<>(); + public List defenders = new ArrayList<>(); + public Map playersLife = new HashMap<>(); + public Map planeswalkerLoyalty = new HashMap<>(); public UUID attackerId; public int rating = 0; @@ -89,7 +85,7 @@ public class CombatSimulator implements Serializable { } public int evaluate() { - Map damage = new HashMap(); + Map damage = new HashMap<>(); int result = 0; for (CombatGroupSimulator group: groups) { if (!damage.containsKey(group.defenderId)) { diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/utils/RateCard.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/utils/RateCard.java index faec662ba7..c409e2d264 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/utils/RateCard.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/utils/RateCard.java @@ -191,7 +191,7 @@ public final class RateCard { } return 2 * (converted - colorPenalty + 1); } - final Map singleCount = new HashMap(); + final Map singleCount = new HashMap<>(); int maxSingleCount = 0; for (String symbol : card.getManaCost().getSymbols()) { int count = 0; @@ -257,7 +257,7 @@ public final class RateCard { * @return */ public static int getDifferentColorManaCount(Card card) { - Set symbols = new HashSet(); + Set symbols = new HashSet<>(); for (String symbol : card.getManaCost().getSymbols()) { if (isColoredMana(symbol)) { symbols.add(symbol); diff --git a/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/MCTSPlayer.java b/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/MCTSPlayer.java index ad07de128b..a33fbfb203 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/MCTSPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AIMCTS/src/mage/player/ai/MCTSPlayer.java @@ -78,7 +78,7 @@ public class MCTSPlayer extends ComputerPlayer { } public List getPlayableOptions(Game game) { - List all = new ArrayList(); + List all = new ArrayList<>(); List playables = getPlayableAbilities(game); for (Ability ability: playables) { List options = game.getPlayer(playerId).getPlayableOptions(ability, game); @@ -122,7 +122,7 @@ public class MCTSPlayer extends ComputerPlayer { } public List> getAttacks(Game game) { - List> engagements = new ArrayList>(); + List> engagements = new ArrayList<>(); List attackersList = super.getAvailableAttackers(game); //use binary digits to calculate powerset of attackers int powerElements = (int) Math.pow(2, attackersList.size()); @@ -133,7 +133,7 @@ public class MCTSPlayer extends ComputerPlayer { while (binary.length() < attackersList.size()) { binary.insert(0, '0'); } - List engagement = new ArrayList(); + List engagement = new ArrayList<>(); for (int j = 0; j < attackersList.size(); j++) { if (binary.charAt(j) == '1') { engagement.add(attackersList.get(j).getId()); @@ -145,14 +145,14 @@ public class MCTSPlayer extends ComputerPlayer { } public List>> getBlocks(Game game) { - List>> engagements = new ArrayList>>(); + List>> engagements = new ArrayList<>(); int numGroups = game.getCombat().getGroups().size(); if (numGroups == 0) { return engagements; } //add a node with no blockers - List> engagement = new ArrayList>(); + List> engagement = new ArrayList<>(); for (int i = 0; i < numGroups; i++) { engagement.add(new ArrayList()); } @@ -165,9 +165,9 @@ public class MCTSPlayer extends ComputerPlayer { } private List> copyEngagement(List> engagement) { - List> newEngagement = new ArrayList>(); + List> newEngagement = new ArrayList<>(); for (List group: engagement) { - newEngagement.add(new ArrayList(group)); + newEngagement.add(new ArrayList<>(group)); } return newEngagement; } diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/Attackers.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/Attackers.java index a20c15f41d..e5d009e568 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/Attackers.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/Attackers.java @@ -28,10 +28,11 @@ package mage.player.ai; +import mage.game.permanent.Permanent; + import java.util.ArrayList; import java.util.List; import java.util.TreeMap; -import mage.game.permanent.Permanent; /** * @@ -40,7 +41,7 @@ import mage.game.permanent.Permanent; public class Attackers extends TreeMap> { public List getAttackers() { - List attackers = new ArrayList(); + List attackers = new ArrayList<>(); for (List l: this.values()) { for (Permanent permanent: l) { attackers.add(permanent); 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 d37112a665..681fcac0fb 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 @@ -28,9 +28,6 @@ package mage.player.ai; -import mage.constants.Outcome; -import mage.constants.PhaseStep; -import mage.constants.RangeOfInfluence; import mage.abilities.Ability; import mage.abilities.ActivatedAbility; import mage.abilities.common.PassAbility; @@ -38,6 +35,9 @@ import mage.abilities.effects.Effect; import mage.abilities.effects.SearchEffect; import mage.cards.Cards; import mage.choices.Choice; +import mage.constants.Outcome; +import mage.constants.PhaseStep; +import mage.constants.RangeOfInfluence; import mage.game.Game; import mage.game.combat.Combat; import mage.game.combat.CombatGroup; @@ -163,7 +163,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player { logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s"); if (!root.children.isEmpty()) { root = root.children.get(0); - actions = new LinkedList(root.abilities); + actions = new LinkedList<>(root.abilities); combat = root.combat; if (logger.isDebugEnabled()) logger.debug("adding actions:" + actions); @@ -184,7 +184,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player { logger.debug("simlating -- game value:" + game.getState().getValue(true) + " test value:" + test.gameValue); if (root.playerId.equals(playerId) && root.abilities != null && game.getState().getValue(true).hashCode() == test.gameValue) { logger.debug("simulating -- continuing previous action chain"); - actions = new LinkedList(root.abilities); + actions = new LinkedList<>(root.abilities); combat = root.combat; return true; } @@ -284,10 +284,9 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player { } protected void addActionsTimed() { - FutureTask task = new FutureTask(new Callable() { + FutureTask task = new FutureTask<>(new Callable() { @Override - public Integer call() throws Exception - { + public Integer call() throws Exception { return addActions(root, Integer.MIN_VALUE, Integer.MAX_VALUE); } }); 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 c38a835d74..b523360807 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 @@ -30,7 +30,6 @@ package mage.player.ai; import mage.constants.PhaseStep; import mage.constants.RangeOfInfluence; -import mage.abilities.Ability; import mage.game.Game; import mage.game.combat.Combat; import mage.game.combat.CombatGroup; @@ -141,7 +140,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player { logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s"); if (!root.children.isEmpty()) { root = root.children.get(0); - actions = new LinkedList(root.abilities); + actions = new LinkedList<>(root.abilities); combat = root.combat; if (logger.isDebugEnabled()) logger.debug("adding pre-combat actions:" + actions); @@ -165,7 +164,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player { logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s"); if (!root.children.isEmpty()) { root = root.children.get(0); - actions = new LinkedList(root.abilities); + actions = new LinkedList<>(root.abilities); combat = root.combat; if (logger.isDebugEnabled()) logger.debug("adding post-combat actions:" + actions); diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulatedPlayer.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulatedPlayer.java index fb43fcb694..957c604403 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulatedPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulatedPlayer.java @@ -28,8 +28,6 @@ package mage.player.ai; -import java.util.*; -import java.util.concurrent.ConcurrentLinkedQueue; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbility; @@ -43,6 +41,9 @@ import mage.game.stack.StackAbility; import mage.target.Target; import org.apache.log4j.Logger; +import java.util.*; +import java.util.concurrent.ConcurrentLinkedQueue; + /** * * @author BetaSteward_at_googlemail.com @@ -73,12 +74,12 @@ public class SimulatedPlayer extends ComputerPlayer { } public List simulatePriority(Game game) { - allActions = new ConcurrentLinkedQueue(); + allActions = new ConcurrentLinkedQueue<>(); Game sim = game.copy(); simulateOptions(sim, pass); - ArrayList list = new ArrayList(allActions); + ArrayList list = new ArrayList<>(allActions); //Collections.shuffle(list); Collections.reverse(list); return list; @@ -160,7 +161,7 @@ public class SimulatedPlayer extends ComputerPlayer { }*/ public List addAttackers(Game game) { - Map engagements = new HashMap(); + Map engagements = new HashMap<>(); //useful only for two player games - will only attack first opponent UUID defenderId = game.getOpponents(playerId).iterator().next(); List attackersList = super.getAvailableAttackers(defenderId, game); @@ -189,13 +190,13 @@ public class SimulatedPlayer extends ComputerPlayer { logger.debug("simulating -- attack:" + sim.getCombat().getGroups().size()); } } - return new ArrayList(engagements.values()); + return new ArrayList<>(engagements.values()); } public List addBlockers(Game game) { - Map engagements = new HashMap(); + Map engagements = new HashMap<>(); int numGroups = game.getCombat().getGroups().size(); - if (numGroups == 0) return new ArrayList(); + if (numGroups == 0) return new ArrayList<>(); //add a node with no blockers Game sim = game.copy(); @@ -205,7 +206,7 @@ public class SimulatedPlayer extends ComputerPlayer { List blockers = getAvailableBlockers(game); addBlocker(game, blockers, engagements); - return new ArrayList(engagements.values()); + return new ArrayList<>(engagements.values()); } protected void addBlocker(Game game, List blockers, Map engagements) { diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulationNode.java b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulationNode.java index 625f93ad5c..d283009629 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulationNode.java +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/src/mage/player/ai/SimulationNode.java @@ -28,13 +28,14 @@ package mage.player.ai; +import mage.abilities.Ability; +import mage.game.Game; +import mage.game.combat.Combat; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.abilities.Ability; -import mage.game.Game; -import mage.game.combat.Combat; /** * @@ -48,10 +49,10 @@ public class SimulationNode implements Serializable { protected int gameValue; protected List abilities; protected int depth; - protected List children = new ArrayList(); + protected List children = new ArrayList<>(); protected SimulationNode parent; - protected List targets = new ArrayList(); - protected List choices = new ArrayList(); + protected List targets = new ArrayList<>(); + protected List choices = new ArrayList<>(); protected UUID playerId; protected Combat combat; @@ -74,7 +75,7 @@ public class SimulationNode implements Serializable { public SimulationNode(SimulationNode parent, Game game, Ability ability, UUID playerId) { this(parent, game, playerId); - this.abilities = new ArrayList(); + this.abilities = new ArrayList<>(); abilities.add(ability); } diff --git a/Mage.Sets/src/mage/cards/a/AvengingArrow.java b/Mage.Sets/src/mage/cards/a/AvengingArrow.java index 2eb1e583b8..c02c3f3211 100644 --- a/Mage.Sets/src/mage/cards/a/AvengingArrow.java +++ b/Mage.Sets/src/mage/cards/a/AvengingArrow.java @@ -27,20 +27,21 @@ */ package mage.cards.a; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; -import mage.constants.CardType; import mage.abilities.Ability; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.watchers.common.SourceDidDamageWatcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -92,7 +93,7 @@ class AvengingArrowTarget extends TargetPermanent { @Override public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); - Set possibleTargets = new HashSet(); + Set possibleTargets = new HashSet<>(); SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); if (watcher != null) { for (UUID targetId : availablePossibleTargets) { diff --git a/Mage.Sets/src/mage/cards/b/BeastbreakerOfBalaGed.java b/Mage.Sets/src/mage/cards/b/BeastbreakerOfBalaGed.java index 415c218d35..97039b6970 100644 --- a/Mage.Sets/src/mage/cards/b/BeastbreakerOfBalaGed.java +++ b/Mage.Sets/src/mage/cards/b/BeastbreakerOfBalaGed.java @@ -27,7 +27,6 @@ */ package mage.cards.b; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -38,6 +37,7 @@ import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -59,13 +59,13 @@ public class BeastbreakerOfBalaGed extends LevelerCard { // Level up {2}{G} ({2}{G}: Put a level counter on this. Level up only as a sorcery.) this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{G}"))); - Abilities levelAbilities = new AbilitiesImpl(); + Abilities levelAbilities = new AbilitiesImpl<>(); levelAbilities.add(TrampleAbility.getInstance()); this.addAbilities(LevelerCardBuilder.construct( // LEVEL 1-3 // 4/4 - new LevelerCardBuilder.LevelAbility(1, 3, new AbilitiesImpl(), 4, 4), + new LevelerCardBuilder.LevelAbility(1, 3, new AbilitiesImpl<>(), 4, 4), // LEVEL 1-3 // 4/4 // Trample diff --git a/Mage.Sets/src/mage/cards/b/BrimstoneMage.java b/Mage.Sets/src/mage/cards/b/BrimstoneMage.java index 20dcf95261..50bbd67a14 100644 --- a/Mage.Sets/src/mage/cards/b/BrimstoneMage.java +++ b/Mage.Sets/src/mage/cards/b/BrimstoneMage.java @@ -28,8 +28,6 @@ package mage.cards.b; -import mage.constants.CardType; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -42,6 +40,8 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Zone; import mage.target.common.TargetCreatureOrPlayer; import java.util.UUID; @@ -61,12 +61,12 @@ public class BrimstoneMage extends LevelerCard { this.toughness = new MageInt(2); this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}{R}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); ability.addTarget(new TargetCreatureOrPlayer()); abilities1.add(ability); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), new TapSourceCost()); ability.addTarget(new TargetCreatureOrPlayer()); abilities2.add(ability); diff --git a/Mage.Sets/src/mage/cards/c/CapriciousEfreet.java b/Mage.Sets/src/mage/cards/c/CapriciousEfreet.java index c9b0a4a91d..bf72e87475 100644 --- a/Mage.Sets/src/mage/cards/c/CapriciousEfreet.java +++ b/Mage.Sets/src/mage/cards/c/CapriciousEfreet.java @@ -27,17 +27,15 @@ */ package mage.cards.c; -import java.util.ArrayList; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.TargetController; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; import mage.filter.common.FilterNonlandPermanent; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; @@ -45,6 +43,9 @@ import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.util.RandomUtil; +import java.util.ArrayList; +import java.util.UUID; + /** * * @author North @@ -101,7 +102,7 @@ class CapriciousEfreetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - ArrayList targetPermanents = new ArrayList(); + ArrayList targetPermanents = new ArrayList<>(); Permanent permanent = game.getPermanent(source.getTargets().get(0).getFirstTarget()); if (permanent != null) { targetPermanents.add(permanent); diff --git a/Mage.Sets/src/mage/cards/c/CaravanEscort.java b/Mage.Sets/src/mage/cards/c/CaravanEscort.java index 7ea9ae818d..2f19e16123 100644 --- a/Mage.Sets/src/mage/cards/c/CaravanEscort.java +++ b/Mage.Sets/src/mage/cards/c/CaravanEscort.java @@ -27,16 +27,16 @@ */ package mage.cards.c; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.AbilitiesImpl; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.keyword.FirstStrikeAbility; -import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.LevelUpAbility; +import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -57,9 +57,9 @@ public class CaravanEscort extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}"))); - AbilitiesImpl levelAbilities = new AbilitiesImpl(FirstStrikeAbility.getInstance()); + AbilitiesImpl levelAbilities = new AbilitiesImpl<>(FirstStrikeAbility.getInstance()); this.addAbilities(LevelerCardBuilder.construct( - new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl(), 2, 2), + new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl<>(), 2, 2), new LevelerCardBuilder.LevelAbility(5, -1, levelAbilities, 5, 5) )); diff --git a/Mage.Sets/src/mage/cards/c/CathedralMembrane.java b/Mage.Sets/src/mage/cards/c/CathedralMembrane.java index e7ff5af80d..d464bd56e7 100644 --- a/Mage.Sets/src/mage/cards/c/CathedralMembrane.java +++ b/Mage.Sets/src/mage/cards/c/CathedralMembrane.java @@ -135,7 +135,7 @@ class CathedralMembraneEffect extends OneShotEffect { class CathedralMembraneWatcher extends Watcher { - public List blockedCreatures = new ArrayList(); + public List blockedCreatures = new ArrayList<>(); public CathedralMembraneWatcher() { super("CathedralMembraneWatcher", WatcherScope.CARD); diff --git a/Mage.Sets/src/mage/cards/c/CoralhelmCommander.java b/Mage.Sets/src/mage/cards/c/CoralhelmCommander.java index 8ac789f7a5..230f82b3fc 100644 --- a/Mage.Sets/src/mage/cards/c/CoralhelmCommander.java +++ b/Mage.Sets/src/mage/cards/c/CoralhelmCommander.java @@ -27,9 +27,6 @@ */ package mage.cards.c; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -42,6 +39,9 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; @@ -70,10 +70,10 @@ public class CoralhelmCommander extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(FlyingAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(FlyingAbility.getInstance()); abilities2.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true))); diff --git a/Mage.Sets/src/mage/cards/c/Counterflux.java b/Mage.Sets/src/mage/cards/c/Counterflux.java index a2c47ec17b..add5f6ef30 100644 --- a/Mage.Sets/src/mage/cards/c/Counterflux.java +++ b/Mage.Sets/src/mage/cards/c/Counterflux.java @@ -27,12 +27,6 @@ */ package mage.cards.c; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Outcome; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; @@ -43,6 +37,8 @@ import mage.abilities.effects.common.CounterTargetEffect; import mage.abilities.keyword.OverloadAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.FilterSpell; @@ -52,6 +48,10 @@ import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.target.TargetSpell; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + /** * @@ -109,7 +109,7 @@ class CounterfluxEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List spellsToCounter = new LinkedList(); + List spellsToCounter = new LinkedList<>(); for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell && !stackObject.getControllerId().equals(source.getControllerId())) { spellsToCounter.add((Spell) stackObject); diff --git a/Mage.Sets/src/mage/cards/c/Counterlash.java b/Mage.Sets/src/mage/cards/c/Counterlash.java index 6d3831fa58..509becfb18 100644 --- a/Mage.Sets/src/mage/cards/c/Counterlash.java +++ b/Mage.Sets/src/mage/cards/c/Counterlash.java @@ -27,16 +27,13 @@ */ package mage.cards.c; -import java.util.ArrayList; -import java.util.UUID; - -import mage.constants.CardType; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; import mage.constants.Outcome; import mage.filter.FilterCard; import mage.filter.predicate.Predicate; @@ -48,6 +45,9 @@ import mage.players.Player; import mage.target.TargetSpell; import mage.target.common.TargetCardInHand; +import java.util.ArrayList; +import java.util.UUID; + /** * * @author BetaSteward @@ -97,7 +97,7 @@ class CounterlashEffect extends OneShotEffect { game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); if (player.chooseUse(Outcome.PutCardInPlay, "Cast a nonland card in your hand that shares a card type with that spell without paying its mana cost?", source, game)) { FilterCard filter = new FilterCard(); - ArrayList> types = new ArrayList>(); + ArrayList> types = new ArrayList<>(); for (CardType type: stackObject.getCardType()) { if (type != CardType.LAND) { types.add(new CardTypePredicate(type)); diff --git a/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java b/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java index 62042d9046..d4aed13bd3 100644 --- a/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java +++ b/Mage.Sets/src/mage/cards/d/DescentOfTheDragons.java @@ -27,8 +27,6 @@ */ package mage.cards.d; -import java.util.HashMap; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -42,6 +40,9 @@ import mage.players.Player; import mage.target.Target; import mage.target.common.TargetCreaturePermanent; +import java.util.HashMap; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -87,7 +88,7 @@ class DescentOfTheDragonsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - HashMap playersWithTargets = new HashMap(); + HashMap playersWithTargets = new HashMap<>(); for (Target target : source.getTargets()) { for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); diff --git a/Mage.Sets/src/mage/cards/d/DjinnIlluminatus.java b/Mage.Sets/src/mage/cards/d/DjinnIlluminatus.java index c41201537f..92800ddc91 100644 --- a/Mage.Sets/src/mage/cards/d/DjinnIlluminatus.java +++ b/Mage.Sets/src/mage/cards/d/DjinnIlluminatus.java @@ -27,9 +27,6 @@ */ package mage.cards.d; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -38,17 +35,16 @@ import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.ReplicateAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.common.FilterInstantOrSorcerySpell; import mage.game.Game; import mage.game.stack.Spell; import mage.game.stack.StackObject; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + /** * * @author LevelX2 @@ -107,11 +103,7 @@ class DjinnIlluminatusGainReplicateEffect extends ContinuousEffectImpl { if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) { Spell spell = (Spell) stackObject; if (filter.match(stackObject, game)) { - ReplicateAbility replicateAbility = replicateAbilities.get(spell.getId()); - if (replicateAbility == null) { - replicateAbility = new ReplicateAbility(spell.getCard(), spell.getSpellAbility().getManaCosts().getText()); - replicateAbilities.put(spell.getId(), replicateAbility); - } + ReplicateAbility replicateAbility = replicateAbilities.computeIfAbsent(spell.getId(), k -> new ReplicateAbility(spell.getCard(), spell.getSpellAbility().getManaCosts().getText())); game.getState().addOtherAbility(spell.getCard(), replicateAbility, false); // Do not copy because paid and # of activations state is handled in the baility } } diff --git a/Mage.Sets/src/mage/cards/d/DoublingChant.java b/Mage.Sets/src/mage/cards/d/DoublingChant.java index 5c2884473a..d72e388c43 100644 --- a/Mage.Sets/src/mage/cards/d/DoublingChant.java +++ b/Mage.Sets/src/mage/cards/d/DoublingChant.java @@ -27,16 +27,17 @@ */ package mage.cards.d; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.NamePredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -45,7 +46,6 @@ import mage.target.common.TargetCardInLibrary; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.filter.predicate.mageobject.NamePredicate; /** * @@ -88,8 +88,8 @@ class DoublingChantEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List chosenCards = new ArrayList(); - List namesFiltered = new ArrayList(); + List chosenCards = new ArrayList<>(); + List namesFiltered = new ArrayList<>(); Player player = game.getPlayer(source.getControllerId()); if (player == null) { diff --git a/Mage.Sets/src/mage/cards/e/EatenBySpiders.java b/Mage.Sets/src/mage/cards/e/EatenBySpiders.java index 066a40e889..13a79c5bdf 100644 --- a/Mage.Sets/src/mage/cards/e/EatenBySpiders.java +++ b/Mage.Sets/src/mage/cards/e/EatenBySpiders.java @@ -27,21 +27,22 @@ */ package mage.cards.e; -import java.util.LinkedList; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; +import java.util.LinkedList; +import java.util.UUID; + /** * * @author North @@ -93,7 +94,7 @@ class EatenBySpidersEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { - LinkedList attachments = new LinkedList(); + LinkedList attachments = new LinkedList<>(); attachments.addAll(permanent.getAttachments()); for (UUID attachmentId : attachments) { diff --git a/Mage.Sets/src/mage/cards/e/EchoMage.java b/Mage.Sets/src/mage/cards/e/EchoMage.java index 6fede82743..1edc7da3ad 100644 --- a/Mage.Sets/src/mage/cards/e/EchoMage.java +++ b/Mage.Sets/src/mage/cards/e/EchoMage.java @@ -27,7 +27,6 @@ */ package mage.cards.e; -import java.util.UUID; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -51,6 +50,8 @@ import mage.game.Game; import mage.game.stack.Spell; import mage.target.TargetSpell; +import java.util.UUID; + /** * * @author North @@ -79,7 +80,7 @@ public class EchoMage extends LevelerCard { // LEVEL 2-3 // 2/4 // {U}{U}, {tap}: Copy target instant or sorcery spell. You may choose new targets for the copy. - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CopyTargetSpellEffect(), new ManaCostsImpl("{U}{U}")); ability.addTarget(new TargetSpell(filter)); ability.addCost(new TapSourceCost()); @@ -87,7 +88,7 @@ public class EchoMage extends LevelerCard { // LEVEL 4+ // 2/5 // {U}{U}, {tap}: Copy target instant or sorcery spell twice. You may choose new targets for the copies. - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new EchoMageEffect(), new ManaCostsImpl("{U}{U}")); ability.addTarget(new TargetSpell(filter)); ability.addCost(new TapSourceCost()); diff --git a/Mage.Sets/src/mage/cards/e/EmptyShrineKannushi.java b/Mage.Sets/src/mage/cards/e/EmptyShrineKannushi.java index 6338e9d72c..f9742dfc28 100644 --- a/Mage.Sets/src/mage/cards/e/EmptyShrineKannushi.java +++ b/Mage.Sets/src/mage/cards/e/EmptyShrineKannushi.java @@ -27,15 +27,13 @@ */ package mage.cards.e; -import java.util.ArrayList; -import java.util.UUID; -import mage.constants.CardType; import mage.MageInt; import mage.MageObject; import mage.ObjectColor; import mage.abilities.keyword.ProtectionAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; import mage.filter.Filter; import mage.filter.FilterCard; import mage.filter.FilterObject; @@ -45,6 +43,9 @@ import mage.filter.predicate.mageobject.ColorPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.ArrayList; +import java.util.UUID; + /** * * @author LevelX2 @@ -113,7 +114,7 @@ class EmptyShrineKannushiProtectionAbility extends ProtectionAbility { } } - ArrayList> colorPredicates = new ArrayList>(); + ArrayList> colorPredicates = new ArrayList<>(); if (color.isBlack()) { colorPredicates.add(new ColorPredicate(ObjectColor.BLACK)); } diff --git a/Mage.Sets/src/mage/cards/e/EnclaveCryptologist.java b/Mage.Sets/src/mage/cards/e/EnclaveCryptologist.java index cb3c2e3757..b0b72289fe 100644 --- a/Mage.Sets/src/mage/cards/e/EnclaveCryptologist.java +++ b/Mage.Sets/src/mage/cards/e/EnclaveCryptologist.java @@ -28,8 +28,6 @@ package mage.cards.e; -import mage.constants.CardType; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -39,10 +37,12 @@ import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawDiscardControllerEffect; -import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.LevelUpAbility; +import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Zone; import java.util.UUID; @@ -63,10 +63,10 @@ public class EnclaveCryptologist extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}{U}"))); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawDiscardControllerEffect(), new TapSourceCost()); - Abilities abilities1 = new AbilitiesImpl(ability); + Abilities abilities1 = new AbilitiesImpl<>(ability); ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapSourceCost()); - Abilities abilities2 = new AbilitiesImpl(ability); + Abilities abilities2 = new AbilitiesImpl<>(ability); this.addAbilities(LevelerCardBuilder.construct( new LevelerCardBuilder.LevelAbility(1, 2, abilities1, 0, 1), diff --git a/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java b/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java index fda223339a..1d38457d6b 100644 --- a/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java +++ b/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java @@ -27,22 +27,23 @@ */ package mage.cards.e; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.watchers.common.SourceDidDamageWatcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -119,7 +120,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { @Override public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); - Set possibleTargets = new HashSet(); + Set possibleTargets = new HashSet<>(); SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher"); if (watcher != null) { for (UUID targetId : availablePossibleTargets) { diff --git a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java index 0a3c265f13..d48d4a71b5 100644 --- a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java +++ b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java @@ -27,9 +27,6 @@ */ package mage.cards.e; -import java.util.HashMap; -import java.util.Objects; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -48,6 +45,10 @@ import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import java.util.HashMap; +import java.util.Objects; +import java.util.UUID; + /** * * @author spjspj @@ -100,7 +101,7 @@ class EyeOfSingularityETBEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - HashMap cardNames = new HashMap(); + HashMap cardNames = new HashMap<>(); HashMap toDestroy = new HashMap<>(); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/cards/f/FaithsReward.java b/Mage.Sets/src/mage/cards/f/FaithsReward.java index 53943aadeb..0ea52836eb 100644 --- a/Mage.Sets/src/mage/cards/f/FaithsReward.java +++ b/Mage.Sets/src/mage/cards/f/FaithsReward.java @@ -27,12 +27,15 @@ */ package mage.cards.f; -import mage.constants.*; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.WatcherScope; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; @@ -99,7 +102,7 @@ class FaithsRewardEffect extends OneShotEffect { } class FaithsRewardWatcher extends Watcher { - ArrayList cards = new ArrayList(); + ArrayList cards = new ArrayList<>(); public FaithsRewardWatcher() { super("FaithsRewardWatcher", WatcherScope.GAME); diff --git a/Mage.Sets/src/mage/cards/f/FellShepherd.java b/Mage.Sets/src/mage/cards/f/FellShepherd.java index c4db208110..4fab1fb1c5 100644 --- a/Mage.Sets/src/mage/cards/f/FellShepherd.java +++ b/Mage.Sets/src/mage/cards/f/FellShepherd.java @@ -27,9 +27,6 @@ */ package mage.cards.f; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -42,11 +39,7 @@ import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.WatcherScope; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; @@ -57,6 +50,10 @@ import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; import mage.watchers.Watcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -98,7 +95,7 @@ public class FellShepherd extends CardImpl { class FellShepherdWatcher extends Watcher { - private Set creatureIds = new HashSet(); + private Set creatureIds = new HashSet<>(); public FellShepherdWatcher() { super("YourCreaturesPutToGraveFromBattlefield", WatcherScope.PLAYER); diff --git a/Mage.Sets/src/mage/cards/f/Fireball.java b/Mage.Sets/src/mage/cards/f/Fireball.java index 56539e5869..ed91c98e46 100644 --- a/Mage.Sets/src/mage/cards/f/Fireball.java +++ b/Mage.Sets/src/mage/cards/f/Fireball.java @@ -27,11 +27,6 @@ */ package mage.cards.f; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; @@ -44,6 +39,8 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCreatureOrPlayer; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -158,9 +155,7 @@ class FireballTargetCreatureOrPlayer extends TargetCreatureOrPlayer { } possibleTargets.removeAll(getTargets()); - Iterator it = possibleTargets.iterator(); - while (it.hasNext()) { - UUID targetId = it.next(); + for (UUID targetId : possibleTargets) { TargetCreatureOrPlayer target = this.copy(); target.clearChosen(); target.addTarget(targetId, source, game, true); diff --git a/Mage.Sets/src/mage/cards/f/FulgentDistraction.java b/Mage.Sets/src/mage/cards/f/FulgentDistraction.java index d8737c2295..7b9018ec28 100644 --- a/Mage.Sets/src/mage/cards/f/FulgentDistraction.java +++ b/Mage.Sets/src/mage/cards/f/FulgentDistraction.java @@ -28,20 +28,21 @@ package mage.cards.f; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.EquipAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author maurer.it_at_gmail.com @@ -84,7 +85,7 @@ class FulgentDistractionEffect extends OneShotEffect { for ( UUID target : targetPointer.getTargets(game, source) ) { Permanent creature = game.getPermanent(target); - List copiedAttachments = new ArrayList(creature.getAttachments()); + List copiedAttachments = new ArrayList<>(creature.getAttachments()); for ( UUID equipmentId : copiedAttachments ) { Permanent equipment = game.getPermanent(equipmentId); boolean isEquipment = false; diff --git a/Mage.Sets/src/mage/cards/g/GargoyleSentinel.java b/Mage.Sets/src/mage/cards/g/GargoyleSentinel.java index 61da303d66..771b115eab 100644 --- a/Mage.Sets/src/mage/cards/g/GargoyleSentinel.java +++ b/Mage.Sets/src/mage/cards/g/GargoyleSentinel.java @@ -28,14 +28,6 @@ package mage.cards.g; -import java.util.Iterator; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -45,9 +37,12 @@ import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -98,11 +93,7 @@ class GargoyleSentinelEffect extends ContinuousEffectImpl { switch (layer) { case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { - for (Iterator i = permanent.getAbilities().iterator(); i.hasNext();) { - Ability entry = i.next(); - if (entry.getId().equals(DefenderAbility.getInstance().getId())) - i.remove(); - } + permanent.getAbilities().removeIf(entry -> entry.getId().equals(DefenderAbility.getInstance().getId())); permanent.getAbilities().add(FlyingAbility.getInstance()); } break; diff --git a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java index 84e347c83a..72d5b4bbce 100644 --- a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java +++ b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java @@ -27,9 +27,6 @@ */ package mage.cards.g; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -47,6 +44,10 @@ import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.watchers.common.PlayerDamagedBySourceWatcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -106,7 +107,7 @@ class GiltspireAvengerTarget extends TargetPermanent { @Override public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); - Set possibleTargets = new HashSet(); + Set possibleTargets = new HashSet<>(); PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/g/GravityWell.java b/Mage.Sets/src/mage/cards/g/GravityWell.java index 05f60b23cb..ce786964bb 100644 --- a/Mage.Sets/src/mage/cards/g/GravityWell.java +++ b/Mage.Sets/src/mage/cards/g/GravityWell.java @@ -27,8 +27,6 @@ */ package mage.cards.g; -import java.util.Iterator; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.ContinuousEffectImpl; @@ -36,18 +34,15 @@ import mage.abilities.effects.Effect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -132,12 +127,7 @@ class GravityWellEffect extends ContinuousEffectImpl { switch (layer) { case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { - for (Iterator i = permanent.getAbilities().iterator(); i.hasNext();) { - Ability entry = i.next(); - if (entry.getId().equals(FlyingAbility.getInstance().getId())) { - i.remove(); - } - } + permanent.getAbilities().removeIf(entry -> entry.getId().equals(FlyingAbility.getInstance().getId())); } break; } diff --git a/Mage.Sets/src/mage/cards/h/HalimarWavewatch.java b/Mage.Sets/src/mage/cards/h/HalimarWavewatch.java index edb2290cec..916d919c0e 100644 --- a/Mage.Sets/src/mage/cards/h/HalimarWavewatch.java +++ b/Mage.Sets/src/mage/cards/h/HalimarWavewatch.java @@ -27,7 +27,6 @@ */ package mage.cards.h; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -38,6 +37,7 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -58,11 +58,11 @@ public class HalimarWavewatch extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}"))); - Abilities levelAbilities = new AbilitiesImpl(); + Abilities levelAbilities = new AbilitiesImpl<>(); levelAbilities.add(new IslandwalkAbility()); this.addAbilities(LevelerCardBuilder.construct( - new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl(), 0, 6), + new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl<>(), 0, 6), new LevelerCardBuilder.LevelAbility(5, -1, levelAbilities, 6, 6) )); setMaxLevelCounters(5); diff --git a/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java b/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java index ee067fb024..fccf2fecd3 100644 --- a/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java +++ b/Mage.Sets/src/mage/cards/h/HarmonicConvergence.java @@ -27,10 +27,6 @@ */ package mage.cards.h; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -46,6 +42,11 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetCard; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -93,13 +94,9 @@ class HarmonicConvergenceEffect extends OneShotEffect { source.getSourceId(), game); - HashMap> moveList = new HashMap>(); + HashMap> moveList = new HashMap<>(); for (Permanent permanent : enchantments) { - List list = moveList.get(permanent.getControllerId()); - if (list == null) { - list = new ArrayList(); - moveList.put(permanent.getControllerId(), list); - } + List list = moveList.computeIfAbsent(permanent.getControllerId(), k -> new ArrayList<>()); list.add(permanent); } diff --git a/Mage.Sets/src/mage/cards/i/IkiralOutrider.java b/Mage.Sets/src/mage/cards/i/IkiralOutrider.java index d42b4a8366..dfd3748a5a 100644 --- a/Mage.Sets/src/mage/cards/i/IkiralOutrider.java +++ b/Mage.Sets/src/mage/cards/i/IkiralOutrider.java @@ -28,17 +28,17 @@ package mage.cards.i; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.LevelUpAbility; +import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -58,10 +58,10 @@ public class IkiralOutrider extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{4}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(VigilanceAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(VigilanceAbility.getInstance()); this.addAbilities(LevelerCardBuilder.construct( diff --git a/Mage.Sets/src/mage/cards/j/JoragaTreespeaker.java b/Mage.Sets/src/mage/cards/j/JoragaTreespeaker.java index 198ecca2ba..f071b30fc5 100644 --- a/Mage.Sets/src/mage/cards/j/JoragaTreespeaker.java +++ b/Mage.Sets/src/mage/cards/j/JoragaTreespeaker.java @@ -28,10 +28,6 @@ package mage.cards.j; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Zone; import mage.MageInt; import mage.Mana; import mage.abilities.Abilities; @@ -46,9 +42,14 @@ import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; +import java.util.UUID; + /** * @@ -77,13 +78,13 @@ public class JoragaTreespeaker extends LevelerCard { // LEVEL 1-4 // 1/2 // {T}: Add {G}{G} to your mana pool. - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GreenMana(2), new TapSourceCost())); // LEVEL 5+ // 1/4 // Elves you control have "{T}: Add {G}{G} to your mana pool." - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GreenMana(2), new TapSourceCost()), Duration.WhileOnBattlefield, filter))); diff --git a/Mage.Sets/src/mage/cards/k/KabiraVindicator.java b/Mage.Sets/src/mage/cards/k/KabiraVindicator.java index 571fa48b0b..9641d3d24e 100644 --- a/Mage.Sets/src/mage/cards/k/KabiraVindicator.java +++ b/Mage.Sets/src/mage/cards/k/KabiraVindicator.java @@ -27,9 +27,6 @@ */ package mage.cards.k; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -41,6 +38,9 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import java.util.UUID; @@ -62,10 +62,10 @@ public class KabiraVindicator extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{W}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), true))); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(2, 2, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), true))); this.addAbilities(LevelerCardBuilder.construct( diff --git a/Mage.Sets/src/mage/cards/k/KarganDragonlord.java b/Mage.Sets/src/mage/cards/k/KarganDragonlord.java index 3a18da36d8..9d1d6edb9d 100644 --- a/Mage.Sets/src/mage/cards/k/KarganDragonlord.java +++ b/Mage.Sets/src/mage/cards/k/KarganDragonlord.java @@ -28,9 +28,6 @@ package mage.cards.k; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -44,6 +41,9 @@ import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; import java.util.UUID; @@ -63,10 +63,10 @@ public class KarganDragonlord extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{R}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(FlyingAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(FlyingAbility.getInstance()); abilities2.add(TrampleAbility.getInstance()); abilities2.add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{R}"))); diff --git a/Mage.Sets/src/mage/cards/k/KazanduTuskcaller.java b/Mage.Sets/src/mage/cards/k/KazanduTuskcaller.java index 5f52495081..236ec2504d 100644 --- a/Mage.Sets/src/mage/cards/k/KazanduTuskcaller.java +++ b/Mage.Sets/src/mage/cards/k/KazanduTuskcaller.java @@ -27,8 +27,6 @@ */ package mage.cards.k; -import mage.constants.CardType; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -41,6 +39,8 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Zone; import mage.game.permanent.token.ElephantToken; import java.util.UUID; @@ -61,12 +61,12 @@ public class KazanduTuskcaller extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}{G}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new ElephantToken()), new TapSourceCost())); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new ElephantToken(), 2), new TapSourceCost())); diff --git a/Mage.Sets/src/mage/cards/k/KillingWave.java b/Mage.Sets/src/mage/cards/k/KillingWave.java index b719c3b334..637362da98 100644 --- a/Mage.Sets/src/mage/cards/k/KillingWave.java +++ b/Mage.Sets/src/mage/cards/k/KillingWave.java @@ -27,13 +27,13 @@ */ package mage.cards.k; -import mage.constants.CardType; -import mage.constants.Outcome; import mage.abilities.Ability; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -93,8 +93,8 @@ class KillingWaveEffect extends OneShotEffect { int amount = (new ManacostVariableValue()).calculate(game, source, this); if (amount > 0) { - LinkedList sacrifices = new LinkedList(); - HashMap lifePaidAmounts = new HashMap(); + LinkedList sacrifices = new LinkedList<>(); + HashMap lifePaidAmounts = new HashMap<>(); FilterCreaturePermanent filter = new FilterCreaturePermanent(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/k/KnightOfCliffhaven.java b/Mage.Sets/src/mage/cards/k/KnightOfCliffhaven.java index 1d10e90a9b..70903f82cb 100644 --- a/Mage.Sets/src/mage/cards/k/KnightOfCliffhaven.java +++ b/Mage.Sets/src/mage/cards/k/KnightOfCliffhaven.java @@ -27,7 +27,6 @@ */ package mage.cards.k; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -39,6 +38,7 @@ import mage.abilities.keyword.LevelerCardBuilder; import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -59,10 +59,10 @@ public class KnightOfCliffhaven extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(FlyingAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(FlyingAbility.getInstance()); abilities2.add(VigilanceAbility.getInstance()); diff --git a/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java b/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java index 1d802133f1..3b0beda3b7 100644 --- a/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java +++ b/Mage.Sets/src/mage/cards/k/KynaiosAndTiroOfMeletis.java @@ -27,9 +27,6 @@ */ package mage.cards.k; -import java.util.HashMap; -import java.util.Objects; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; @@ -50,6 +47,10 @@ import mage.players.PlayerList; import mage.target.Target; import mage.target.common.TargetCardInHand; +import java.util.HashMap; +import java.util.Objects; +import java.util.UUID; + /** * * @author spjspj @@ -110,7 +111,7 @@ class KynaiosAndTirosEffect extends OneShotEffect { Player currentPlayer = game.getPlayer(playerList.get()); UUID firstInactivePlayer = null; Target target = new TargetCardInHand(filter); - HashMap noLandPlayers = new HashMap(); + HashMap noLandPlayers = new HashMap<>(); while (controller.canRespond()) { if (currentPlayer != null && currentPlayer.canRespond() && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { diff --git a/Mage.Sets/src/mage/cards/l/LeoninArbiter.java b/Mage.Sets/src/mage/cards/l/LeoninArbiter.java index db3672a1d4..8dbb86850a 100644 --- a/Mage.Sets/src/mage/cards/l/LeoninArbiter.java +++ b/Mage.Sets/src/mage/cards/l/LeoninArbiter.java @@ -27,11 +27,6 @@ */ package mage.cards.l; -import java.util.AbstractMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.SpecialAction; @@ -41,16 +36,14 @@ import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; +import java.util.*; + /** * * @author maurer.it_at_gmail.com, dustinconrad @@ -135,7 +128,7 @@ class LeoninArbiterIgnoreEffect extends OneShotEffect { Map.Entry> turnIgnoringPlayersPair = (Map.Entry>) game.getState().getValue(key); if (turnIgnoringPlayersPair == null || !activationState.equals(turnIgnoringPlayersPair.getKey())) { - turnIgnoringPlayersPair = new AbstractMap.SimpleImmutableEntry>(activationState, new HashSet()); + turnIgnoringPlayersPair = new AbstractMap.SimpleImmutableEntry<>(activationState, new HashSet<>()); game.getState().setValue(key, turnIgnoringPlayersPair); } diff --git a/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java b/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java index b63a31acf3..faf8e86abb 100644 --- a/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java +++ b/Mage.Sets/src/mage/cards/l/LordOfShatterskullPass.java @@ -27,10 +27,6 @@ */ package mage.cards.l; -import java.util.List; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -42,11 +38,16 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; +import mage.constants.Outcome; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -66,11 +67,11 @@ public class LordOfShatterskullPass extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}{R}"))); // LEVEL 1-5 // 6/6 - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); // LEVEL 6+ // 6/6 // Whenever Lord of Shatterskull Pass attacks, it deals 6 damage to each creature defending player controls. - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(new AttacksTriggeredAbility(new LordOfShatterskullPassEffect(), false)); this.addAbilities(LevelerCardBuilder.construct( diff --git a/Mage.Sets/src/mage/cards/m/MarchOfSouls.java b/Mage.Sets/src/mage/cards/m/MarchOfSouls.java index db32fd5a2b..4f4a9b9b04 100644 --- a/Mage.Sets/src/mage/cards/m/MarchOfSouls.java +++ b/Mage.Sets/src/mage/cards/m/MarchOfSouls.java @@ -27,9 +27,6 @@ */ package mage.cards.m; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -41,6 +38,10 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.SpiritWhiteToken; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + /** * * @author LoneFox @@ -85,7 +86,7 @@ class MarchOfSoulsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { List creatures = game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game); - HashMap playersWithCreatures = new HashMap(); + HashMap playersWithCreatures = new HashMap<>(); for(Permanent p : creatures) { UUID controllerId = p.getControllerId(); if(p.destroy(source.getSourceId(), game, true)) { diff --git a/Mage.Sets/src/mage/cards/m/MazesEnd.java b/Mage.Sets/src/mage/cards/m/MazesEnd.java index ba28845b4f..0607d55c90 100644 --- a/Mage.Sets/src/mage/cards/m/MazesEnd.java +++ b/Mage.Sets/src/mage/cards/m/MazesEnd.java @@ -28,12 +28,6 @@ package mage.cards.m; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.common.SimpleActivatedAbility; @@ -45,6 +39,9 @@ import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; @@ -52,6 +49,10 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCardInLibrary; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author LevelX2 @@ -111,7 +112,7 @@ class MazesEndEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - List names = new ArrayList(); + List names = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { if (permanent.hasSubtype("Gate", game)) { if (!names.contains(permanent.getName())) { diff --git a/Mage.Sets/src/mage/cards/m/Mindreaver.java b/Mage.Sets/src/mage/cards/m/Mindreaver.java index 6de80efc19..593b3ef29d 100644 --- a/Mage.Sets/src/mage/cards/m/Mindreaver.java +++ b/Mage.Sets/src/mage/cards/m/Mindreaver.java @@ -27,9 +27,6 @@ */ package mage.cards.m; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -57,6 +54,10 @@ import mage.target.TargetPlayer; import mage.target.TargetSpell; import mage.util.CardUtil; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -138,7 +139,7 @@ class MindreaverNamePredicate implements Predicate { @Override public boolean apply(MageObject input, Game game) { - Set cardNames = new HashSet(); + Set cardNames = new HashSet<>(); UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); ExileZone exileZone = game.getExile().getExileZone(exileId); if (exileZone != null) { diff --git a/Mage.Sets/src/mage/cards/m/MitoticManipulation.java b/Mage.Sets/src/mage/cards/m/MitoticManipulation.java index df8a291fb1..fc3627fb56 100644 --- a/Mage.Sets/src/mage/cards/m/MitoticManipulation.java +++ b/Mage.Sets/src/mage/cards/m/MitoticManipulation.java @@ -27,16 +27,9 @@ */ package mage.cards.m; -import java.util.HashSet; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -47,6 +40,10 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetCard; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + /** * * @author North @@ -89,7 +86,7 @@ class MitoticManipulationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game); - HashSet permanentNames = new HashSet(); + HashSet permanentNames = new HashSet<>(); FilterCard filter = new FilterCard("card to put onto the battlefield"); for (Permanent permanent : permanents) { permanentNames.add(permanent.getName()); diff --git a/Mage.Sets/src/mage/cards/m/MurderousSpoils.java b/Mage.Sets/src/mage/cards/m/MurderousSpoils.java index e2a7f29e7a..19675103ba 100644 --- a/Mage.Sets/src/mage/cards/m/MurderousSpoils.java +++ b/Mage.Sets/src/mage/cards/m/MurderousSpoils.java @@ -27,9 +27,6 @@ */ package mage.cards.m; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffect; @@ -48,6 +45,10 @@ import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; import mage.target.targetpointer.FixedTarget; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author wetterlicht @@ -94,7 +95,7 @@ class MurderousSpoilsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); if (target != null) { - List attachments = new ArrayList(); + List attachments = new ArrayList<>(); for (UUID uuid : target.getAttachments()) { Permanent attached = game.getBattlefield().getPermanent(uuid); if (attached.getSubtype(game).contains("Equipment")) { diff --git a/Mage.Sets/src/mage/cards/n/NaturesWill.java b/Mage.Sets/src/mage/cards/n/NaturesWill.java index 04206d7fdf..b60c149917 100644 --- a/Mage.Sets/src/mage/cards/n/NaturesWill.java +++ b/Mage.Sets/src/mage/cards/n/NaturesWill.java @@ -27,10 +27,6 @@ */ package mage.cards.n; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; @@ -47,6 +43,11 @@ import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -74,7 +75,7 @@ public class NaturesWill extends CardImpl { class NaturesWillTriggeredAbility extends TriggeredAbilityImpl { private boolean madeDamge = false; - private Set damagedPlayers = new HashSet(); + private Set damagedPlayers = new HashSet<>(); public NaturesWillTriggeredAbility() { super(Zone.BATTLEFIELD, new NaturesWillEffect(), false); @@ -83,7 +84,7 @@ class NaturesWillTriggeredAbility extends TriggeredAbilityImpl { public NaturesWillTriggeredAbility(final NaturesWillTriggeredAbility ability) { super(ability); this.madeDamge = ability.madeDamge; - this.damagedPlayers = new HashSet(); + this.damagedPlayers = new HashSet<>(); this.damagedPlayers.addAll(ability.damagedPlayers); } @@ -109,7 +110,7 @@ class NaturesWillTriggeredAbility extends TriggeredAbilityImpl { } if (event.getType().equals(EventType.COMBAT_DAMAGE_STEP_POST)) { if (madeDamge) { - Set damagedPlayersCopy = new HashSet(); + Set damagedPlayersCopy = new HashSet<>(); damagedPlayersCopy.addAll(damagedPlayers); for(Effect effect: this.getEffects()) { effect.setValue("damagedPlayers", damagedPlayersCopy); diff --git a/Mage.Sets/src/mage/cards/n/NirkanaCutthroat.java b/Mage.Sets/src/mage/cards/n/NirkanaCutthroat.java index 6de9b1f43a..46b28a2520 100644 --- a/Mage.Sets/src/mage/cards/n/NirkanaCutthroat.java +++ b/Mage.Sets/src/mage/cards/n/NirkanaCutthroat.java @@ -28,7 +28,6 @@ package mage.cards.n; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -40,6 +39,7 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -58,10 +58,10 @@ public class NirkanaCutthroat extends LevelerCard { this.toughness = new MageInt(2); this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{B}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(DeathtouchAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(FirstStrikeAbility.getInstance()); abilities2.add(DeathtouchAbility.getInstance()); diff --git a/Mage.Sets/src/mage/cards/n/NullChampion.java b/Mage.Sets/src/mage/cards/n/NullChampion.java index 20ccc4829e..3430bd1da0 100644 --- a/Mage.Sets/src/mage/cards/n/NullChampion.java +++ b/Mage.Sets/src/mage/cards/n/NullChampion.java @@ -28,7 +28,6 @@ package mage.cards.n; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -40,6 +39,7 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import mage.constants.Zone; import java.util.UUID; @@ -59,9 +59,9 @@ public class NullChampion extends LevelerCard { this.toughness = new MageInt(1); this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{B}"))); this.addAbilities(LevelerCardBuilder.construct( diff --git a/Mage.Sets/src/mage/cards/o/OngoingInvestigation.java b/Mage.Sets/src/mage/cards/o/OngoingInvestigation.java index cfaea445eb..56b8527f32 100644 --- a/Mage.Sets/src/mage/cards/o/OngoingInvestigation.java +++ b/Mage.Sets/src/mage/cards/o/OngoingInvestigation.java @@ -27,9 +27,6 @@ */ package mage.cards.o; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleActivatedAbility; @@ -50,6 +47,10 @@ import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.common.TargetCardInYourGraveyard; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author fireshoes @@ -82,7 +83,7 @@ public class OngoingInvestigation extends CardImpl { class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl { private boolean madeDamage = false; - private Set damagedPlayers = new HashSet(); + private Set damagedPlayers = new HashSet<>(); public OngoingInvestigationTriggeredAbility() { super(Zone.BATTLEFIELD, new InvestigateEffect(), false); @@ -91,7 +92,7 @@ class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl { public OngoingInvestigationTriggeredAbility(final OngoingInvestigationTriggeredAbility ability) { super(ability); this.madeDamage = ability.madeDamage; - this.damagedPlayers = new HashSet(); + this.damagedPlayers = new HashSet<>(); this.damagedPlayers.addAll(ability.damagedPlayers); } @@ -117,7 +118,7 @@ class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl { } if (event.getType().equals(EventType.COMBAT_DAMAGE_STEP_POST)) { if (madeDamage) { - Set damagedPlayersCopy = new HashSet(); + Set damagedPlayersCopy = new HashSet<>(); damagedPlayersCopy.addAll(damagedPlayers); for(Effect effect: this.getEffects()) { effect.setValue("damagedPlayers", damagedPlayersCopy); diff --git a/Mage.Sets/src/mage/cards/o/Outwit.java b/Mage.Sets/src/mage/cards/o/Outwit.java index cf140a7a4a..0d0d0156db 100644 --- a/Mage.Sets/src/mage/cards/o/Outwit.java +++ b/Mage.Sets/src/mage/cards/o/Outwit.java @@ -141,7 +141,7 @@ public class Outwit extends CardImpl { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { - Set possibleTargets = new HashSet(); + Set possibleTargets = new HashSet<>(); for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell && filter.match((Spell) stackObject, game)) { if (targetsPlayer(stackObject.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java b/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java index 73c19fe322..0ab8b036c2 100644 --- a/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java +++ b/Mage.Sets/src/mage/cards/p/PyxisOfPandemonium.java @@ -27,9 +27,6 @@ */ package mage.cards.p; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -37,11 +34,7 @@ import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -50,6 +43,10 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + /** * * @author LevelX2 @@ -117,11 +114,7 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { if (player.getLibrary().size() > 0) { Card card = player.getLibrary().getFromTop(game); String exileKey = playerId.toString() + CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()).toString(); - UUID exileId = exileIds.get(exileKey); - if (exileId == null) { - exileId = UUID.randomUUID(); - exileIds.put(exileKey, exileId); - } + UUID exileId = exileIds.computeIfAbsent(exileKey, k -> UUID.randomUUID()); player.moveCardsToExile(card, source, game, false, exileId, sourceObject.getIdName() + " (" + player.getName() + ')'); card.setFaceDown(true, game); } diff --git a/Mage.Sets/src/mage/cards/r/Reciprocate.java b/Mage.Sets/src/mage/cards/r/Reciprocate.java index 8df2f2ba0b..050ca5fcd4 100644 --- a/Mage.Sets/src/mage/cards/r/Reciprocate.java +++ b/Mage.Sets/src/mage/cards/r/Reciprocate.java @@ -27,9 +27,6 @@ */ package mage.cards.r; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.common.ExileTargetEffect; @@ -42,6 +39,10 @@ import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.watchers.common.PlayerDamagedBySourceWatcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * @author LevelX2 */ @@ -89,7 +90,7 @@ class ReciprocateTarget extends TargetPermanent { @Override public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); - Set possibleTargets = new HashSet(); + Set possibleTargets = new HashSet<>(); PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/r/ReverseTheSands.java b/Mage.Sets/src/mage/cards/r/ReverseTheSands.java index 970864b126..c4b09c30f2 100644 --- a/Mage.Sets/src/mage/cards/r/ReverseTheSands.java +++ b/Mage.Sets/src/mage/cards/r/ReverseTheSands.java @@ -27,9 +27,6 @@ */ package mage.cards.r; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -41,6 +38,10 @@ import mage.constants.Outcome; import mage.game.Game; import mage.players.Player; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -86,7 +87,7 @@ class ReverseTheSandsEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Choice lifeChoice = new ChoiceImpl(true); - Set choices = new HashSet(); + Set choices = new HashSet<>(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/s/SecondSunrise.java b/Mage.Sets/src/mage/cards/s/SecondSunrise.java index 29963084b3..4ce88d3d74 100644 --- a/Mage.Sets/src/mage/cards/s/SecondSunrise.java +++ b/Mage.Sets/src/mage/cards/s/SecondSunrise.java @@ -27,20 +27,23 @@ */ package mage.cards.s; -import java.util.ArrayList; -import java.util.UUID; - -import mage.constants.*; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.WatcherScope; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; import mage.watchers.Watcher; +import java.util.ArrayList; +import java.util.UUID; + /** * * @author LevelX2 @@ -101,7 +104,7 @@ class SecondSunriseEffect extends OneShotEffect { } class SecondSunriseWatcher extends Watcher { - ArrayList cards = new ArrayList(); + ArrayList cards = new ArrayList<>(); public SecondSunriseWatcher() { super("SecondSunriseWatcher", WatcherScope.GAME); diff --git a/Mage.Sets/src/mage/cards/s/ShoalSerpent.java b/Mage.Sets/src/mage/cards/s/ShoalSerpent.java index faa9e423d9..af0a932b60 100644 --- a/Mage.Sets/src/mage/cards/s/ShoalSerpent.java +++ b/Mage.Sets/src/mage/cards/s/ShoalSerpent.java @@ -27,10 +27,6 @@ */ package mage.cards.s; -import java.util.Iterator; -import java.util.UUID; - -import mage.constants.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.LandfallAbility; @@ -38,9 +34,12 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.keyword.DefenderAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.*; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -95,12 +94,7 @@ class ShoalSerpentEffect extends ContinuousEffectImpl { switch (layer) { case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { - for (Iterator i = permanent.getAbilities().iterator(); i.hasNext();) { - Ability entry = i.next(); - if (entry.getId().equals(DefenderAbility.getInstance().getId())) { - i.remove(); - } - } + permanent.getAbilities().removeIf(entry -> entry.getId().equals(DefenderAbility.getInstance().getId())); } break; } diff --git a/Mage.Sets/src/mage/cards/s/SkywatcherAdept.java b/Mage.Sets/src/mage/cards/s/SkywatcherAdept.java index 6d73cd9753..d68523cb9a 100644 --- a/Mage.Sets/src/mage/cards/s/SkywatcherAdept.java +++ b/Mage.Sets/src/mage/cards/s/SkywatcherAdept.java @@ -27,7 +27,6 @@ */ package mage.cards.s; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -38,6 +37,7 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -58,10 +58,10 @@ public class SkywatcherAdept extends LevelerCard { this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(FlyingAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(FlyingAbility.getInstance()); this.addAbilities(LevelerCardBuilder.construct( diff --git a/Mage.Sets/src/mage/cards/s/SpellContortion.java b/Mage.Sets/src/mage/cards/s/SpellContortion.java index 7dd9587bbf..778996f88a 100644 --- a/Mage.Sets/src/mage/cards/s/SpellContortion.java +++ b/Mage.Sets/src/mage/cards/s/SpellContortion.java @@ -27,10 +27,6 @@ */ package mage.cards.s; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import mage.constants.CardType; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.dynamicvalue.common.MultikickerCount; import mage.abilities.effects.common.CounterUnlessPaysEffect; @@ -38,8 +34,13 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.keyword.MultikickerAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; import mage.target.TargetSpell; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -71,7 +72,7 @@ public class SpellContortion extends CardImpl { @Override public List getRules() { - List rules = new ArrayList(); + List rules = new ArrayList<>(); rules.add("Counter target spell unless its controller pays {2}. Draw a card for each time Spell Contortion was kicked."); return rules; } diff --git a/Mage.Sets/src/mage/cards/s/StudentOfWarfare.java b/Mage.Sets/src/mage/cards/s/StudentOfWarfare.java index 7ccfcb29de..0349bb2443 100644 --- a/Mage.Sets/src/mage/cards/s/StudentOfWarfare.java +++ b/Mage.Sets/src/mage/cards/s/StudentOfWarfare.java @@ -28,7 +28,6 @@ package mage.cards.s; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; @@ -40,6 +39,7 @@ import mage.abilities.keyword.LevelUpAbility; import mage.abilities.keyword.LevelerCardBuilder; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -58,10 +58,10 @@ public class StudentOfWarfare extends LevelerCard { this.toughness = new MageInt(1); this.addAbility(new LevelUpAbility(new ManaCostsImpl("{W}"))); - Abilities abilities1 = new AbilitiesImpl(); + Abilities abilities1 = new AbilitiesImpl<>(); abilities1.add(FirstStrikeAbility.getInstance()); - Abilities abilities2 = new AbilitiesImpl(); + Abilities abilities2 = new AbilitiesImpl<>(); abilities2.add(DoubleStrikeAbility.getInstance()); this.addAbilities(LevelerCardBuilder.construct( diff --git a/Mage.Sets/src/mage/cards/t/TheBattleOfYavin.java b/Mage.Sets/src/mage/cards/t/TheBattleOfYavin.java index 3e39261247..0d4ecaa8c7 100644 --- a/Mage.Sets/src/mage/cards/t/TheBattleOfYavin.java +++ b/Mage.Sets/src/mage/cards/t/TheBattleOfYavin.java @@ -27,9 +27,6 @@ */ package mage.cards.t; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.OneShotEffect; @@ -43,6 +40,10 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetOpponent; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + /** * * @author Styxo @@ -93,7 +94,7 @@ class TheBattleOfYavinEffect extends OneShotEffect { int amount = (new ManacostVariableValue()).calculate(game, source, this); if (amount > 0) { - LinkedList sacrifices = new LinkedList(); + LinkedList sacrifices = new LinkedList<>(); FilterNonlandPermanent filter = new FilterNonlandPermanent(); List permanents = game.getBattlefield().getAllActivePermanents(filter, opponent.getId(), game); diff --git a/Mage.Sets/src/mage/cards/t/TheGreatAurora.java b/Mage.Sets/src/mage/cards/t/TheGreatAurora.java index eba6c35b87..aa6345841a 100644 --- a/Mage.Sets/src/mage/cards/t/TheGreatAurora.java +++ b/Mage.Sets/src/mage/cards/t/TheGreatAurora.java @@ -27,12 +27,6 @@ */ package mage.cards.t; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileSpellEffect; @@ -50,6 +44,8 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInHand; +import java.util.*; + /** * * @author LevelX2 @@ -98,11 +94,7 @@ class TheGreatAuroraEffect extends OneShotEffect { Map> permanentsOwned = new HashMap<>(); Collection permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game); for (Permanent permanent : permanents) { - List list = permanentsOwned.get(permanent.getOwnerId()); - if (list == null) { - list = new ArrayList<>(); - permanentsOwned.put(permanent.getOwnerId(), list); - } + List list = permanentsOwned.computeIfAbsent(permanent.getOwnerId(), k -> new ArrayList<>()); list.add(permanent); } diff --git a/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java b/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java index 6a54e2a4e0..ab969163de 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtsOfRuin.java @@ -27,9 +27,6 @@ */ package mage.cards.t; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -44,6 +41,10 @@ import mage.players.Player; import mage.target.Target; import mage.target.common.TargetLandPermanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author LevelX2 @@ -93,7 +94,7 @@ class ThoughtsOfRuinEffect extends OneShotEffect { if (controller != null) { int amount = controller.getHand().size(); if (amount > 0) { - List permanentsToSacrifice = new ArrayList(); + List permanentsToSacrifice = new ArrayList<>(); // select all lands to sacrifice for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/cards/t/ThranTurbine.java b/Mage.Sets/src/mage/cards/t/ThranTurbine.java index c8a34e87ec..8853d1bbee 100644 --- a/Mage.Sets/src/mage/cards/t/ThranTurbine.java +++ b/Mage.Sets/src/mage/cards/t/ThranTurbine.java @@ -27,8 +27,6 @@ */ package mage.cards.t; -import java.util.HashSet; -import java.util.UUID; import mage.ConditionalMana; import mage.Mana; import mage.abilities.Ability; @@ -53,6 +51,9 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.HashSet; +import java.util.UUID; + /** * * @author spjspjs @@ -98,7 +99,7 @@ class ThranTurbineEffect extends OneShotEffect { if (player != null) { Choice numberChoice = new ChoiceImpl(); - HashSet numbers = new HashSet(); + HashSet numbers = new HashSet<>(); numbers.add(Integer.toString(1)); numbers.add(Integer.toString(2)); numberChoice.setChoices(numbers); diff --git a/Mage.Sets/src/mage/cards/t/TideOfWar.java b/Mage.Sets/src/mage/cards/t/TideOfWar.java index c3cc6e4fa2..eb129dd185 100644 --- a/Mage.Sets/src/mage/cards/t/TideOfWar.java +++ b/Mage.Sets/src/mage/cards/t/TideOfWar.java @@ -27,9 +27,6 @@ */ package mage.cards.t; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; @@ -46,6 +43,10 @@ import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * * @author LevelX2 @@ -126,7 +127,7 @@ class TideOfWarEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Set toSacrifice = new HashSet(); + Set toSacrifice = new HashSet<>(); if (controller.flipCoin(game)) { // each blocking creature is sacrificed by its controller for (CombatGroup combatGroup: game.getCombat().getGroups()) { diff --git a/Mage.Sets/src/mage/cards/t/TranscendentMaster.java b/Mage.Sets/src/mage/cards/t/TranscendentMaster.java index afff879001..d9b15b89df 100644 --- a/Mage.Sets/src/mage/cards/t/TranscendentMaster.java +++ b/Mage.Sets/src/mage/cards/t/TranscendentMaster.java @@ -27,15 +27,18 @@ */ package mage.cards.t; -import mage.constants.CardType; import mage.MageInt; import mage.abilities.Abilities; import mage.abilities.AbilitiesImpl; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.keyword.*; +import mage.abilities.keyword.IndestructibleAbility; +import mage.abilities.keyword.LevelUpAbility; +import mage.abilities.keyword.LevelerCardBuilder; +import mage.abilities.keyword.LifelinkAbility; import mage.cards.CardSetInfo; import mage.cards.LevelerCard; +import mage.constants.CardType; import java.util.UUID; @@ -60,12 +63,12 @@ public class TranscendentMaster extends LevelerCard { // LEVEL 6-11 // 6/6 // Lifelink - Abilities abilities1 = new AbilitiesImpl(LifelinkAbility.getInstance()); + Abilities abilities1 = new AbilitiesImpl<>(LifelinkAbility.getInstance()); // LEVEL 12+ // 9/9 // Lifelink // Transcendent Master is indestructible. - Abilities abilities2 = new AbilitiesImpl( + Abilities abilities2 = new AbilitiesImpl<>( LifelinkAbility.getInstance(), IndestructibleAbility.getInstance()); diff --git a/Mage.Sets/src/mage/cards/t/TritonTactics.java b/Mage.Sets/src/mage/cards/t/TritonTactics.java index bcbee12747..91e186877f 100644 --- a/Mage.Sets/src/mage/cards/t/TritonTactics.java +++ b/Mage.Sets/src/mage/cards/t/TritonTactics.java @@ -27,13 +27,6 @@ */ package mage.cards.t; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.effects.ContinuousEffect; @@ -58,6 +51,8 @@ import mage.target.targetpointer.FixedTargets; import mage.util.CardUtil; import mage.watchers.Watcher; +import java.util.*; + /** * * @author LevelX2 @@ -254,11 +249,7 @@ class BlockedCreaturesWatcher extends Watcher { } else { attackerMap = new HashMap<>(); } - attackers = attackerMap.get(zoneChangeCounter); - if (attackers == null) { - attackers = new HashSet<>(); - attackerMap.put(zoneChangeCounter, attackers); - } + attackers = attackerMap.computeIfAbsent(zoneChangeCounter, k -> new HashSet<>()); attackers.add(CardUtil.getCardZoneString(null, attackerId, game)); game.getState().setValue("blockedAttackers" + getSourceId().toString(), attackerMap); } diff --git a/Mage.Sets/src/mage/cards/t/TurnToSlag.java b/Mage.Sets/src/mage/cards/t/TurnToSlag.java index 71b3eed9af..63d54a20ff 100644 --- a/Mage.Sets/src/mage/cards/t/TurnToSlag.java +++ b/Mage.Sets/src/mage/cards/t/TurnToSlag.java @@ -28,20 +28,20 @@ package mage.cards.t; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import mage.constants.CardType; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; import mage.constants.Outcome; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author Loki @@ -80,7 +80,7 @@ class TurnToSlagEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); if (target != null) { - List attachments = new ArrayList(); + List attachments = new ArrayList<>(); for (UUID uuid : target.getAttachments()) { Permanent attached = game.getBattlefield().getPermanent(uuid); if (attached.getSubtype(game).contains("Equipment")) { diff --git a/Mage.Sets/src/mage/cards/w/WarleadersHelix.java b/Mage.Sets/src/mage/cards/w/WarleadersHelix.java index 8643224790..1f6537a1fc 100644 --- a/Mage.Sets/src/mage/cards/w/WarleadersHelix.java +++ b/Mage.Sets/src/mage/cards/w/WarleadersHelix.java @@ -27,16 +27,17 @@ */ package mage.cards.w; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import mage.constants.CardType; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.CardType; import mage.target.common.TargetCreatureOrPlayer; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author jeffwadsworth @@ -64,7 +65,7 @@ public class WarleadersHelix extends CardImpl { @Override public List getRules() { - List rules = new ArrayList(); + List rules = new ArrayList<>(); rules.add("Warleader's Helix deals 4 damage to target creature or player and you gain 4 life."); return rules; } diff --git a/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java b/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java index 327b53cef5..cdfc130164 100644 --- a/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java +++ b/Mage.Sets/src/mage/cards/w/WhimsOfTheFates.java @@ -27,12 +27,6 @@ */ package mage.cards.w; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -49,6 +43,8 @@ import mage.target.Target; import mage.target.TargetPermanent; import mage.util.RandomUtil; +import java.util.*; + /** * * @author LevelX2 @@ -121,7 +117,7 @@ class WhimsOfTheFateEffect extends OneShotEffect { if (currentPlayer != null && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { Map> playerPiles = new HashMap<>(); for (int i = 1; i < 4; i++) { - playerPiles.put(i, new LinkedHashSet()); + playerPiles.put(i, new LinkedHashSet<>()); } playerPermanents.put(currentPlayer.getId(), playerPiles); for (int i = 1; i < 3; i++) { diff --git a/Mage.Stats/src/main/java/com/xmage/ws/util/IPHolderUtil.java b/Mage.Stats/src/main/java/com/xmage/ws/util/IPHolderUtil.java index 406a8b9bd1..ac9ea26bba 100644 --- a/Mage.Stats/src/main/java/com/xmage/ws/util/IPHolderUtil.java +++ b/Mage.Stats/src/main/java/com/xmage/ws/util/IPHolderUtil.java @@ -8,8 +8,8 @@ package com.xmage.ws.util; */ public final class IPHolderUtil { - private static final ThreadLocal ipThreadLocal = new ThreadLocal(); - private static final ThreadLocal userAgentThreadLocal = new ThreadLocal(); + private static final ThreadLocal ipThreadLocal = new ThreadLocal<>(); + private static final ThreadLocal userAgentThreadLocal = new ThreadLocal<>(); private IPHolderUtil() {} diff --git a/Mage.Stats/src/main/java/com/xmage/ws/util/json/JSONParser.java b/Mage.Stats/src/main/java/com/xmage/ws/util/json/JSONParser.java index 3654f32585..ce68bedbfb 100644 --- a/Mage.Stats/src/main/java/com/xmage/ws/util/json/JSONParser.java +++ b/Mage.Stats/src/main/java/com/xmage/ws/util/json/JSONParser.java @@ -34,7 +34,7 @@ public class JSONParser { private CachePolicy cachePolicy = CachePolicy.CACHE_ONE_LEVEL_ONLY; - private Map cache = new HashMap(); + private Map cache = new HashMap<>(); public void parseJSON(String jsonString) throws JSONValidationException { parseJSON(jsonString, true); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/CloneTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/CloneTest.java index 536c5136b3..8863198b27 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/CloneTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/CloneTest.java @@ -1,6 +1,5 @@ package org.mage.test.cards.copy; -import java.util.Iterator; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffectsList; import mage.cards.Card; @@ -140,9 +139,8 @@ public class CloneTest extends CardTestPlayerBase { Logger.getLogger(CloneTest.class).debug("EXISTING CONTINUOUS EFFECTS:"); for (ContinuousEffectsList effectsList : currentGame.getContinuousEffects().allEffectsLists) { - Iterator it = effectsList.iterator(); - while (it.hasNext()) { - ContinuousEffect effect = (ContinuousEffect) it.next(); + for (Object anEffectsList : effectsList) { + ContinuousEffect effect = (ContinuousEffect) anEffectsList; Logger.getLogger(CloneTest.class).debug("- " + effect.toString()); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/load/LoadCallbackClient.java b/Mage.Tests/src/test/java/org/mage/test/load/LoadCallbackClient.java index 8f6943bd0d..e047c2737d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/load/LoadCallbackClient.java +++ b/Mage.Tests/src/test/java/org/mage/test/load/LoadCallbackClient.java @@ -103,24 +103,21 @@ public class LoadCallbackClient implements CallbackClient { } private void startControlThread() { - new Thread(new Runnable() { - @Override - public void run() { - while (true) { - controlCount++; - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (controlCount > 5) { - log.warn("Game seems freezed. Sending boolean message to server."); - session.sendPlayerBoolean(gameId, false); - controlCount = 0; - } + new Thread(() -> { + while (true) { + controlCount++; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (controlCount > 5) { + log.warn("Game seems freezed. Sending boolean message to server."); + session.sendPlayerBoolean(gameId, false); + controlCount = 0; } - } + }).start(); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/load/LoadTest.java b/Mage.Tests/src/test/java/org/mage/test/load/LoadTest.java index bdf0c03257..5e551f1874 100644 --- a/Mage.Tests/src/test/java/org/mage/test/load/LoadTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/load/LoadTest.java @@ -1,7 +1,9 @@ package org.mage.test.load; import mage.cards.Card; +import mage.cards.Sets; import mage.cards.decks.Deck; +import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardLists; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; @@ -13,7 +15,6 @@ import mage.player.ai.ComputerPlayer; import mage.remote.Connection; import mage.remote.Session; import mage.remote.SessionImpl; -import mage.cards.Sets; import mage.view.GameTypeView; import mage.view.TableView; import org.apache.log4j.Logger; @@ -24,7 +25,6 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.cards.decks.DeckCardInfo; /** * Intended to test Mage server under different load patterns. @@ -142,14 +142,11 @@ public class LoadTest { for (int i = 0; i < EXECUTION_COUNT_PLAY_GAME; i++) { final int j = i; - Thread t = new Thread(new Runnable() { - @Override - public void run() { - try { - testSimpleGame0(deckList, j); - } catch (InterruptedException e) { - e.printStackTrace(); - } + Thread t = new Thread(() -> { + try { + testSimpleGame0(deckList, j); + } catch (InterruptedException e) { + e.printStackTrace(); } }); t.start(); @@ -288,7 +285,7 @@ public class LoadTest { */ private Deck generateRandomDeck() { String selectedColors = "BR"; - List allowedColors = new ArrayList(); + List allowedColors = new ArrayList<>(); log.info("Building deck with colors: " + selectedColors); for (int i = 0; i < selectedColors.length(); i++) { char c = selectedColors.charAt(i); diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java b/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java index d07589f557..59802a09c8 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java @@ -1,8 +1,9 @@ package org.mage.test.serverside; -import mage.constants.ColoredManaSymbol; import mage.cards.Card; +import mage.cards.Sets; import mage.cards.decks.Deck; +import mage.constants.ColoredManaSymbol; import mage.constants.MultiplayerAttackOption; import mage.constants.RangeOfInfluence; import mage.game.Game; @@ -11,7 +12,6 @@ import mage.game.GameOptions; import mage.game.TwoPlayerDuel; import mage.player.ai.ComputerPlayer; import mage.players.Player; -import mage.cards.Sets; import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.MageTestBase; @@ -80,7 +80,7 @@ public class PlayGameTest extends MageTestBase { private Deck generateRandomDeck() { String selectedColors = colorChoices.get(new Random().nextInt(colorChoices.size())).toUpperCase(); - List allowedColors = new ArrayList(); + List allowedColors = new ArrayList<>(); logger.info("Building deck with colors: " + selectedColors); for (int i = 0; i < selectedColors.length(); i++) { char c = selectedColors.charAt(i); diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/TestPlayRandomGame.java b/Mage.Tests/src/test/java/org/mage/test/serverside/TestPlayRandomGame.java index e409b73828..8d6a213307 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/TestPlayRandomGame.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/TestPlayRandomGame.java @@ -1,8 +1,9 @@ package org.mage.test.serverside; -import mage.constants.ColoredManaSymbol; import mage.cards.Card; +import mage.cards.Sets; import mage.cards.decks.Deck; +import mage.constants.ColoredManaSymbol; import mage.constants.MultiplayerAttackOption; import mage.constants.RangeOfInfluence; import mage.game.Game; @@ -11,7 +12,6 @@ import mage.game.GameOptions; import mage.game.TwoPlayerDuel; import mage.player.ai.ComputerPlayer; import mage.players.Player; -import mage.cards.Sets; import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.MageTestBase; @@ -71,7 +71,7 @@ public class TestPlayRandomGame extends MageTestBase { private Deck generateRandomDeck() { String selectedColors = colorChoices.get(new Random().nextInt(colorChoices.size())).toUpperCase(); - List allowedColors = new ArrayList(); + List allowedColors = new ArrayList<>(); logger.info("Building deck with colors: " + selectedColors); for (int i = 0; i < selectedColors.length(); i++) { char c = selectedColors.charAt(i); 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 00ee97cd16..472db3d0bc 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 @@ -27,7 +27,6 @@ import org.mage.test.player.TestPlayer; import java.io.File; import java.io.FileNotFoundException; -import java.io.FilenameFilter; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -163,12 +162,7 @@ public abstract class MageTestBase { directory.mkdirs(); } File[] files = directory.listFiles( - new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".game"); - } - } + (dir, name) -> name.endsWith(".game") ); for (File file : files) { file.delete(); 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 698271e521..f97664b789 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 @@ -25,8 +25,6 @@ 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; @@ -150,12 +148,7 @@ public abstract class MageTestPlayerBase { directory.mkdirs(); } File[] files = directory.listFiles( - new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".game"); - } - } + (dir, name) -> name.endsWith(".game") ); for (File file : files) { file.delete(); diff --git a/Mage.Updater/src/main/java/com/magefree/update/helpers/FileHelper.java b/Mage.Updater/src/main/java/com/magefree/update/helpers/FileHelper.java index 9de551c2d9..63b9d873e1 100644 --- a/Mage.Updater/src/main/java/com/magefree/update/helpers/FileHelper.java +++ b/Mage.Updater/src/main/java/com/magefree/update/helpers/FileHelper.java @@ -18,22 +18,12 @@ public final class FileHelper { /** * Filters out dirs. */ - private static final FileFilter anyFileFilter = new FileFilter() { - @Override - public boolean accept(File f) { - return f.isFile(); - } - }; + private static final FileFilter anyFileFilter = f -> f.isFile(); /** * Filters out jars. */ - private static final FilenameFilter jarFileFilter = new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".jar"); - } - }; + private static final FilenameFilter jarFileFilter = (dir, name) -> name.endsWith(".jar"); /** * Gets .jar files from specified folder. @@ -42,7 +32,7 @@ public final class FileHelper { * @return */ public static List findJarsInDir(String dir) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); File directory = new File(dir); if (directory.exists() && directory.isDirectory()) { for (File jar : directory.listFiles(jarFileFilter)) { @@ -59,7 +49,7 @@ public final class FileHelper { * @return */ public static List findAllFilesInDir(String dir) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); File directory = new File(dir); if (directory.exists() && directory.isDirectory()) { for (File jar : directory.listFiles(anyFileFilter)) { diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java index cd041b6d59..fc7378c4ae 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java @@ -212,7 +212,7 @@ public class ContinuousEffects implements Serializable { updateTimestamps(layerEffects); - Collections.sort(layerEffects, sorter); + layerEffects.sort(sorter); return layerEffects; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CopySpellForEachItCouldTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CopySpellForEachItCouldTargetEffect.java index 05bbaaf28e..8a99938b2a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CopySpellForEachItCouldTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CopySpellForEachItCouldTargetEffect.java @@ -27,14 +27,6 @@ */ package mage.abilities.effects.common; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.MageItem; import mage.MageObject; import mage.abilities.Ability; @@ -51,6 +43,8 @@ import mage.target.Target; import mage.target.TargetImpl; import mage.util.TargetAddress; +import java.util.*; + /** * @author duncant * @param @@ -158,7 +152,7 @@ public abstract class CopySpellForEachItCouldTargetEffect ex targetInstance.add(objId, game); } if (!playerTargetCopyMap.containsKey(copy.getControllerId())) { - playerTargetCopyMap.put(copy.getControllerId(), new HashMap()); + playerTargetCopyMap.put(copy.getControllerId(), new HashMap<>()); } playerTargetCopyMap.get(copy.getControllerId()).put(objId, copy); } diff --git a/Mage/src/main/java/mage/cards/ExpansionSet.java b/Mage/src/main/java/mage/cards/ExpansionSet.java index 384601df49..6b6f0d2c0b 100644 --- a/Mage/src/main/java/mage/cards/ExpansionSet.java +++ b/Mage/src/main/java/mage/cards/ExpansionSet.java @@ -27,13 +27,6 @@ */ package mage.cards; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.EnumMap; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.List; import mage.cards.repository.CardCriteria; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; @@ -41,6 +34,9 @@ import mage.constants.Rarity; import mage.constants.SetType; import mage.util.RandomUtil; +import java.io.Serializable; +import java.util.*; + /** * @author BetaSteward_at_googlemail.com */ @@ -403,13 +399,7 @@ public abstract class ExpansionSet implements Serializable { savedCardsInfos = CardRepository.instance.findCards(criteria); // Workaround after card number is numeric if (maxCardNumberInBooster != Integer.MAX_VALUE) { - Iterator iterator = savedCardsInfos.iterator(); - while (iterator.hasNext()) { - CardInfo next = iterator.next(); - if (Integer.valueOf(next.getCardNumber()) > maxCardNumberInBooster && !rarity.equals(Rarity.LAND)) { - iterator.remove(); - } - } + savedCardsInfos.removeIf(next -> Integer.valueOf(next.getCardNumber()) > maxCardNumberInBooster && !rarity.equals(Rarity.LAND)); } savedCards.put(rarity, savedCardsInfos); diff --git a/Mage/src/main/java/mage/game/CardAttribute.java b/Mage/src/main/java/mage/game/CardAttribute.java index 6ed2cd7326..0289d11b1f 100644 --- a/Mage/src/main/java/mage/game/CardAttribute.java +++ b/Mage/src/main/java/mage/game/CardAttribute.java @@ -5,11 +5,12 @@ */ package mage.game; +import mage.ObjectColor; +import mage.cards.Card; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import mage.ObjectColor; -import mage.cards.Card; /** * This class saves changed attributes of cards (e.g. in graveyard, exile or player hands or libraries). @@ -23,7 +24,7 @@ public class CardAttribute implements Serializable { public CardAttribute(Card card) { color = card.getColor(null).copy(); - subtype = new ArrayList(card.getSubtype(null)); + subtype = new ArrayList<>(card.getSubtype(null)); } public CardAttribute(CardAttribute cardAttribute) { diff --git a/Mage/src/main/java/mage/game/GameCanadianHighlanderImpl.java b/Mage/src/main/java/mage/game/GameCanadianHighlanderImpl.java index e2877b17fa..40aecac9ef 100644 --- a/Mage/src/main/java/mage/game/GameCanadianHighlanderImpl.java +++ b/Mage/src/main/java/mage/game/GameCanadianHighlanderImpl.java @@ -27,17 +27,14 @@ */ package mage.game; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import mage.constants.MultiplayerAttackOption; import mage.constants.PhaseStep; import mage.constants.RangeOfInfluence; import mage.game.turn.TurnMod; import mage.players.Player; +import java.util.*; + public abstract class GameCanadianHighlanderImpl extends GameImpl { protected boolean startingPlayerSkipsDraw = true; @@ -58,59 +55,61 @@ public abstract class GameCanadianHighlanderImpl extends GameImpl { } private String getNextMulligan(String mulligan) { - if (mulligan.equals("7")) { - return "6a"; - } else if (mulligan.equals("6a")) { - return "6b"; - } else if (mulligan.equals("6b")) { - return "5a"; - } else if (mulligan.equals("5a")) { - return "5b"; - } else if (mulligan.equals("5b")) { - return "4a"; - } else if (mulligan.equals("4a")) { - return "4b"; - } else if (mulligan.equals("4b")) { - return "3a"; - } else if (mulligan.equals("3a")) { - return "3b"; - } else if (mulligan.equals("3b")) { - return "2a"; - } else if (mulligan.equals("2a")) { - return "2b"; - } else if (mulligan.equals("2b")) { - return "1a"; - } else if (mulligan.equals("1a")) { - return "1b"; + switch (mulligan) { + case "7": + return "6a"; + case "6a": + return "6b"; + case "6b": + return "5a"; + case "5a": + return "5b"; + case "5b": + return "4a"; + case "4a": + return "4b"; + case "4b": + return "3a"; + case "3a": + return "3b"; + case "3b": + return "2a"; + case "2a": + return "2b"; + case "2b": + return "1a"; + case "1a": + return "1b"; } return "0"; } private int getNextMulliganNum(String mulligan) { - if (mulligan.equals("7")) { - return 6; - } else if (mulligan.equals("6a")) { - return 6; - } else if (mulligan.equals("6b")) { - return 5; - } else if (mulligan.equals("5a")) { - return 5; - } else if (mulligan.equals("5b")) { - return 4; - } else if (mulligan.equals("4a")) { - return 4; - } else if (mulligan.equals("4b")) { - return 3; - } else if (mulligan.equals("3a")) { - return 3; - } else if (mulligan.equals("3b")) { - return 2; - } else if (mulligan.equals("2a")) { - return 2; - } else if (mulligan.equals("2b")) { - return 1; - } else if (mulligan.equals("1a")) { - return 1; + switch (mulligan) { + case "7": + return 6; + case "6a": + return 6; + case "6b": + return 5; + case "5a": + return 5; + case "5b": + return 4; + case "4a": + return 4; + case "4b": + return 3; + case "3a": + return 3; + case "3b": + return 2; + case "2a": + return 2; + case "2b": + return 1; + case "1a": + return 1; } return 0; } diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 56fdedf86f..337158a0d3 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -27,19 +27,9 @@ */ package mage.game; -import java.io.IOException; -import java.io.Serializable; -import java.util.*; -import java.util.Map.Entry; - import mage.MageException; import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.ActivatedAbility; -import mage.abilities.DelayedTriggeredAbility; -import mage.abilities.OpeningHandAction; -import mage.abilities.SpellAbility; -import mage.abilities.TriggeredAbility; +import mage.abilities.*; import mage.abilities.common.AttachableToRestrictedAbility; import mage.abilities.common.CantHaveMoreThanAmountCountersSourceAbility; import mage.abilities.effects.ContinuousEffect; @@ -53,24 +43,10 @@ import mage.abilities.keyword.TransformAbility; import mage.abilities.mana.DelayedTriggeredManaAbility; import mage.abilities.mana.TriggeredManaAbility; import mage.actions.impl.MageAction; -import mage.cards.Card; -import mage.cards.Cards; -import mage.cards.CardsImpl; -import mage.cards.MeldCard; -import mage.cards.SplitCard; -import mage.cards.SplitCardHalf; +import mage.cards.*; import mage.cards.decks.Deck; import mage.choices.Choice; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.MultiplayerAttackOption; -import mage.constants.Outcome; -import mage.constants.PhaseStep; -import mage.constants.PlayerAction; -import mage.constants.RangeOfInfluence; -import mage.constants.SpellAbilityType; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.CounterType; import mage.counters.Counters; import mage.designations.Designation; @@ -89,14 +65,8 @@ import mage.game.combat.Combat; import mage.game.command.CommandObject; import mage.game.command.Commander; import mage.game.command.Emblem; -import mage.game.events.DamageEvent; -import mage.game.events.GameEvent; -import mage.game.events.Listener; -import mage.game.events.PlayerQueryEvent; -import mage.game.events.PlayerQueryEventSource; -import mage.game.events.TableEvent; +import mage.game.events.*; import mage.game.events.TableEvent.EventType; -import mage.game.events.TableEventSource; import mage.game.permanent.Battlefield; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; @@ -119,15 +89,14 @@ import mage.util.MessageToClient; import mage.util.RandomUtil; import mage.util.functions.ApplyToPermanent; import mage.watchers.Watchers; -import mage.watchers.common.BlockedAttackerWatcher; -import mage.watchers.common.BloodthirstWatcher; -import mage.watchers.common.CastSpellLastTurnWatcher; -import mage.watchers.common.DamageDoneWatcher; -import mage.watchers.common.MorbidWatcher; -import mage.watchers.common.PlayerDamagedBySourceWatcher; -import mage.watchers.common.PlayerLostLifeWatcher; +import mage.watchers.common.*; import org.apache.log4j.Logger; +import java.io.IOException; +import java.io.Serializable; +import java.util.*; +import java.util.Map.Entry; + public abstract class GameImpl implements Game, Serializable { private static final int ROLLBACK_TURNS_MAX = 4; @@ -2584,11 +2553,7 @@ public abstract class GameImpl implements Game, Serializable { // remembers if a object was in a zone during the resolution of an effect // e.g. Wrath destroys all and you the question is is the replacement effect to apply because the source was also moved by the same effect // because it ahppens all at the same time the replcaement effect has still to be applied - Set idSet = shortLivingLKI.get(zone); - if (idSet == null) { - idSet = new HashSet<>(); - shortLivingLKI.put(zone, idSet); - } + Set idSet = shortLivingLKI.computeIfAbsent(zone, k -> new HashSet<>()); idSet.add(objectId); if (object instanceof Permanent) { Map lkiExtendedMap = lkiExtended.get(objectId); diff --git a/Mage/src/main/java/mage/game/GameState.java b/Mage/src/main/java/mage/game/GameState.java index 4b545ea161..fbda67dc8c 100644 --- a/Mage/src/main/java/mage/game/GameState.java +++ b/Mage/src/main/java/mage/game/GameState.java @@ -27,21 +27,8 @@ */ package mage.game; -import java.io.Serializable; -import java.util.*; - import mage.MageObject; -import mage.abilities.Abilities; -import mage.abilities.Ability; -import mage.abilities.ActivatedAbility; -import mage.abilities.DelayedTriggeredAbilities; -import mage.abilities.DelayedTriggeredAbility; -import mage.abilities.MageSingleton; -import mage.abilities.Mode; -import mage.abilities.SpecialActions; -import mage.abilities.StaticAbility; -import mage.abilities.TriggeredAbilities; -import mage.abilities.TriggeredAbility; +import mage.abilities.*; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffects; import mage.abilities.effects.Effect; @@ -71,6 +58,9 @@ import mage.util.ThreadLocalStringBuilder; import mage.watchers.Watcher; import mage.watchers.Watchers; +import java.io.Serializable; +import java.util.*; + /** * * @author BetaSteward_at_googlemail.com @@ -1091,11 +1081,7 @@ public class GameState implements Serializable, Copyable { } public CardAttribute getCreateCardAttribute(Card card) { - CardAttribute cardAtt = cardAttribute.get(card.getId()); - if (cardAtt == null) { - cardAtt = new CardAttribute(card); - cardAttribute.put(card.getId(), cardAtt); - } + CardAttribute cardAtt = cardAttribute.computeIfAbsent(card.getId(), k -> new CardAttribute(card)); return cardAtt; } diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index e7fbfc40be..85c011229e 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -27,7 +27,6 @@ */ package mage.game.permanent; -import java.util.*; import mage.MageObject; import mage.MageObjectReference; import mage.ObjectColor; @@ -36,25 +35,10 @@ import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.RestrictionEffect; -import mage.abilities.keyword.DeathtouchAbility; -import mage.abilities.keyword.DefenderAbility; -import mage.abilities.keyword.HasteAbility; -import mage.abilities.keyword.HexproofAbility; -import mage.abilities.keyword.IndestructibleAbility; -import mage.abilities.keyword.InfectAbility; -import mage.abilities.keyword.LifelinkAbility; -import mage.abilities.keyword.MorphAbility; -import mage.abilities.keyword.ProtectionAbility; -import mage.abilities.keyword.ShroudAbility; -import mage.abilities.keyword.WitherAbility; +import mage.abilities.keyword.*; import mage.cards.Card; import mage.cards.CardImpl; -import mage.constants.AsThoughEffectType; -import mage.constants.CardType; -import mage.constants.EffectType; -import mage.constants.EnterEventType; -import mage.constants.Rarity; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.Counter; import mage.counters.CounterType; import mage.counters.Counters; @@ -71,6 +55,8 @@ import mage.players.Player; import mage.util.GameLog; import mage.util.ThreadLocalStringBuilder; +import java.util.*; + /** * @author BetaSteward_at_googlemail.com */ @@ -1216,7 +1202,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { @Override public boolean clearImprinted(Game game) { - this.connectedCards.put("imprint", new ArrayList()); + this.connectedCards.put("imprint", new ArrayList<>()); return true; } diff --git a/Mage/src/main/java/mage/game/tournament/TournamentImpl.java b/Mage/src/main/java/mage/game/tournament/TournamentImpl.java index 3c48e1611b..bae294f7c3 100644 --- a/Mage/src/main/java/mage/game/tournament/TournamentImpl.java +++ b/Mage/src/main/java/mage/game/tournament/TournamentImpl.java @@ -27,38 +27,23 @@ */ package mage.game.tournament; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -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.concurrent.CopyOnWriteArrayList; import mage.cards.ExpansionSet; import mage.cards.decks.Deck; import mage.constants.TournamentPlayerState; import mage.game.draft.Draft; import mage.game.draft.DraftCube; -import mage.game.events.Listener; -import mage.game.events.PlayerQueryEvent; -import mage.game.events.PlayerQueryEventSource; -import mage.game.events.TableEvent; +import mage.game.events.*; import mage.game.events.TableEvent.EventType; -import mage.game.events.TableEventSource; import mage.game.match.Match; import mage.game.match.MatchPlayer; -import mage.game.result.ResultProtos.MatchPlayerProto; -import mage.game.result.ResultProtos.MatchProto; -import mage.game.result.ResultProtos.MatchQuitStatus; -import mage.game.result.ResultProtos.TourneyProto; -import mage.game.result.ResultProtos.TourneyRoundProto; +import mage.game.result.ResultProtos.*; import mage.players.Player; import mage.util.RandomUtil; import org.apache.log4j.Logger; +import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; + /** * * @author BetaSteward_at_googlemail.com @@ -404,12 +389,7 @@ public abstract class TournamentImpl implements Tournament { player.setConstructing(); new Thread( - new Runnable() { - @Override - public void run() { - player.getPlayer().construct(TournamentImpl.this, player.getDeck()); - } - } + () -> player.getPlayer().construct(TournamentImpl.this, player.getDeck()) ).start(); } // add autosubmit trigger diff --git a/Mage/src/main/java/mage/game/tournament/pairing/RoundPairings.java b/Mage/src/main/java/mage/game/tournament/pairing/RoundPairings.java index b6c77874e1..315a5536b2 100644 --- a/Mage/src/main/java/mage/game/tournament/pairing/RoundPairings.java +++ b/Mage/src/main/java/mage/game/tournament/pairing/RoundPairings.java @@ -41,7 +41,7 @@ import java.util.List; public class RoundPairings { public RoundPairings() { - this(new ArrayList(), new ArrayList()); + this(new ArrayList<>(), new ArrayList<>()); } public RoundPairings(List pairings, List playerByes) { diff --git a/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingMinimalWeightMatching.java b/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingMinimalWeightMatching.java index 36f3e74bc5..8693def0da 100644 --- a/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingMinimalWeightMatching.java +++ b/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingMinimalWeightMatching.java @@ -60,7 +60,7 @@ public class SwissPairingMinimalWeightMatching { public SwissPairingMinimalWeightMatching(List players, List rounds, boolean isLastRound) { playersCount = players.size(); - swissPlayers = new ArrayList(); + swissPlayers = new ArrayList<>(); for (TournamentPlayer tournamentPlayer : players) { PlayerInfo swissPlayer = new PlayerInfo(); swissPlayer.tournamentPlayer = tournamentPlayer; @@ -98,15 +98,12 @@ public class SwissPairingMinimalWeightMatching { } // sort by points and then by sos points - Collections.sort(swissPlayers, new Comparator() { - @Override - public int compare(PlayerInfo p1, PlayerInfo p2) { - int result = p2.points - p1.points; - if (result != 0) { - return result; - } - return p2.sosPoints - p1.sosPoints; + swissPlayers.sort((p1, p2) -> { + int result = p2.points - p1.points; + if (result != 0) { + return result; } + return p2.sosPoints - p1.sosPoints; }); // order could be changed, update ids and mapping diff --git a/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingSimple.java b/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingSimple.java index 249fa0b116..494178bfd7 100644 --- a/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingSimple.java +++ b/Mage/src/main/java/mage/game/tournament/pairing/SwissPairingSimple.java @@ -33,8 +33,6 @@ import mage.game.tournament.TournamentPairing; import mage.game.tournament.TournamentPlayer; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; /** @@ -59,13 +57,7 @@ public class SwissPairingSimple { List playerByes = new ArrayList<>(); // sort players by tournament points - Collections.sort(players, new Comparator() { - @Override - public int compare(TournamentPlayer p1, TournamentPlayer p2) { - return p2.getPoints() - p1.getPoints(); - } - - }); + players.sort((p1, p2) -> p2.getPoints() - p1.getPoints()); // create pairings while (!players.isEmpty()) { TournamentPlayer player1 = players.get(0); diff --git a/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java index 0e097f16cb..db301a7055 100644 --- a/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java @@ -1,14 +1,11 @@ package mage.target.targetpointer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import mage.abilities.Ability; import mage.cards.Card; import mage.game.Game; +import java.util.*; + public class SecondTargetPointer implements TargetPointer { private Map zoneChangeCounter = new HashMap<>(); @@ -21,7 +18,7 @@ public class SecondTargetPointer implements TargetPointer { } public SecondTargetPointer(SecondTargetPointer firstTargetPointer) { - this.zoneChangeCounter = new HashMap(); + this.zoneChangeCounter = new HashMap<>(); for (Map.Entry entry : firstTargetPointer.zoneChangeCounter.entrySet()) { this.zoneChangeCounter.put(entry.getKey(), entry.getValue()); }