Sonar's fixes

This commit is contained in:
Oleg Agafonov 2019-07-06 13:09:27 +04:00
parent f572ace420
commit bce01ce053
6 changed files with 703 additions and 714 deletions

View file

@ -848,7 +848,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
}
// can save result
if (isDownloadOK & httpConn != null) {
if (isDownloadOK && httpConn != null) {
// save data to temp
try (InputStream in = new BufferedInputStream(httpConn.getInputStream());
OutputStream tfileout = new TFileOutputStream(fileTempImage);

View file

@ -135,6 +135,7 @@ public class TableView implements Serializable {
switch (table.getState()) {
case WAITING:
stateText.append(" (").append(table.getTournament().getPlayers().size()).append('/').append(table.getNumberOfSeats()).append(')');
break;
case READY_TO_START:
case STARTING:
infoText.append(" Time: ").append(table.getTournament().getOptions().getMatchOptions().getMatchTimeLimit().toString());
@ -153,6 +154,7 @@ public class TableView implements Serializable {
if (draft != null) {
stateText.append(' ').append(draft.getBoosterNum()).append('/').append(draft.getCardNum() - 1);
}
break;
default:
}
this.additionalInfo = infoText.toString();

View file

@ -1,31 +1,26 @@
package mage.server.console;
import mage.remote.Session;
import mage.view.TableView;
import mage.view.UserView;
import org.apache.log4j.Logger;
/*
* ConsolePanel.java
*
* Created on 14-May-2011, 6:08:48 PM
*/
package mage.server.console;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.swing.*;
import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN;
import static javax.swing.JTable.AUTO_RESIZE_OFF;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;
import mage.remote.Session;
import mage.view.TableView;
import mage.view.UserView;
import org.apache.log4j.Logger;
import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN;
import static javax.swing.JTable.AUTO_RESIZE_OFF;
/**
/**
* @author BetaSteward_at_googlemail.com
*/
public class ConsolePanel extends javax.swing.JPanel {
public class ConsolePanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(ConsolePanel.class);
@ -404,9 +399,9 @@ public class ConsolePanel extends javax.swing.JPanel {
private javax.swing.JTable tblTables;
private javax.swing.JTable tblUsers;
// End of variables declaration//GEN-END:variables
}
}
class TableUserModel extends AbstractTableModel {
class TableUserModel extends AbstractTableModel {
public static final int POS_USER_NAME = 0;
public static final int POS_HOST = 1;
@ -487,9 +482,9 @@ class TableUserModel extends AbstractTableModel {
return false;
}
}
}
class TableTableModel extends AbstractTableModel {
class TableTableModel extends AbstractTableModel {
private final String[] columnNames = new String[]{"Table Name", "Owner", "Game Type", "Deck Type", "Status"};
private TableView[] tables = new TableView[0];
@ -553,15 +548,12 @@ class TableTableModel extends AbstractTableModel {
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
if (columnIndex != 5) {
return false;
}
return true;
return columnIndex == 5;
}
}
}
class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
private final Session session;
private final ConsolePanel panel;
@ -589,44 +581,35 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
users = users2;
}
if (previousUsers == null || checkUserListChanged(users)) {
logger.debug("Need to update the user list");
checkUserListChanged(users);
this.publish(users);
previousUsers = users;
}
Thread.sleep(2000);
}
return null;
}
private boolean checkUserListChanged(List<UserView> usersToCheck) {
private void checkUserListChanged(List<UserView> usersToCheck) {
if (previousUsers == null || usersToCheck == null) {
return true;
}
if (previousUsers.size() != usersToCheck.size()) {
// new user appeared
return true;
return;
}
for (UserView u1 : previousUsers) {
for (UserView u2 : usersToCheck) {
if (u1.getUserName().equals(u2.getUserName())) {
String s = u1.getUserName() + ',' + u1.getHost();
if (peopleIps.get(s) == null) {
logger.warn("Found new user: " + u1.getUserName() + ',' + u1.getHost());
peopleIps.put(s, "1");
}
s = u2.getUserName() + ',' + u2.getHost();
}
for (UserView u1 : usersToCheck) {
String s = u1.getUserName() + ',' + u1.getHost();
if (peopleIps.get(s) == null) {
logger.warn("Found new user: " + u1.getUserName() + ',' + u1.getHost());
peopleIps.put(s, "1");
}
break;
}
}
}
// seems nothing has been changed
return true;
}
@Override
protected void process(List<List<UserView>> view) {
@ -648,9 +631,9 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
} catch (CancellationException ex) {
}
}
}
}
class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
private final Session session;
private final UUID roomId;
@ -700,4 +683,4 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
} catch (CancellationException ex) {
}
}
}
}

View file

@ -1999,8 +1999,10 @@ public class HumanPlayer extends PlayerImpl {
tResponse.setString("resolveStack");
actionQueueSaved.add(tResponse);
}
break;
default:
super.sendPlayerAction(playerAction, game, data);
break;
}
}

View file

@ -97,12 +97,13 @@ class BondOfPassionEffect extends OneShotEffect {
Permanent permanent2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent2 != null) {
permanent2.damage(2, source.getSourceId(), game);
return true;
}
} else {
Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (player != null) {
player.damage(2, source.getSourceId(), game);
}
}
return true;
}
}

View file

@ -1,10 +1,5 @@
package mage;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
@ -14,6 +9,11 @@ import mage.filter.Filter;
import mage.filter.FilterMana;
import mage.game.Game;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author nantuko
*/
@ -192,6 +192,7 @@ public class ConditionalMana extends Mana implements Serializable {
break;
case COLORLESS:
colorless += amount;
break;
case GENERIC:
generic += amount;
break;