From f99cd21275ba0adb4e0f3fa43b8eedcc76d55725 Mon Sep 17 00:00:00 2001 From: vraskulin Date: Thu, 9 Feb 2017 18:30:31 +0300 Subject: [PATCH] Mostly code format fixes. --- .../src/main/java/mage/client/MageFrame.java | 2 +- .../java/mage/client/cards/DragCardGrid.java | 6 +- .../java/mage/client/chat/ChatPanelBasic.java | 4 +- .../mage/client/components/KeyBindButton.java | 4 +- .../components/ext/dlg/DialogManager.java | 8 +- .../components/ext/dlg/impl/ChoiceDialog.java | 3 +- .../client/deckeditor/DeckEditorPanel.java | 2 +- .../client/dialog/NewTournamentDialog.java | 5 +- .../mage/client/game/BattlefieldPanel.java | 3 +- .../main/java/mage/client/game/GamePanel.java | 6 +- .../java/mage/client/util/ButtonColumn.java | 2 +- .../mage/client/util/audio/AudioManager.java | 60 ++--- .../java/org/mage/card/arcane/CardPanel.java | 6 +- .../org/mage/card/arcane/CardRenderer.java | 2 +- .../mage/card/arcane/ModernCardRenderer.java | 6 +- .../mage/card/arcane/TextboxLoyaltyRule.java | 2 +- .../mage/card/arcane/TextboxRuleParser.java | 4 +- .../org/mage/plugins/card/dl/DownloadGui.java | 8 +- .../org/mage/plugins/card/dl/DownloadJob.java | 6 +- .../org/mage/plugins/card/dl/Downloader.java | 2 +- .../card/dl/sources/GathererSymbols.java | 2 +- .../plugins/card/images/DownloadPictures.java | 2 +- .../mage/plugins/theme/ThemePluginImpl.java | 4 +- .../main/java/mage/server/ChatManager.java | 1 - .../main/java/mage/server/ChatSession.java | 2 +- .../main/java/mage/server/MageServerImpl.java | 226 +++++++++++------- .../src/main/java/mage/server/Session.java | 2 +- .../java/mage/server/TableController.java | 15 +- .../main/java/mage/server/UserManager.java | 2 +- .../server/challenge/ChallengeManager.java | 2 +- .../java/mage/server/draft/CubeFactory.java | 2 +- .../mage/server/draft/DraftController.java | 3 +- .../java/mage/server/game/GameController.java | 3 +- .../mage/server/game/GameSessionPlayer.java | 1 - .../tournament/TournamentController.java | 3 +- .../server/tournament/TournamentFactory.java | 2 +- .../mage/server/util/ServerMessagesUtil.java | 2 +- 37 files changed, 226 insertions(+), 189 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 67167a7582..79a7037063 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -1443,7 +1443,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { ((MagePane) component).changeGUISize(); } } - for (ChatPanelBasic chatPanel : getChatPanels().values()) { + for (ChatPanelBasic chatPanel : CHATS.values()) { chatPanel.changeGUISize(GUISizeHelper.chatFont); } try { diff --git a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java index 83dd8bc9da..f1a332f427 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java @@ -1718,8 +1718,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg private void updateCounts() { deckNameAndCountLabel.setText(role.getName() + " - " + allCards.size()); - creatureCountLabel.setText("" + creatureCounter.get()); - landCountLabel.setText("" + landCounter.get()); + creatureCountLabel.setText(String.valueOf(creatureCounter.get())); + landCountLabel.setText(String.valueOf(landCounter.get())); for (CardType cardType : selectByTypeButtons.keySet()) { AbstractButton button = selectByTypeButtons.get(cardType); String text = cardType.toString(); @@ -2058,7 +2058,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg if (stack.isEmpty()) { countLabel.setVisible(false); } else { - countLabel.setText("" + stack.size()); + countLabel.setText(String.valueOf(stack.size())); countLabel.setLocation(GRID_PADDING + (cardWidth + GRID_PADDING) * colIndex, currentY - COUNT_LABEL_HEIGHT); countLabel.setSize(cardWidth, COUNT_LABEL_HEIGHT); countLabel.setVisible(true); diff --git a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java index c370581d9a..1fa3ee5e80 100644 --- a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java +++ b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java @@ -195,7 +195,7 @@ public class ChatPanelBasic extends javax.swing.JPanel { if (level.equals("0")) { return false; } - message = "." + message + "."; + message = '.' + message + '.'; message = message.toLowerCase(); message = message.replaceAll("[a@]([s5][s5]+)", "axyx"); @@ -217,7 +217,7 @@ public class ChatPanelBasic extends javax.swing.JPanel { if (level.equals("2")) { message = message.replaceAll("\\.", ""); - message = "." + message + "."; + message = '.' + message + '.'; matchPattern = profanity2Pattern.matcher(message); if (matchPattern.find()) { return true; diff --git a/Mage.Client/src/main/java/mage/client/components/KeyBindButton.java b/Mage.Client/src/main/java/mage/client/components/KeyBindButton.java index ea16158ad1..be63bbacbe 100644 --- a/Mage.Client/src/main/java/mage/client/components/KeyBindButton.java +++ b/Mage.Client/src/main/java/mage/client/components/KeyBindButton.java @@ -45,7 +45,9 @@ public class KeyBindButton extends JButton implements ActionListener { private void applyNewKeycode(int code) { preferences.getKeybindButtons().stream() .filter(b -> b != KeyBindButton.this) - .filter(b -> b.getKeyCode() == code) + .filter(b -> { + return b.keyCode == code; + }) .forEach(b -> b.setKeyCode(0)); setKeyCode(code); diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java index 2eeafeddb4..2f7f69998e 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogManager.java @@ -27,8 +27,8 @@ public class DialogManager extends JComponent implements MouseListener, synchronized (dialogManagers) { if (!dialogManagers.containsKey(gameId)) { DialogManager dialogManager = new DialogManager(); - dialogManager.setScreenWidth(768); - dialogManager.setScreenHeight(1024); + dialogManager.screen_width = 768; + dialogManager.screen_height = 1024; dialogManager.setBounds(0, 0, 768, 1024); dialogManager.setVisible(false); dialogManagers.put(gameId, dialogManager); @@ -96,8 +96,8 @@ public class DialogManager extends JComponent implements MouseListener, public static void updateParams(int width, int height, boolean isVisible) { synchronized (dialogManagers) { for (DialogManager dialogManager : dialogManagers.values()) { - dialogManager.setScreenWidth(width); - dialogManager.setScreenHeight(height); + dialogManager.screen_width = width; + dialogManager.screen_height = height; dialogManager.setBounds(0, 0, width, height); } } 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 9294a12a07..d298cc4cc2 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 @@ -141,8 +141,7 @@ public class ChoiceDialog extends IDialogPanel { remove(toRemove.get(i)); } - java.util.List cardList = new ArrayList(); - cardList.addAll(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/DeckEditorPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java index cb11486d6e..b055778607 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java @@ -346,7 +346,7 @@ public class DeckEditorPanel extends javax.swing.JPanel { if (card.getId().equals(cardView.getId())) { deck.getCards().remove(card); deck.getSideboard().add(card); - cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), getBigCard()); + cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), this.bigCard); break; } } diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java index bc7584eed9..7807ba1e51 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java @@ -537,7 +537,7 @@ public class NewTournamentDialog extends MageDialog { tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom()); if (tournamentType.isCubeBooster()) { tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString()); - if (!(cubeFromDeckFilename.equals(""))) { + if (!(cubeFromDeckFilename.isEmpty())) { Deck cubeFromDeck = new Deck(); try { cubeFromDeck = Deck.load(DeckImporterUtil.importDeck(cubeFromDeckFilename), true, true); @@ -828,8 +828,7 @@ public class NewTournamentDialog extends MageDialog { String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, ""); if (!randomPrefs.isEmpty()) { txtRandomPacks.setText(randomPrefs); - ArrayList theList = new ArrayList<>(); - theList.addAll(Arrays.asList(randomPrefs.split(";"))); + ArrayList theList = new ArrayList<>(Arrays.asList(randomPrefs.split(";"))); randomPackSelector.setSelectedPacks(theList); } else { ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate(); diff --git a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java index da32bb08cb..b5a90c9da6 100644 --- a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java @@ -162,8 +162,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { if (s1 != s2) { changed = true; } else if (s1 > 0) { - Set attachmentIds = new HashSet<>(); - attachmentIds.addAll(permanent.getAttachments()); + Set attachmentIds = new HashSet<>(permanent.getAttachments()); for (MagePermanent magePermanent : oldMagePermanent.getLinks()) { if (!attachmentIds.contains(magePermanent.getOriginalPermanent().getId())) { // that means that the amount of attachments is the same diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index 85435f2fe3..7604e43c97 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -533,7 +533,7 @@ public final class GamePanel extends javax.swing.JPanel { if (!SessionHandler.watchGame(gameId)) { removeGame(); } - for (PlayAreaPanel panel : getPlayers().values()) { + for (PlayAreaPanel panel : players.values()) { panel.setPlayingMode(false); } } @@ -553,7 +553,7 @@ public final class GamePanel extends javax.swing.JPanel { if (!SessionHandler.startReplay(gameId)) { removeGame(); } - for (PlayAreaPanel panel : getPlayers().values()) { + for (PlayAreaPanel panel : players.values()) { panel.setPlayingMode(false); } } @@ -815,7 +815,7 @@ public final class GamePanel extends javax.swing.JPanel { logger.warn(" uuid:" + player.getPlayerId()); logger.warn(" players:"); for (PlayAreaPanel p : players.values()) { - logger.warn("" + p); + logger.warn(String.valueOf(p)); } } } diff --git a/Mage.Client/src/main/java/mage/client/util/ButtonColumn.java b/Mage.Client/src/main/java/mage/client/util/ButtonColumn.java index 7003a4ee6d..7ba39b2695 100644 --- a/Mage.Client/src/main/java/mage/client/util/ButtonColumn.java +++ b/Mage.Client/src/main/java/mage/client/util/ButtonColumn.java @@ -114,7 +114,7 @@ public class ButtonColumn extends AbstractCellEditor implements TableCellRendere if (table.getRowCount() > 0 && table.getRowCount() >= table.getEditingRow() && table.getEditingRow() >= 0) { int row = table.convertRowIndexToModel(table.getEditingRow()); fireEditingStopped(); - ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row); + ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, String.valueOf(row)); action.actionPerformed(event); } } diff --git a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java index 5273a53eca..cefdab11aa 100644 --- a/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java +++ b/Mage.Client/src/main/java/mage/client/util/audio/AudioManager.java @@ -68,70 +68,70 @@ public class AudioManager { if (audioManager.nextPageClip == null) { audioManager.nextPageClip = new MageClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().nextPageClip); + checkAndPlayClip(audioManager.nextPageClip); } public static void playPrevPage() { if (audioManager.prevPageClip == null) { audioManager.prevPageClip = new MageClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().prevPageClip); + checkAndPlayClip(audioManager.prevPageClip); } public static void playAnotherTab() { if (audioManager.anotherTabClip == null) { audioManager.anotherTabClip = new MageClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().anotherTabClip); + checkAndPlayClip(audioManager.anotherTabClip); } public static void playNextPhase() { if (audioManager.nextPhaseClip == null) { audioManager.nextPhaseClip = new MageClip(Constants.BASE_SOUND_PATH + "OnNextPhase.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().nextPhaseClip); + checkAndPlayClip(audioManager.nextPhaseClip); } public static void playEndTurn() { if (audioManager.endTurnClip == null) { audioManager.endTurnClip = new MageClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().endTurnClip); + checkAndPlayClip(audioManager.endTurnClip); } public static void playTapPermanent() { if (audioManager.tapPermanentClip == null) { audioManager.tapPermanentClip = new MageClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().tapPermanentClip); + checkAndPlayClip(audioManager.tapPermanentClip); } public static void playSummon() { if (audioManager.summonClip == null) { audioManager.summonClip = new MageClip(Constants.BASE_SOUND_PATH + "OnSummon.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().summonClip); + checkAndPlayClip(audioManager.summonClip); } public static void playDiedCreature() { if (audioManager.diedCreatureClip == null) { audioManager.diedCreatureClip = new MageClip(Constants.BASE_SOUND_PATH + "OnSummon-.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().diedCreatureClip); + checkAndPlayClip(audioManager.diedCreatureClip); } public static void playDraw() { if (audioManager.drawClip == null) { audioManager.drawClip = new MageClip(Constants.BASE_SOUND_PATH + "OnDraw.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().drawClip); + checkAndPlayClip(audioManager.drawClip); } public static void playButtonOk() { if (audioManager.buttonOkClip == null) { audioManager.buttonOkClip = new MageClip(Constants.BASE_SOUND_PATH + "OnButtonOk.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().buttonOkClip); + checkAndPlayClip(audioManager.buttonOkClip); } public static void playButtonCancel() { @@ -139,105 +139,105 @@ public class AudioManager { audioManager.buttonCancelClip = new MageClip(Constants.BASE_SOUND_PATH + "OnButtonCancel.wav", AudioGroup.SkipSounds); } - checkAndPlayClip(getManager().buttonCancelClip); + checkAndPlayClip(audioManager.buttonCancelClip); } public static void playAttack() { if (audioManager.attackClip == null) { audioManager.attackClip = new MageClip(Constants.BASE_SOUND_PATH + "OnAttack.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().attackClip); + checkAndPlayClip(audioManager.attackClip); } public static void playBlock() { if (audioManager.blockClip == null) { audioManager.blockClip = new MageClip(Constants.BASE_SOUND_PATH + "OnBlock.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().blockClip); + checkAndPlayClip(audioManager.blockClip); } public static void playAddPermanent() { if (audioManager.addPermanentClip == null) { audioManager.addPermanentClip = new MageClip(Constants.BASE_SOUND_PATH + "OnAddPermanent.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().addPermanentClip); + checkAndPlayClip(audioManager.addPermanentClip); } public static void playAddArtifact() { if (audioManager.addArtifactClip == null) { audioManager.addArtifactClip = new MageClip(Constants.BASE_SOUND_PATH + "OnAddArtifact.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().addArtifactClip); + checkAndPlayClip(audioManager.addArtifactClip); } public static void playStackNew() { if (audioManager.updateStackClip == null) { audioManager.updateStackClip = new MageClip(Constants.BASE_SOUND_PATH + "OnStackNew.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().updateStackClip); + checkAndPlayClip(audioManager.updateStackClip); } public static void playOnHover() { if (audioManager.onHover == null) { audioManager.onHover = new MageClip(Constants.BASE_SOUND_PATH + "OnHover.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().onHover); + checkAndPlayClip(audioManager.onHover); } public static void playOnCountdown1() { if (audioManager.onCountdown1 == null) { audioManager.onCountdown1 = new MageClip(Constants.BASE_SOUND_PATH + "OnCountdown1.wav", AudioGroup.DraftSounds); } - checkAndPlayClip(getManager().onCountdown1); + checkAndPlayClip(audioManager.onCountdown1); } public static void playOnDraftSelect() { if (audioManager.onDraftSelect == null) { audioManager.onDraftSelect = new MageClip(Constants.BASE_SOUND_PATH + "OnDraftSelect.wav", AudioGroup.DraftSounds); } - checkAndPlayClip(getManager().onDraftSelect); + checkAndPlayClip(audioManager.onDraftSelect); } public static void playOnSkipButton() { if (audioManager.onSkipButton == null) { audioManager.onSkipButton = new MageClip(Constants.BASE_SOUND_PATH + "OnSkipButton.wav", AudioGroup.SkipSounds); } - checkAndPlayClip(getManager().onSkipButton); + checkAndPlayClip(audioManager.onSkipButton); } public static void playOnSkipButtonCancel() { if (audioManager.onSkipButtonCancel == null) { audioManager.onSkipButtonCancel = new MageClip(Constants.BASE_SOUND_PATH + "OnSkipButtonCancel.wav", AudioGroup.SkipSounds); } - checkAndPlayClip(getManager().onSkipButtonCancel); + checkAndPlayClip(audioManager.onSkipButtonCancel); } public static void playPlayerJoinedTable() { if (audioManager.playerJoinedTable == null) { audioManager.playerJoinedTable = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerJoined.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().playerJoinedTable); + checkAndPlayClip(audioManager.playerJoinedTable); } public static void playYourGameStarted() { if (audioManager.yourGameStarted == null) { audioManager.yourGameStarted = new MageClip(Constants.BASE_SOUND_PATH + "OnGameStart.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().yourGameStarted); + checkAndPlayClip(audioManager.yourGameStarted); } public static void playTournamentStarted() { if (audioManager.tournamentStarted == null) { audioManager.tournamentStarted = new MageClip(Constants.BASE_SOUND_PATH + "OnTournamentStart.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().tournamentStarted); + checkAndPlayClip(audioManager.tournamentStarted); } public static void playPlayerWhispered() { if (audioManager.playerWhispered == null) { audioManager.playerWhispered = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerWhispered.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().playerWhispered); + checkAndPlayClip(audioManager.playerWhispered); } public static void playPlayerSubmittedDeck() { @@ -245,14 +245,14 @@ public class AudioManager { audioManager.playerSubmittedDeck = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerSubmittedDeck.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().playerSubmittedDeck); + checkAndPlayClip(audioManager.playerSubmittedDeck); } public static void playPlayerLeft() { if (audioManager.playerLeft == null) { audioManager.playerLeft = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerLeft.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().playerLeft); + checkAndPlayClip(audioManager.playerLeft); } public static void playPlayerQuitTournament() { @@ -260,21 +260,21 @@ public class AudioManager { audioManager.playerQuitTournament = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerQuitTournament.wav", AudioGroup.OtherSounds); } - checkAndPlayClip(getManager().playerQuitTournament); + checkAndPlayClip(audioManager.playerQuitTournament); } public static void playPlayerLost() { if (audioManager.playerLost == null) { audioManager.playerLost = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerLost.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().playerLost); + checkAndPlayClip(audioManager.playerLost); } public static void playPlayerWon() { if (audioManager.playerWon == null) { audioManager.playerWon = new MageClip(Constants.BASE_SOUND_PATH + "OnPlayerWon.wav", AudioGroup.GameSounds); } - checkAndPlayClip(getManager().playerWon); + checkAndPlayClip(audioManager.playerWon); } private static boolean audioGroupEnabled(AudioGroup audioGroup) { diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index f55acc778c..0483922aa1 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -574,12 +574,12 @@ public abstract class CardPanel extends MagePermanent implements MouseListener, int cx = getCardX() - component.x; int cy = getCardY() - component.y; - int cw = getCardWidth(); - int ch = getCardHeight(); + int cw = cardWidth; + int ch = cardHeight; if (isTapped()) { cy = ch - cw + cx; ch = cw; - cw = getCardHeight(); + cw = cardHeight; } return x >= cx && x <= cx + cw && y >= cy && y <= cy + ch; diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardRenderer.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardRenderer.java index fa568e13b7..f5e59fe6cf 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardRenderer.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardRenderer.java @@ -290,7 +290,7 @@ public abstract class CardRenderer { g2.setColor(Color.black); g2.drawPolygon(p); g2.setFont(new Font("Arial", Font.BOLD, 7)); - String cstr = "" + v.getCount(); + String cstr = String.valueOf(v.getCount()); int strW = g2.getFontMetrics().stringWidth(cstr); g2.drawString(cstr, 5 - strW / 2, 8); g2.dispose(); 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 b727c29d44..367984774b 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 @@ -707,7 +707,7 @@ public class ModernCardRenderer extends CardRenderer { if ((cardView instanceof PermanentView) && ((PermanentView) cardView).getDamage() > 0) { int x = cardWidth - partWidth - borderWidth; int y = curY - boxHeight; - String damage = "" + ((PermanentView) cardView).getDamage(); + String damage = String.valueOf(((PermanentView) cardView).getDamage()); g.setFont(ptTextFont); int txWidth = g.getFontMetrics().stringWidth(damage); g.setColor(Color.red); @@ -986,7 +986,7 @@ public class ModernCardRenderer extends CardRenderer { g.setColor(Color.black); g.fillOval(borderWidth + 1, totalContentInset + 1, boxHeight - 2, boxHeight - 2); g.setColor(Color.white); - if (isNightCard()) { + if (isTransformed) { g.fillArc(borderWidth + 3, totalContentInset + 3, boxHeight - 6, boxHeight - 6, 90, 270); g.setColor(Color.black); g.fillArc(borderWidth + 3 + 3, totalContentInset + 3, boxHeight - 6 - 3, boxHeight - 6, 90, 270); @@ -1012,7 +1012,7 @@ public class ModernCardRenderer extends CardRenderer { // Determine the color of the name / type line text protected Color getBoxTextColor() { - if (isNightCard()) { + if (isTransformed) { return Color.white; } else if (cardView.isAbility()) { return Color.white; diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxLoyaltyRule.java b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxLoyaltyRule.java index d7b599e2b4..b3d3f975c1 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxLoyaltyRule.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxLoyaltyRule.java @@ -22,7 +22,7 @@ public class TextboxLoyaltyRule extends TextboxRule { } else if (loyaltyChange > 0) { return "+" + loyaltyChange; } else { - return "" + loyaltyChange; + return String.valueOf(loyaltyChange); } } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java index 4c380281a7..ad040a594e 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java @@ -186,10 +186,10 @@ public class TextboxRuleParser { if (levelMatch.find()) { try { levelFrom = Integer.parseInt(levelMatch.group(1)); - if (!levelMatch.group(2).equals("")) { + if (!levelMatch.group(2).isEmpty()) { levelTo = Integer.parseInt(levelMatch.group(2)); } - if (!levelMatch.group(3).equals("")) { + if (!levelMatch.group(3).isEmpty()) { levelTo = TextboxLevelRule.AND_HIGHER; } isLeveler = true; diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadGui.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadGui.java index b847d94127..a8438a706a 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadGui.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadGui.java @@ -53,7 +53,9 @@ public class DownloadGui extends JPanel { p.setBorder(BorderFactory.createTitledBorder("Progress:")); p.add(progress); JButton b = new JButton("X"); - b.addActionListener(e -> getDownloader().dispose()); + b.addActionListener(e -> { + d.dispose(); + }); p.add(b, BorderLayout.EAST); add(p, BorderLayout.NORTH); @@ -154,10 +156,10 @@ public class DownloadGui extends JPanel { add(bar = new JProgressBar(job.getProgress())); JButton b = new JButton("X"); b.addActionListener(e -> { - switch(getJob().getState()) { + switch(this.job.getState()) { case NEW: case WORKING: - getJob().setState(State.ABORTED); + this.job.setState(State.ABORTED); } }); add(b, BorderLayout.EAST); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java index e82220c845..8d189b5796 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java @@ -90,7 +90,7 @@ public class DownloadJob extends AbstractLaternaBean { public void setError(String message, Exception error) { if (message == null) { - message = "Download of " + this.getName() + "from " + this.getSource().toString() + " caused error: " + error.toString(); + message = "Download of " + name + "from " + source.toString() + " caused error: " + error.toString(); } // log.warn(message, error); log.warn(message); @@ -167,7 +167,7 @@ public class DownloadJob extends AbstractLaternaBean { @Override public String toString() { - return proxy != null ? proxy.type().toString() + ' ' : "" + url; + return proxy != null ? proxy.type().toString() + ' ' : url; } }; @@ -196,7 +196,7 @@ public class DownloadJob extends AbstractLaternaBean { @Override public String toString() { - return proxy != null ? proxy.type().toString() + ' ' : "" + url; + return proxy != null ? proxy.type().toString() + ' ' : String.valueOf(url); } }; } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java index 92759be7ec..4b71a8d16c 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/Downloader.java @@ -57,7 +57,7 @@ public class Downloader extends AbstractLaternaBean implements Disposable { @Override public void dispose() { - for (DownloadJob j : getJobs()) { + for (DownloadJob j : jobs) { switch (j.getState()) { case NEW: case WORKING: diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSymbols.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSymbols.java index 2beb29d6ac..995b182e5b 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSymbols.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSymbols.java @@ -59,7 +59,7 @@ public class GathererSymbols implements Iterable { if (symIndex < symbols.length) { sym = symbols[symIndex++]; } else if (numeric <= maxNumeric) { - sym = "" + (numeric++); + sym = String.valueOf(numeric++); } else { sizeIndex++; if (sizeIndex == sizes.length) { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java index 7db13b2326..4510e7df0e 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPictures.java @@ -71,7 +71,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab JDialog dlg = download.getDlg(frame); dlg.setVisible(true); dlg.dispose(); - download.setCancel(true); + download.cancel = true; } public JDialog getDlg(JFrame frame) { diff --git a/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java b/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java index f6587272d9..f51fe8b54f 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java @@ -124,7 +124,7 @@ public class ThemePluginImpl implements ThemePlugin { private BufferedImage loadbuffer_selected() throws IOException { BufferedImage res; String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, ""); - if (path != null && !path.equals("")) { + if (path != null && !path.isEmpty()) { try { res = ImageIO.read(new File(path)); return res; @@ -162,7 +162,7 @@ public class ThemePluginImpl implements ThemePlugin { background = ImageIO.read(is); } else { String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, ""); - if (path != null && !path.equals("")) { + if (path != null && !path.isEmpty()) { try { File f = new File(path); if (f != null) { diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java index 2541720012..ec7fe0dcfd 100644 --- a/Mage.Server/src/main/java/mage/server/ChatManager.java +++ b/Mage.Server/src/main/java/mage/server/ChatManager.java @@ -245,7 +245,6 @@ public class ChatManager { */ public void broadcast(UUID userId, String message, MessageColor color) throws UserNotFoundException { UserManager.getInstance().getUser(userId).ifPresent(user-> { - chatSessions.values() .stream() .filter(chat -> chat.hasUser(userId)) diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java index 0f97c01ca6..5f84426857 100644 --- a/Mage.Server/src/main/java/mage/server/ChatSession.java +++ b/Mage.Server/src/main/java/mage/server/ChatSession.java @@ -49,7 +49,7 @@ import java.util.concurrent.ConcurrentHashMap; public class ChatSession { private static final Logger logger = Logger.getLogger(ChatSession.class); - private static final DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT); + private static final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT); private final ConcurrentHashMap clients = new ConcurrentHashMap<>(); private final UUID chatId; diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index 1392b92ee5..842e85376b 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -202,38 +202,7 @@ public class MageServerImpl implements MageServer { @Override public TableView createTable(final String sessionId, final UUID roomId, final MatchOptions options) throws MageException { - return executeWithResult("createTable", sessionId, new ActionWithTableViewResult() { - @Override - public TableView execute() throws MageException { - UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); - Optional _user = UserManager.getInstance().getUser(userId); - if (!_user.isPresent()) { - logger.error("User for session not found. session = " + sessionId); - return null; - } - User user = _user.get(); - // check if user can create another table - int notStartedTables = user.getNumberOfNotStartedTables(); - if (notStartedTables > 1) { - user.showUserMessage("Create table", "You have already " + notStartedTables + " not started table" + (notStartedTables == 1 ? "" : "s") + ". You can't create another."); - throw new MageException("No message"); - } - // check if the user itself satisfies the quitRatio requirement. - int quitRatio = options.getQuitRatio(); - if (quitRatio < user.getMatchQuitRatio()) { - user.showUserMessage("Create table", "Your quit ratio " + user.getMatchQuitRatio() + "% is higher than the table requirement " + quitRatio + '%'); - throw new MageException("No message"); - } - - TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(userId, options); - if (logger.isDebugEnabled()) { - logger.debug("TABLE created - tableId: " + table.getTableId() + ' ' + table.getTableName()); - logger.debug("- " + user.getName() + " userId: " + user.getId()); - logger.debug("- chatId: " + TableManager.getInstance().getChatId(table.getTableId())); - } - return table; - } - }); + return executeWithResult("createTable", sessionId, new MyActionWithTableViewResult(sessionId, options, roomId)); } @Override @@ -322,9 +291,7 @@ public class MageServerImpl implements MageServer { UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); if (logger.isTraceEnabled()) { Optional user = UserManager.getInstance().getUser(userId); - if (user.isPresent()) { - logger.trace("join tourn. tableId: " + tableId + ' ' + name); - } + user.ifPresent(user1 -> logger.trace("join tourn. tableId: " + tableId + ' ' + name)); } if (userId == null) { logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId); @@ -688,18 +655,7 @@ public class MageServerImpl implements MageServer { @Override public DraftPickView sendCardPick(final UUID draftId, final String sessionId, final UUID cardPick, final Set hiddenCards) throws MageException { - return executeWithResult("sendCardPick", sessionId, new ActionWithNullNegativeResult() { - @Override - public DraftPickView execute() { - Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) { - return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards); - } else { - logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId); - } - return null; - } - }); + return executeWithResult("sendCardPick", sessionId, new DraftPickViewActionWithNullNegativeResult(sessionId, draftId, cardPick, hiddenCards)); } @Override @@ -780,13 +736,7 @@ public class MageServerImpl implements MageServer { @Override public boolean watchTournamentTable(final String sessionId, final UUID tableId) throws MageException { - return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() { - @Override - public Boolean execute() throws MageException { - UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); - return TableManager.getInstance().watchTable(userId, tableId); - } - }); + return executeWithResult("setUserData", sessionId, new MyActionWithBooleanResult(sessionId, tableId)); } @Override @@ -911,13 +861,7 @@ public class MageServerImpl implements MageServer { @Override public GameView getGameView(final UUID gameId, final String sessionId, final UUID playerId) throws MageException { - return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult() { - @Override - public GameView execute() throws MageException { - UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); - return GameManager.getInstance().getGameView(gameId, userId, playerId); - } - }); + return executeWithResult("getGameView", sessionId, new GameViewActionWithNullNegativeResult(sessionId, gameId, playerId)); } /** @@ -929,27 +873,7 @@ public class MageServerImpl implements MageServer { */ @Override public List getUsers(String sessionId) throws MageException { - return executeWithResult("getUsers", sessionId, new ActionWithNullNegativeResult>() { - @Override - public List execute() throws MageException { - List users = new ArrayList<>(); - for (User user : UserManager.getInstance().getUsers()) { - users.add(new UserView( - user.getName(), - user.getHost(), - user.getSessionId(), - user.getConnectionTime(), - user.getGameInfo(), - user.getUserState().toString(), - user.getChatLockedUntil(), - user.getClientVersion(), - user.getEmail(), - user.getUserIdStr() - )); - } - return users; - } - }, true); + return executeWithResult("getUsers", sessionId, new ListActionWithNullNegativeResult(), true); } @Override @@ -1040,12 +964,7 @@ public class MageServerImpl implements MageServer { @Override public Object getServerMessagesCompressed(String sessionId) throws MageException { - return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult() { - @Override - public Object execute() throws MageException { - return CompressUtil.compress(ServerMessagesUtil.getInstance().getMessages()); - } - }); + return executeWithResult("getGameView", sessionId, new MyActionWithNullNegativeResult()); } @Override @@ -1142,4 +1061,135 @@ public class MageServerImpl implements MageServer { public List getMissingCardsData(List classNames) { return CardRepository.instance.getMissingCards(classNames); } + + private static class MyActionWithNullNegativeResult extends ActionWithNullNegativeResult { + @Override + public Object execute() throws MageException { + return CompressUtil.compress(ServerMessagesUtil.getInstance().getMessages()); + } + } + + private static class ListActionWithNullNegativeResult extends ActionWithNullNegativeResult> { + @Override + public List execute() throws MageException { + List users = new ArrayList<>(); + for (User user : UserManager.getInstance().getUsers()) { + users.add(new UserView( + user.getName(), + user.getHost(), + user.getSessionId(), + user.getConnectionTime(), + user.getGameInfo(), + user.getUserState().toString(), + user.getChatLockedUntil(), + user.getClientVersion(), + user.getEmail(), + user.getUserIdStr() + )); + } + return users; + } + } + + private static class GameViewActionWithNullNegativeResult extends ActionWithNullNegativeResult { + private final String sessionId; + private final UUID gameId; + private final UUID playerId; + + public GameViewActionWithNullNegativeResult(String sessionId, UUID gameId, UUID playerId) { + this.sessionId = sessionId; + this.gameId = gameId; + this.playerId = playerId; + } + + @Override + public GameView execute() throws MageException { + UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); + return GameManager.getInstance().getGameView(gameId, userId, playerId); + } + } + + private static class MyActionWithBooleanResult extends ActionWithBooleanResult { + private final String sessionId; + private final UUID tableId; + + public MyActionWithBooleanResult(String sessionId, UUID tableId) { + this.sessionId = sessionId; + this.tableId = tableId; + } + + @Override + public Boolean execute() throws MageException { + UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); + return TableManager.getInstance().watchTable(userId, tableId); + } + } + + private static class DraftPickViewActionWithNullNegativeResult extends ActionWithNullNegativeResult { + private final String sessionId; + private final UUID draftId; + private final UUID cardPick; + private final Set hiddenCards; + + public DraftPickViewActionWithNullNegativeResult(String sessionId, UUID draftId, UUID cardPick, Set hiddenCards) { + this.sessionId = sessionId; + this.draftId = draftId; + this.cardPick = cardPick; + this.hiddenCards = hiddenCards; + } + + @Override + public DraftPickView execute() { + Session session = SessionManager.getInstance().getSession(sessionId); + if (session != null) { + return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards); + } else { + logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId); + } + return null; + } + } + + private static class MyActionWithTableViewResult extends ActionWithTableViewResult { + private final String sessionId; + private final MatchOptions options; + private final UUID roomId; + + public MyActionWithTableViewResult(String sessionId, MatchOptions options, UUID roomId) { + this.sessionId = sessionId; + this.options = options; + this.roomId = roomId; + } + + @Override + public TableView execute() throws MageException { + UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId(); + Optional _user = UserManager.getInstance().getUser(userId); + if (!_user.isPresent()) { + logger.error("User for session not found. session = " + sessionId); + return null; + } + User user = _user.get(); + // check if user can create another table + int notStartedTables = user.getNumberOfNotStartedTables(); + if (notStartedTables > 1) { + user.showUserMessage("Create table", "You have already " + notStartedTables + " not started table" + (notStartedTables == 1 ? "" : "s") + ". You can't create another."); + throw new MageException("No message"); + } + // check if the user itself satisfies the quitRatio requirement. + int quitRatio = options.getQuitRatio(); + if (quitRatio < user.getMatchQuitRatio()) { + user.showUserMessage("Create table", "Your quit ratio " + user.getMatchQuitRatio() + "% is higher than the table requirement " + quitRatio + '%'); + throw new MageException("No message"); + } + + TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(userId, options); + if (logger.isDebugEnabled()) { + logger.debug("TABLE created - tableId: " + table.getTableId() + ' ' + table.getTableName()); + logger.debug("- " + user.getName() + " userId: " + user.getId()); + logger.debug("- chatId: " + TableManager.getInstance().getChatId(table.getTableId())); + } + return table; + } + } } diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index 55e9b5e6e9..d0b68ddf0b 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -421,7 +421,7 @@ public class Session { Throwable t = cause; while (t.getCause() != null) { t = t.getCause(); - if (t == cause) { + if (Objects.equals(t, cause)) { throw new IllegalArgumentException("Infinite cycle detected in causal chain"); } } diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index aa47c9d04a..254caa0b4e 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -95,11 +95,7 @@ public class TableController { if (userId != null) { Optional user = UserManager.getInstance().getUser(userId); // TODO: Handle if user == null - if (user.isPresent()) { - controllerName = user.get().getName(); - } else { - controllerName = "undefined"; - } + controllerName = user.map(User::getName).orElse("undefined"); } else { controllerName = "System"; } @@ -671,9 +667,7 @@ public class TableController { if (entry.getValue().equals(playerId)) { Optional user = UserManager.getInstance().getUser(entry.getKey()); int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS); - if (user.isPresent()) { - user.get().ccSideboard(deck, table.getId(), remaining, options.isLimited()); - } + user.ifPresent(user1 -> user1.ccSideboard(deck, table.getId(), remaining, options.isLimited())); break; } } @@ -811,10 +805,7 @@ public class TableController { private synchronized void setupTimeout(int seconds) { cancelTimeout(); if (seconds > 0) { - futureTimeout = timeoutExecutor.schedule( - () -> autoSideboard(), - seconds, TimeUnit.SECONDS - ); + futureTimeout = timeoutExecutor.schedule(this::autoSideboard, seconds, TimeUnit.SECONDS); } } diff --git a/Mage.Server/src/main/java/mage/server/UserManager.java b/Mage.Server/src/main/java/mage/server/UserManager.java index a1c45d113f..45252eb034 100644 --- a/Mage.Server/src/main/java/mage/server/UserManager.java +++ b/Mage.Server/src/main/java/mage/server/UserManager.java @@ -60,7 +60,7 @@ public class UserManager { } private UserManager() { - expireExecutor.scheduleAtFixedRate(() -> checkExpired(), 60, 60, TimeUnit.SECONDS); + expireExecutor.scheduleAtFixedRate(this::checkExpired, 60, 60, TimeUnit.SECONDS); } public User createUser(String userName, String host, AuthorizedUser authorizedUser) { diff --git a/Mage.Server/src/main/java/mage/server/challenge/ChallengeManager.java b/Mage.Server/src/main/java/mage/server/challenge/ChallengeManager.java index d4ecf55507..341e593cf3 100644 --- a/Mage.Server/src/main/java/mage/server/challenge/ChallengeManager.java +++ b/Mage.Server/src/main/java/mage/server/challenge/ChallengeManager.java @@ -21,7 +21,7 @@ public class ChallengeManager { } public void prepareChallenge(UUID playerId, Match match) { - Map commands = new HashMap(); + Map commands = new HashMap<>(); commands.put(Zone.OUTSIDE, "life:3"); match.getGame().cheat(playerId, commands); } diff --git a/Mage.Server/src/main/java/mage/server/draft/CubeFactory.java b/Mage.Server/src/main/java/mage/server/draft/CubeFactory.java index d38208c1c5..ad59a9b0ae 100644 --- a/Mage.Server/src/main/java/mage/server/draft/CubeFactory.java +++ b/Mage.Server/src/main/java/mage/server/draft/CubeFactory.java @@ -44,7 +44,7 @@ public class CubeFactory { private static final CubeFactory INSTANCE = new CubeFactory(); private static final Logger logger = Logger.getLogger(CubeFactory.class); - private final Map draftCubes = new LinkedHashMap(); + private final Map draftCubes = new LinkedHashMap<>(); public static CubeFactory getInstance() { return INSTANCE; diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftController.java b/Mage.Server/src/main/java/mage/server/draft/DraftController.java index a6f523279f..3b69b5b2e5 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftController.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftController.java @@ -151,8 +151,7 @@ public class DraftController { private synchronized void checkStart() { if (!draft.isStarted() && allJoined()) { draft.setStarted(); - ThreadExecutor.getInstance().getCallExecutor().execute( - () -> startDraft()); + ThreadExecutor.getInstance().getCallExecutor().execute(this::startDraft); } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 5436f1c1ee..e514e233bd 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -388,8 +388,7 @@ public class GameController implements GameCallback { private void checkStart() { if (allJoined()) { joinWaitingExecutor.shutdownNow(); - ThreadExecutor.getInstance().getCallExecutor().execute( - () -> startGame()); + ThreadExecutor.getInstance().getCallExecutor().execute(this::startGame); } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java b/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java index d2b897c6e8..ad1cd8022f 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java @@ -130,7 +130,6 @@ public class GameSessionPlayer extends GameSessionWatcher { public void getAmount(final String message, final int min, final int max) { if (!killed) { UserManager.getInstance().getUser(userId).ifPresent(user -> { - user.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max))); }); } diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java index bca997678d..c99e136e32 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java @@ -198,8 +198,7 @@ public class TournamentController { private void checkStart() { if (!started && allJoined()) { - ThreadExecutor.getInstance().getCallExecutor().execute( - () -> startTournament()); + ThreadExecutor.getInstance().getCallExecutor().execute(this::startTournament); } } diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentFactory.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentFactory.java index 3a479da566..dad91bc46b 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentFactory.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentFactory.java @@ -79,7 +79,7 @@ public class TournamentFactory { } tournament.getOptions().getLimitedOptions().setNumberBoosters(tournament.getTournamentType().getNumBoosters()); if (tournament.getTournamentType().isCubeBooster()) { - DraftCube draftCube = null; + DraftCube draftCube; if (tournament.getOptions().getLimitedOptions().getCubeFromDeck() != null) { draftCube = CubeFactory.getInstance().createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeck()); diff --git a/Mage.Server/src/main/java/mage/server/util/ServerMessagesUtil.java b/Mage.Server/src/main/java/mage/server/util/ServerMessagesUtil.java index fe2e2212b2..87ccff610e 100644 --- a/Mage.Server/src/main/java/mage/server/util/ServerMessagesUtil.java +++ b/Mage.Server/src/main/java/mage/server/util/ServerMessagesUtil.java @@ -74,7 +74,7 @@ public class ServerMessagesUtil { public ServerMessagesUtil() { updateExecutor = Executors.newSingleThreadScheduledExecutor(); - updateExecutor.scheduleAtFixedRate(() -> reloadMessages(), 5, 5 * 60, TimeUnit.SECONDS); + updateExecutor.scheduleAtFixedRate(this::reloadMessages, 5, 5 * 60, TimeUnit.SECONDS); } public static ServerMessagesUtil getInstance() {