Merge pull request #2846 from kubikrubikvkube/master

Singleton object should not have map with values that can't be GCed
This commit is contained in:
ingmargoudt 2017-02-11 20:43:32 +01:00 committed by GitHub
commit 20b24e3360
40 changed files with 289 additions and 263 deletions

View file

@ -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 {

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);
}
}

View file

@ -141,8 +141,7 @@ public class ChoiceDialog extends IDialogPanel {
remove(toRemove.get(i));
}
java.util.List<CardView> cardList = new ArrayList<CardView>();
cardList.addAll(cards.values());
java.util.List<CardView> cardList = new ArrayList<CardView>(cards.values());
int width = SettingsManager.getInstance().getCardSize().width;
int height = SettingsManager.getInstance().getCardSize().height;

View file

@ -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;
}
}

View file

@ -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<String> theList = new ArrayList<>();
theList.addAll(Arrays.asList(randomPrefs.split(";")));
ArrayList<String> theList = new ArrayList<>(Arrays.asList(randomPrefs.split(";")));
randomPackSelector.setSelectedPacks(theList);
} else {
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();

View file

@ -162,8 +162,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
if (s1 != s2) {
changed = true;
} else if (s1 > 0) {
Set<UUID> attachmentIds = new HashSet<>();
attachmentIds.addAll(permanent.getAttachments());
Set<UUID> 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

View file

@ -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));
}
}
}

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -1,5 +1,7 @@
package mage.client.util.gui;
import com.google.common.collect.MapMaker;
import javax.swing.*;
import java.awt.*;
import java.util.*;
@ -18,31 +20,25 @@ public class ArrowBuilder {
instance = new ArrowBuilder();
}
/**
* Stores arrow panels per game
*/
private final Map<UUID, JPanel> arrowPanels = new HashMap<>();
private final Map<UUID, Map<Type, List<Arrow>>> map = new MapMaker().weakKeys().weakValues().makeMap();
/**
* The top panel where arrow panels are added to.
*/
private JPanel arrowsManagerPanel;
private int currentWidth;
private int currentHeight;
public static ArrowBuilder getBuilder() {
return instance;
}
/**
* The top panel where arrow panels are added to.
*/
private JPanel arrowsManagerPanel;
/**
* Stores arrow panels per game
*/
private final Map<UUID, JPanel> arrowPanels = new HashMap<UUID, JPanel>();
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<UUID, Map<Type, java.util.List<Arrow>>>();
private int currentWidth;
private int currentHeight;
public enum Type {
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
}
/**
* Get the panel where all arrows are being drawn.
*
* @return
*/
public JPanel getArrowsManagerPanel() {
@ -73,17 +69,6 @@ public class ArrowBuilder {
return arrowPanels.get(gameId);
}
/**
* Not synchronized method for arrows panel.
* Doesn't create JPanel in case the panel doesn't exist.
* Works faster.
*
* @return
*/
/*public JPanel getPanelRef() {
return arrowsManagerPanel;
}*/
/**
* Adds new arrow.
*
@ -100,18 +85,25 @@ public class ArrowBuilder {
arrow.setColor(color);
arrow.setArrowLocation(startX, startY, endX, endY);
arrow.setBounds(0, 0, Math.max(startX, endX) + 40, Math.max(startY, endY) + 30); // 30 is offset for arrow heads (being cut otherwise)
synchronized (map) {
p.add(arrow);
Map<Type, java.util.List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<Type, List<Arrow>>());
java.util.List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<Arrow>());
arrows.add(arrow);
}
p.add(arrow);
Map<Type, List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<>());
List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<>());
arrows.add(arrow);
p.revalidate();
p.repaint();
}
/**
* Not synchronized method for arrows panel.
* Doesn't create JPanel in case the panel doesn't exist.
* Works faster.
*
* @return
*/
/*public JPanel getPanelRef() {
return arrowsManagerPanel;
}*/
/**
* Removes all arrows from the screen.
*/
@ -119,15 +111,13 @@ public class ArrowBuilder {
if (map.containsKey(gameId)) {
Map<Type, List<Arrow>> innerMap = map.get(gameId);
JPanel p = getArrowsPanel(gameId);
synchronized (map) {
if (p != null && p.getComponentCount() > 0) {
p.removeAll();
p.revalidate();
p.repaint();
}
innerMap.clear();
map.remove(gameId);
if (p != null && p.getComponentCount() > 0) {
p.removeAll();
p.revalidate();
p.repaint();
}
innerMap.clear();
map.remove(gameId);
}
}
@ -137,12 +127,10 @@ public class ArrowBuilder {
java.util.List<Arrow> arrows = innerMap.get(type);
if (arrows != null && !arrows.isEmpty()) {
JPanel p = getArrowsPanel(gameId);
synchronized (map) {
for (Arrow arrow : arrows) {
p.remove(arrow);
}
innerMap.put(type, new ArrayList<Arrow>());
for (Arrow arrow : arrows) {
p.remove(arrow);
}
innerMap.put(type, new ArrayList<>());
p.revalidate();
p.repaint();
}
@ -173,4 +161,8 @@ public class ArrowBuilder {
}
}
public enum Type {
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
}
}

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -22,7 +22,7 @@ public class TextboxLoyaltyRule extends TextboxRule {
} else if (loyaltyChange > 0) {
return "+" + loyaltyChange;
} else {
return "" + loyaltyChange;
return String.valueOf(loyaltyChange);
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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);
}
};
}

View file

@ -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:

View file

@ -59,7 +59,7 @@ public class GathererSymbols implements Iterable<DownloadJob> {
if (symIndex < symbols.length) {
sym = symbols[symIndex++];
} else if (numeric <= maxNumeric) {
sym = "" + (numeric++);
sym = String.valueOf(numeric++);
} else {
sizeIndex++;
if (sizeIndex == sizes.length) {

View file

@ -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) {

View file

@ -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) {

View file

@ -124,7 +124,7 @@ public class ChatManager {
if (messageType != MessageType.GAME) {
User user = UserManager.getInstance().getUserByName(userName);
if (message != null && userName != null && !userName.equals("")) {
if (message != null && userName != null && !userName.isEmpty()) {
if (message.equals(userMessages.get(userName))) {
// prevent identical messages
@ -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))
@ -272,8 +271,7 @@ public class ChatManager {
}
public ArrayList<ChatSession> getChatSessions() {
ArrayList<ChatSession> chatSessionList = new ArrayList<>();
chatSessionList.addAll(chatSessions.values());
ArrayList<ChatSession> chatSessionList = new ArrayList<>(chatSessions.values());
return chatSessionList;
}

View file

@ -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<UUID, String> clients = new ConcurrentHashMap<>();
private final UUID chatId;

View file

@ -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> _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> 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<UUID> hiddenCards) throws MageException {
return executeWithResult("sendCardPick", sessionId, new ActionWithNullNegativeResult<DraftPickView>() {
@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<GameView>() {
@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<UserView> getUsers(String sessionId) throws MageException {
return executeWithResult("getUsers", sessionId, new ActionWithNullNegativeResult<List<UserView>>() {
@Override
public List<UserView> execute() throws MageException {
List<UserView> 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<Object>() {
@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<CardInfo> getMissingCardsData(List<String> classNames) {
return CardRepository.instance.getMissingCards(classNames);
}
private static class MyActionWithNullNegativeResult extends ActionWithNullNegativeResult<Object> {
@Override
public Object execute() throws MageException {
return CompressUtil.compress(ServerMessagesUtil.getInstance().getMessages());
}
}
private static class ListActionWithNullNegativeResult extends ActionWithNullNegativeResult<List<UserView>> {
@Override
public List<UserView> execute() throws MageException {
List<UserView> 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<GameView> {
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<DraftPickView> {
private final String sessionId;
private final UUID draftId;
private final UUID cardPick;
private final Set<UUID> hiddenCards;
public DraftPickViewActionWithNullNegativeResult(String sessionId, UUID draftId, UUID cardPick, Set<UUID> 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> _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;
}
}
}

View file

@ -425,7 +425,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");
}
}

View file

@ -95,11 +95,7 @@ public class TableController {
if (userId != null) {
Optional<User> 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> 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);
}
}
@ -985,11 +976,11 @@ public class TableController {
}
public synchronized TableState getTableState() {
return getTable().getState();
return table.getState();
}
public synchronized boolean changeTableStateToStarting() {
if (getTable().getState() != TableState.READY_TO_START) {
if (table.getState() != TableState.READY_TO_START) {
// tournament is not ready, can't start
return false;
}
@ -997,7 +988,7 @@ public class TableController {
logger.debug("Not alle Seats are occupied: stop start tableId:" + table.getId());
return false;
}
getTable().setState(TableState.STARTING);
table.setState(TableState.STARTING);
return true;
}
}

View file

@ -388,8 +388,7 @@ public class TableManager {
debugServerState();
}
logger.debug("TABLE HEALTH CHECK");
ArrayList<Table> tableCopy = new ArrayList<>();
tableCopy.addAll(tables.values());
ArrayList<Table> tableCopy = new ArrayList<>(tables.values());
for (Table table : tableCopy) {
try {
if (table.getState() != TableState.FINISHED) {

View file

@ -430,35 +430,35 @@ public class User {
}
public void remove(DisconnectReason reason) {
logger.trace("REMOVE " + getName() + " Draft sessions " + draftSessions.size());
logger.trace("REMOVE " + userName + " Draft sessions " + draftSessions.size());
for (DraftSession draftSession : draftSessions.values()) {
draftSession.setKilled();
}
draftSessions.clear();
logger.trace("REMOVE " + getName() + " Tournament sessions " + userTournaments.size());
logger.trace("REMOVE " + userName + " Tournament sessions " + userTournaments.size());
for (UUID tournamentId : userTournaments.values()) {
TournamentManager.getInstance().quit(tournamentId, getId());
TournamentManager.getInstance().quit(tournamentId, userId);
}
userTournaments.clear();
logger.trace("REMOVE " + getName() + " Tables " + tables.size());
logger.trace("REMOVE " + userName + " Tables " + tables.size());
for (Entry<UUID, Table> entry : tables.entrySet()) {
logger.debug("-- leave tableId: " + entry.getValue().getId());
TableManager.getInstance().leaveTable(userId, entry.getValue().getId());
}
tables.clear();
logger.trace("REMOVE " + getName() + " Game sessions: " + gameSessions.size());
logger.trace("REMOVE " + userName + " Game sessions: " + gameSessions.size());
for (GameSessionPlayer gameSessionPlayer : gameSessions.values()) {
logger.debug("-- kill game session of gameId: " + gameSessionPlayer.getGameId());
GameManager.getInstance().quitMatch(gameSessionPlayer.getGameId(), userId);
gameSessionPlayer.quitGame();
}
gameSessions.clear();
logger.trace("REMOVE " + getName() + " watched Games " + watchedGames.size());
logger.trace("REMOVE " + userName + " watched Games " + watchedGames.size());
for (UUID gameId : watchedGames) {
GameManager.getInstance().stopWatching(gameId, userId);
}
watchedGames.clear();
logger.trace("REMOVE " + getName() + " Chats ");
logger.trace("REMOVE " + userName + " Chats ");
ChatManager.getInstance().removeUser(userId, reason);
}
@ -517,11 +517,11 @@ public class User {
}
} else {
// can happen if tournamet has just ended
logger.debug(getName() + " tournament player missing - tableId:" + table.getId(), null);
logger.debug(userName + " tournament player missing - tableId:" + table.getId(), null);
tablesToDelete.add(tableEntry.getKey());
}
} else {
logger.error(getName() + " tournament key missing - tableId: " + table.getId(), null);
logger.error(userName + " tournament key missing - tableId: " + table.getId(), null);
}
} else {
switch (table.getState()) {

View file

@ -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) {
@ -168,8 +168,7 @@ public class UserManager {
private void checkExpired() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -3);
List<User> usersToCheck = new ArrayList<>();
usersToCheck.addAll(users.values());
List<User> usersToCheck = new ArrayList<>(users.values());
for (User user : usersToCheck) {
if (!user.getUserState().equals(UserState.Expired) && user.isExpired(calendar.getTime())) {
removeUser(user.getId(), DisconnectReason.SessionExpired);

View file

@ -21,7 +21,7 @@ public class ChallengeManager {
}
public void prepareChallenge(UUID playerId, Match match) {
Map<Zone, String> commands = new HashMap<Zone, String>();
Map<Zone, String> commands = new HashMap<>();
commands.put(Zone.OUTSIDE, "life:3");
match.getGame().cheat(playerId, commands);
}

View file

@ -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<String, Class> draftCubes = new LinkedHashMap<String, Class>();
private final Map<String, Class> draftCubes = new LinkedHashMap<>();
public static CubeFactory getInstance() {
return INSTANCE;

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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)));
});
}

View file

@ -198,8 +198,7 @@ public class TournamentController {
private void checkStart() {
if (!started && allJoined()) {
ThreadExecutor.getInstance().getCallExecutor().execute(
() -> startTournament());
ThreadExecutor.getInstance().getCallExecutor().execute(this::startTournament);
}
}

View file

@ -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());

View file

@ -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() {