mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
[minor] access modifer order
This commit is contained in:
parent
ec546a5ae6
commit
a7a565bb8f
549 changed files with 1032 additions and 1040 deletions
|
@ -43,7 +43,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public abstract class MagePane extends javax.swing.JInternalFrame {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MagePane.class);
|
||||
private static final Logger logger = Logger.getLogger(MagePane.class);
|
||||
|
||||
/** Creates new form MagePane */
|
||||
public MagePane() {
|
||||
|
|
|
@ -38,24 +38,24 @@ public class RelativeLayout implements LayoutManager2, java.io.Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Used in the constructor
|
||||
public final static int X_AXIS = 0;
|
||||
public final static int Y_AXIS = 1;
|
||||
public static final int X_AXIS = 0;
|
||||
public static final int Y_AXIS = 1;
|
||||
|
||||
// See setAlignment() method
|
||||
public final static float LEADING = 0.0f;
|
||||
public final static float CENTER = 0.5f;
|
||||
public final static float TRAILING = 1.0f;
|
||||
public final static float COMPONENT = -1.0f;
|
||||
public static final float LEADING = 0.0f;
|
||||
public static final float CENTER = 0.5f;
|
||||
public static final float TRAILING = 1.0f;
|
||||
public static final float COMPONENT = -1.0f;
|
||||
|
||||
// See setRoundingPolicy() method
|
||||
public final static int DO_NOTHING = 0;
|
||||
public final static int FIRST = 1;
|
||||
public final static int LAST = 2;
|
||||
public final static int LARGEST = 3;
|
||||
public final static int EQUAL = 4;
|
||||
public static final int DO_NOTHING = 0;
|
||||
public static final int FIRST = 1;
|
||||
public static final int LAST = 2;
|
||||
public static final int LARGEST = 3;
|
||||
public static final int EQUAL = 4;
|
||||
|
||||
private final static int MINIMUM = 0;
|
||||
private final static int PREFERRED = 1;
|
||||
private static final int MINIMUM = 0;
|
||||
private static final int PREFERRED = 1;
|
||||
|
||||
private Map<Component, Float> constraints = new HashMap<Component, Float>();
|
||||
|
||||
|
@ -657,11 +657,9 @@ public class RelativeLayout implements LayoutManager2, java.io.Serializable {
|
|||
for (int i = 0; i < relativeSpace.length; i++) {
|
||||
int space = relativeSpace[i];
|
||||
|
||||
if (space > 0) {
|
||||
if (largestSpace < space) {
|
||||
largestSpace = space;
|
||||
largest = i;
|
||||
}
|
||||
if (space > 0 && largestSpace < space) {
|
||||
largestSpace = space;
|
||||
largest = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ import java.util.concurrent.ExecutionException;
|
|||
*/
|
||||
public class DeckEditorPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(DeckEditorPanel.class);
|
||||
private static final Logger logger = Logger.getLogger(DeckEditorPanel.class);
|
||||
|
||||
private JFileChooser fcSelectDeck;
|
||||
private JFileChooser fcImportDeck;
|
||||
|
@ -697,7 +697,7 @@ class ImportFilter extends FileFilter {
|
|||
|
||||
class UpdateDeckTask extends SwingWorker<Void, Void> {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(UpdateDeckTask.class);
|
||||
private static final Logger logger = Logger.getLogger(UpdateDeckTask.class);
|
||||
|
||||
private Session session;
|
||||
private UUID tableId;
|
||||
|
|
|
@ -60,7 +60,7 @@ import java.util.concurrent.ExecutionException;
|
|||
*/
|
||||
public class ConnectDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ConnectDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(ConnectDialog.class);
|
||||
private Connection connection;
|
||||
private ConnectTask task;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class JoinTableDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(JoinTableDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(JoinTableDialog.class);
|
||||
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
*/
|
||||
public class MageDialog extends javax.swing.JInternalFrame {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MageDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(MageDialog.class);
|
||||
|
||||
protected boolean modal = false;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class NewTableDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(NewTableDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(NewTableDialog.class);
|
||||
|
||||
private TableView table;
|
||||
private UUID playerId;
|
||||
|
|
|
@ -60,7 +60,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class NewTournamentDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(NewTournamentDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(NewTournamentDialog.class);
|
||||
|
||||
private TableView table;
|
||||
private UUID playerId;
|
||||
|
|
|
@ -56,7 +56,7 @@ import java.util.concurrent.ExecutionException;
|
|||
*/
|
||||
public class TableWaitingDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
|
@ -363,7 +363,7 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
|||
private TableWaitingDialog dialog;
|
||||
private int count = 0;
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
|
||||
UpdateSeatsTask(Session session, UUID roomId, UUID tableId, TableWaitingDialog dialog) {
|
||||
this.session = session;
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class FeedbackPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(FeedbackPanel.class);
|
||||
private static final Logger logger = Logger.getLogger(FeedbackPanel.class);
|
||||
|
||||
public enum FeedbackMode {
|
||||
INFORM, QUESTION, CONFIRM, CANCEL, SELECT, END
|
||||
|
|
|
@ -1255,7 +1255,7 @@ class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
|||
private Session session;
|
||||
private UUID gameId;
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ReplayTask.class);
|
||||
private static final Logger logger = Logger.getLogger(ReplayTask.class);
|
||||
|
||||
ReplayTask(Session session, UUID gameId) {
|
||||
this.session = session;
|
||||
|
|
|
@ -33,8 +33,8 @@ public class Plugins implements MagePlugins {
|
|||
|
||||
public static final String PLUGINS_DIRECTORY = "plugins/";
|
||||
|
||||
private final static MagePlugins fINSTANCE = new Plugins();
|
||||
private final static Logger logger = Logger.getLogger(Plugins.class);
|
||||
private static final MagePlugins fINSTANCE = new Plugins();
|
||||
private static final Logger logger = Logger.getLogger(Plugins.class);
|
||||
private static PluginManager pm;
|
||||
|
||||
private ThemePlugin themePlugin = null;
|
||||
|
|
|
@ -53,7 +53,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CallbackClientImpl implements CallbackClient {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
private static final Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
|
||||
private UUID clientId;
|
||||
private MageFrame frame;
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class TournamentPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TournamentPanel.class);
|
||||
private static final Logger logger = Logger.getLogger(TournamentPanel.class);
|
||||
|
||||
private UUID tournamentId;
|
||||
private Session session;
|
||||
|
@ -334,7 +334,7 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
|||
private UUID tournamentId;
|
||||
private TournamentPanel panel;
|
||||
|
||||
private final static Logger logger = Logger.getLogger(UpdateTournamentTask.class);
|
||||
private static final Logger logger = Logger.getLogger(UpdateTournamentTask.class);
|
||||
|
||||
UpdateTournamentTask(Session session, UUID tournamentId, TournamentPanel panel) {
|
||||
this.session = session;
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.Properties;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Config.class);
|
||||
private static final Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
public static final String remoteServer;
|
||||
public static final String serverName;
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class EDTExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(EDTExceptionHandler.class);
|
||||
private static final Logger logger = Logger.getLogger(EDTExceptionHandler.class);
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.awt.*;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
abstract public class Animation {
|
||||
public abstract class Animation {
|
||||
private static final long TARGET_MILLIS_PER_FRAME = 30;
|
||||
|
||||
private static Timer timer = new Timer("Animation", true);
|
||||
|
@ -46,7 +46,7 @@ abstract public class Animation {
|
|||
timer.scheduleAtFixedRate(timerTask, delay, TARGET_MILLIS_PER_FRAME);
|
||||
}
|
||||
|
||||
abstract protected void update (float percentage);
|
||||
protected abstract void update (float percentage);
|
||||
|
||||
protected void cancel () {
|
||||
timerTask.cancel();
|
||||
|
@ -102,7 +102,7 @@ abstract public class Animation {
|
|||
}
|
||||
}
|
||||
|
||||
static public void tapCardToggle (final CardPanel panel, final MagePermanent parent, final boolean tapped, final boolean flipped) {
|
||||
public static void tapCardToggle (final CardPanel panel, final MagePermanent parent, final boolean tapped, final boolean flipped) {
|
||||
new Animation(300) {
|
||||
@Override
|
||||
protected void start () {
|
||||
|
@ -177,7 +177,7 @@ abstract public class Animation {
|
|||
};
|
||||
}
|
||||
|
||||
static public void moveCardToPlay (final int startX, final int startY, final int startWidth, final int endX, final int endY,
|
||||
public static void moveCardToPlay (final int startX, final int startY, final int startWidth, final int endX, final int endY,
|
||||
final int endWidth, final CardPanel animationPanel, final CardPanel placeholder, final JLayeredPane layeredPane,
|
||||
final int speed) {
|
||||
UI.invokeLater(new Runnable() {
|
||||
|
@ -247,7 +247,7 @@ abstract public class Animation {
|
|||
});
|
||||
}
|
||||
|
||||
static public void moveCard (final int startX, final int startY, final int startWidth, final int endX, final int endY,
|
||||
public static void moveCard (final int startX, final int startY, final int startWidth, final int endX, final int endY,
|
||||
final int endWidth, final CardPanel animationPanel, final CardPanel placeholder, final JLayeredPane layeredPane,
|
||||
final int speed) {
|
||||
UI.invokeLater(new Runnable() {
|
||||
|
@ -294,11 +294,9 @@ abstract public class Animation {
|
|||
});
|
||||
}
|
||||
|
||||
static public void shrinkCard () {
|
||||
public static void shrinkCard () {
|
||||
final CardPanel overPanel, animationPanel;
|
||||
synchronized (enlargeLock) {
|
||||
//delayedCardPanel = null;
|
||||
//delayedTime = 0;
|
||||
overPanel = Animation.enlargedCardPanel;
|
||||
animationPanel = Animation.enlargedAnimationPanel;
|
||||
if (animationPanel == null) {
|
||||
|
@ -348,15 +346,15 @@ abstract public class Animation {
|
|||
};
|
||||
}
|
||||
|
||||
static public boolean isShowingEnlargedCard () {
|
||||
public static boolean isShowingEnlargedCard () {
|
||||
synchronized (enlargeLock) {
|
||||
return enlargedAnimationPanel != null;
|
||||
}
|
||||
}
|
||||
|
||||
static public void showCard(final MagePermanent card, int count) {
|
||||
public static void showCard(final MagePermanent card, int count) {
|
||||
if (count == 0) {
|
||||
count = 1;
|
||||
return;
|
||||
}
|
||||
new Animation(600 / count) {
|
||||
@Override
|
||||
|
@ -377,9 +375,9 @@ abstract public class Animation {
|
|||
};
|
||||
}
|
||||
|
||||
static public void hideCard(final MagePermanent card, int count) {
|
||||
public static void hideCard(final MagePermanent card, int count) {
|
||||
if (count == 0) {
|
||||
count = 1;
|
||||
return;
|
||||
}
|
||||
new Animation(600 / count) {
|
||||
@Override
|
||||
|
|
|
@ -46,12 +46,12 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
|
||||
public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149);
|
||||
|
||||
static private final float ROUNDED_CORNER_SIZE = 0.1f;
|
||||
static private final float BLACK_BORDER_SIZE = 0.03f;
|
||||
static private final int TEXT_GLOW_SIZE = 6;
|
||||
static private final float TEXT_GLOW_INTENSITY = 3f;
|
||||
static private final float ROT_CENTER_TO_TOP_CORNER = 1.0295630140987000315797369464196f;
|
||||
static private final float ROT_CENTER_TO_BOTTOM_CORNER = 0.7071067811865475244008443621048f;
|
||||
private static final float ROUNDED_CORNER_SIZE = 0.1f;
|
||||
private static final float BLACK_BORDER_SIZE = 0.03f;
|
||||
private static final int TEXT_GLOW_SIZE = 6;
|
||||
private static final float TEXT_GLOW_INTENSITY = 3f;
|
||||
private static final float ROT_CENTER_TO_TOP_CORNER = 1.0295630140987000315797369464196f;
|
||||
private static final float ROT_CENTER_TO_BOTTOM_CORNER = 0.7071067811865475244008443621048f;
|
||||
|
||||
public CardView gameCard;
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
public void setImage(final CardPanel panel) {
|
||||
synchronized (panel.imagePanel) {
|
||||
if (panel.imagePanel.hasImage()) {
|
||||
setImage(panel.imagePanel.srcImage);
|
||||
setImage(panel.imagePanel.getSrcImage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
return data;
|
||||
}
|
||||
|
||||
final protected String getType(CardView card) {
|
||||
protected final String getType(CardView card) {
|
||||
StringBuilder sbType = new StringBuilder();
|
||||
|
||||
for (String superType : card.getSuperTypes()) {
|
||||
|
@ -768,7 +768,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
return sbType.toString();
|
||||
}
|
||||
|
||||
final protected String getText(String cardType, CardView card) {
|
||||
protected final String getText(String cardType, CardView card) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
for (String rule : card.getRules()) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import javax.swing.JPanel;
|
|||
|
||||
public class ScaledImagePanel extends JPanel {
|
||||
private static final long serialVersionUID = -1523279873208605664L;
|
||||
public volatile Image srcImage;
|
||||
private volatile Image srcImage;
|
||||
|
||||
private ScalingType scalingType = ScalingType.bilinear;
|
||||
private boolean scaleLarger;
|
||||
|
@ -101,7 +101,6 @@ public class ScaledImagePanel extends JPanel {
|
|||
}
|
||||
|
||||
private void scaleWithGetScaledInstance (Graphics2D g2, ScalingInfo info, int hints) {
|
||||
Image srcImage = getSourceImage(info);
|
||||
Image scaledImage = srcImage.getScaledInstance(info.targetWidth, info.targetHeight, hints);
|
||||
g2.drawImage(scaledImage, info.x, info.y, null);
|
||||
}
|
||||
|
@ -117,8 +116,6 @@ public class ScaledImagePanel extends JPanel {
|
|||
tempDestHeight = info.targetHeight;
|
||||
}
|
||||
|
||||
Image srcImage = getSourceImage(info);
|
||||
|
||||
// If not doing multipass or multipass only needs a single pass, just scale it once directly to the panel surface.
|
||||
if (multiPassType == MultipassType.none || (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight)) {
|
||||
g2.drawImage(srcImage, info.x, info.y, info.targetWidth, info.targetHeight, null);
|
||||
|
@ -174,15 +171,11 @@ public class ScaledImagePanel extends JPanel {
|
|||
tempSrcHeight, null);
|
||||
}
|
||||
|
||||
private Image getSourceImage (ScalingInfo info) {
|
||||
return srcImage;
|
||||
}
|
||||
|
||||
public Image getSrcImage() {
|
||||
return srcImage;
|
||||
}
|
||||
|
||||
static private class ScalingInfo {
|
||||
private static class ScalingInfo {
|
||||
public int targetWidth;
|
||||
public int targetHeight;
|
||||
public int srcWidth;
|
||||
|
@ -191,11 +184,11 @@ public class ScaledImagePanel extends JPanel {
|
|||
public int y;
|
||||
}
|
||||
|
||||
static public enum MultipassType {
|
||||
public static enum MultipassType {
|
||||
none, nearestNeighbor, bilinear, bicubic
|
||||
}
|
||||
|
||||
static public enum ScalingType {
|
||||
public static enum ScalingType {
|
||||
nearestNeighbor, replicate, bilinear, bicubic, areaAveraging
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import static org.mage.plugins.card.dl.DownloadJob.toFile;
|
|||
|
||||
public class GathererSets implements Iterable<DownloadJob> {
|
||||
|
||||
private final static String SETS_PATH = File.separator + "sets";
|
||||
private final static File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + SETS_PATH);
|
||||
private static final String SETS_PATH = File.separator + "sets";
|
||||
private static final File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + SETS_PATH);
|
||||
private static File outDir = DEFAULT_OUT_DIR;
|
||||
|
||||
private static final String[] symbols = {"10E", "9ED", "8ED", "7ED", "6ED", "5ED", "4ED", "3ED", "2ED", "LEB", "LEA",
|
||||
|
|
|
@ -28,8 +28,8 @@ public class GathererSymbols implements Iterable<DownloadJob> {
|
|||
//TODO chaos and planeswalker symbol
|
||||
//chaos: http://gatherer.wizards.com/Images/Symbols/chaos.gif
|
||||
|
||||
private final static String SYMBOLS_PATH = File.separator + "symbols";
|
||||
private final static File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + SYMBOLS_PATH);
|
||||
private static final String SYMBOLS_PATH = File.separator + "symbols";
|
||||
private static final File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + SYMBOLS_PATH);
|
||||
private static File outDir = DEFAULT_OUT_DIR;
|
||||
|
||||
private static final String urlFmt = "http://gatherer.wizards.com/handlers/image.ashx?size=%1$s&name=%2$s&type=symbol";
|
||||
|
|
|
@ -21,16 +21,16 @@ import org.junit.Ignore;
|
|||
@Ignore
|
||||
public class MultiConnectTest {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MultiConnectTest.class);
|
||||
private static final Logger logger = Logger.getLogger(MultiConnectTest.class);
|
||||
|
||||
/**
|
||||
* Amount of games to be started from this test.
|
||||
*/
|
||||
private final static Integer USER_CONNECT_COUNT = 200;
|
||||
private static final Integer USER_CONNECT_COUNT = 200;
|
||||
|
||||
private final static CountDownLatch latch = new CountDownLatch(USER_CONNECT_COUNT);
|
||||
private static final CountDownLatch latch = new CountDownLatch(USER_CONNECT_COUNT);
|
||||
|
||||
private final static MageVersion version = new MageVersion(1, 0, 1, "");
|
||||
private static final MageVersion version = new MageVersion(1, 0, 1, "");
|
||||
|
||||
private static volatile int connected;
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ import org.junit.Ignore;
|
|||
@Ignore
|
||||
public class StartMultiGamesTest {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(StartMultiGamesTest.class);
|
||||
private static final Logger logger = Logger.getLogger(StartMultiGamesTest.class);
|
||||
|
||||
/**
|
||||
* Amount of games to be started from this test.
|
||||
*/
|
||||
private final static Integer GAME_START_COUNT = 10;
|
||||
private static final Integer GAME_START_COUNT = 10;
|
||||
|
||||
private MageFrame frame = null;
|
||||
private Object sync = new Object();
|
||||
|
|
|
@ -60,7 +60,7 @@ import java.util.*;
|
|||
*/
|
||||
public class SessionImpl implements Session {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(SessionImpl.class);
|
||||
private static final Logger logger = Logger.getLogger(SessionImpl.class);
|
||||
|
||||
private String sessionId;
|
||||
private MageServer server;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Map;
|
|||
@Author(name = "nantuko")
|
||||
public class ThemePluginImpl implements ThemePlugin {
|
||||
|
||||
private final static Logger log = Logger.getLogger(ThemePluginImpl.class);
|
||||
private static final Logger log = Logger.getLogger(ThemePluginImpl.class);
|
||||
private static BufferedImage background;
|
||||
|
||||
@Init
|
||||
|
|
|
@ -55,7 +55,7 @@ import java.util.concurrent.ExecutionException;
|
|||
*/
|
||||
public class ConnectDialog extends JDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ConnectDialog.class);
|
||||
private static final Logger logger = Logger.getLogger(ConnectDialog.class);
|
||||
private ConsoleFrame console;
|
||||
private Connection connection;
|
||||
private ConnectTask task;
|
||||
|
|
|
@ -52,12 +52,12 @@ import java.util.prefs.Preferences;
|
|||
*/
|
||||
public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ConsoleFrame.class);
|
||||
private static final Logger logger = Logger.getLogger(ConsoleFrame.class);
|
||||
|
||||
private static Session session;
|
||||
private ConnectDialog connectDialog;
|
||||
private static Preferences prefs = Preferences.userNodeForPackage(ConsoleFrame.class);
|
||||
private final static MageVersion version = new MageVersion(1, 0, 1, "");
|
||||
private static final MageVersion version = new MageVersion(1, 0, 1, "");
|
||||
|
||||
/**
|
||||
* @return the session
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class Config2 {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(Config2.class.getName());
|
||||
private static final Logger logger = Logging.getLogger(Config2.class.getName());
|
||||
|
||||
// public static final int maxDepth;
|
||||
public static final int maxNodes;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.logging.Logger;
|
|||
*/
|
||||
public class GameStateEvaluator2 {
|
||||
|
||||
private final static transient Logger logger = Logging.getLogger(GameStateEvaluator2.class.getName());
|
||||
private static final transient Logger logger = Logging.getLogger(GameStateEvaluator2.class.getName());
|
||||
|
||||
static {
|
||||
logger.setLevel(Level.ALL);
|
||||
|
|
|
@ -56,7 +56,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
*/
|
||||
public class SimulatedPlayer2 extends ComputerPlayer<SimulatedPlayer2> {
|
||||
|
||||
private final static transient Logger logger = Logger.getLogger(SimulatedPlayer2.class);
|
||||
private static final transient Logger logger = Logger.getLogger(SimulatedPlayer2.class);
|
||||
private boolean isSimulatedPlayer;
|
||||
private transient ConcurrentLinkedQueue<Ability> allActions;
|
||||
private boolean forced;
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class SimulationWorker2 implements Callable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker2.class.getName());
|
||||
private static final Logger logger = Logging.getLogger(SimulationWorker2.class.getName());
|
||||
|
||||
private Game game;
|
||||
private SimulatedAction2 previousActions;
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ComputerPlayerMCTS extends ComputerPlayer<ComputerPlayerMCTS> imple
|
|||
|
||||
protected transient MCTSNode root;
|
||||
protected int maxThinkTime;
|
||||
private final static transient Logger logger = Logger.getLogger(ComputerPlayerMCTS.class);
|
||||
private static final transient Logger logger = Logger.getLogger(ComputerPlayerMCTS.class);
|
||||
private transient ExecutorService pool;
|
||||
private int cores;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MCTSExecutor implements Callable<Boolean> {
|
|||
protected int thinkTime;
|
||||
protected UUID playerId;
|
||||
|
||||
private final static transient Logger logger = Logger.getLogger(ComputerPlayerMCTS.class);
|
||||
private static final transient Logger logger = Logger.getLogger(ComputerPlayerMCTS.class);
|
||||
|
||||
public MCTSExecutor(Game sim, UUID playerId, int thinkTime) {
|
||||
this.playerId = playerId;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class MCTSNode {
|
|||
|
||||
private static final double selectionCoefficient = 1.0;
|
||||
private static final double passRatioTolerance = 0.0;
|
||||
private final static transient Logger logger = Logger.getLogger(MCTSNode.class);
|
||||
private static final transient Logger logger = Logger.getLogger(MCTSNode.class);
|
||||
|
||||
private int visits = 0;
|
||||
private int wins = 0;
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class MCTSPlayer extends ComputerPlayer<MCTSPlayer> {
|
||||
|
||||
private final static transient Logger logger = Logger.getLogger(MCTSPlayer.class);
|
||||
private static final transient Logger logger = Logger.getLogger(MCTSPlayer.class);
|
||||
|
||||
protected PassAbility pass = new PassAbility();
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
private boolean isSimulatedPlayer;
|
||||
private static Random rnd = new Random();
|
||||
private int actionCount = 0;
|
||||
private final static transient Logger logger = Logger.getLogger(SimulatedPlayerMCTS.class);
|
||||
private static final transient Logger logger = Logger.getLogger(SimulatedPlayerMCTS.class);
|
||||
|
||||
public SimulatedPlayerMCTS(UUID id, boolean isSimulatedPlayer) {
|
||||
super(id);
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Config.class);
|
||||
private static final Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
// public static final int maxDepth;
|
||||
public static final int maxNodes;
|
||||
|
|
|
@ -53,7 +53,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class GameStateEvaluator {
|
||||
|
||||
private final static transient Logger logger = Logger.getLogger(GameStateEvaluator.class);
|
||||
private static final transient Logger logger = Logger.getLogger(GameStateEvaluator.class);
|
||||
|
||||
private static final int LIFE_FACTOR = Config.evaluatorLifeFactor;
|
||||
private static final int PERMANENT_FACTOR = Config.evaluatorPermanentFactor;
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class SimulateBlockWorker implements Callable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker.class.getName());
|
||||
private static final Logger logger = Logging.getLogger(SimulationWorker.class.getName());
|
||||
|
||||
private SimulationNode node;
|
||||
private ComputerPlayer3 player;
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class SimulatedPlayer extends ComputerPlayer<SimulatedPlayer> {
|
||||
|
||||
private final static transient Logger logger = Logger.getLogger(SimulatedPlayer.class);
|
||||
private static final transient Logger logger = Logger.getLogger(SimulatedPlayer.class);
|
||||
private boolean isSimulatedPlayer;
|
||||
private transient ConcurrentLinkedQueue<Ability> allActions;
|
||||
private static PassAbility pass = new PassAbility();
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.util.Logging;
|
|||
*/
|
||||
public class SimulationWorker implements Callable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker.class.getName());
|
||||
private static final Logger logger = Logging.getLogger(SimulationWorker.class.getName());
|
||||
|
||||
private Game game;
|
||||
private SimulatedAction previousActions;
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
*/
|
||||
public class ChatManager {
|
||||
|
||||
private final static ChatManager INSTANCE = new ChatManager();
|
||||
private static final ChatManager INSTANCE = new ChatManager();
|
||||
|
||||
public static ChatManager getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ChatSession {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ChatSession.class);
|
||||
private static final Logger logger = Logger.getLogger(ChatSession.class);
|
||||
private ConcurrentHashMap<UUID, String> clients = new ConcurrentHashMap<UUID, String>();
|
||||
private UUID chatId;
|
||||
private DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
||||
|
|
|
@ -66,7 +66,7 @@ import java.util.concurrent.ExecutorService;
|
|||
*/
|
||||
public class MageServerImpl implements MageServer {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MageServerImpl.class);
|
||||
private static final Logger logger = Logger.getLogger(MageServerImpl.class);
|
||||
private static ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
|
||||
|
||||
private String password;
|
||||
|
|
|
@ -1,311 +1,314 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.server;
|
||||
|
||||
import mage.cards.repository.CardScanner;
|
||||
import mage.game.match.MatchType;
|
||||
import mage.game.tournament.TournamentType;
|
||||
import mage.interfaces.MageServer;
|
||||
import mage.remote.Connection;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.game.GameFactory;
|
||||
import mage.server.game.PlayerFactory;
|
||||
import mage.server.tournament.TournamentFactory;
|
||||
import mage.server.util.ConfigSettings;
|
||||
import mage.server.util.PluginClassLoader;
|
||||
import mage.server.util.ServerMessagesUtil;
|
||||
import mage.server.util.SystemUtil;
|
||||
import mage.server.util.config.GamePlugin;
|
||||
import mage.server.util.config.Plugin;
|
||||
import mage.utils.MageVersion;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.*;
|
||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
|
||||
import org.jboss.remoting.transport.Connector;
|
||||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||
import org.jboss.remoting.transporter.TransporterClient;
|
||||
import org.jboss.remoting.transporter.TransporterServer;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
private static Logger logger = Logger.getLogger(Main.class);
|
||||
|
||||
private final static String testModeArg = "-testMode=";
|
||||
private final static String adminPasswordArg = "-adminPassword=";
|
||||
private final static String pluginFolder = "plugins";
|
||||
private static MageVersion version = new MageVersion(1, 0, 1, "");
|
||||
|
||||
public static PluginClassLoader classLoader = new PluginClassLoader();
|
||||
public static TransporterServer server;
|
||||
protected static boolean testMode;
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
logger.info("Starting MAGE server version " + version);
|
||||
logger.info("Logging level: " + logger.getEffectiveLevel());
|
||||
CardScanner.scan();
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = ConfigSettings.getInstance();
|
||||
for (GamePlugin plugin: config.getGameTypes()) {
|
||||
GameFactory.getInstance().addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (GamePlugin plugin: config.getTournamentTypes()) {
|
||||
TournamentFactory.getInstance().addTournamentType(plugin.getName(), loadTournamentType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getPlayerTypes()) {
|
||||
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getDeckTypes()) {
|
||||
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
String adminPassword = "";
|
||||
for (String arg: args) {
|
||||
if (arg.startsWith(testModeArg)) {
|
||||
testMode = Boolean.valueOf(arg.replace(testModeArg, ""));
|
||||
}
|
||||
else if (arg.startsWith(adminPasswordArg)) {
|
||||
adminPassword = arg.replace(adminPasswordArg, "");
|
||||
adminPassword = SystemUtil.sanitize(adminPassword);
|
||||
}
|
||||
}
|
||||
Connection connection = new Connection();
|
||||
connection.setHost(config.getServerAddress());
|
||||
connection.setPort(config.getPort());
|
||||
try {
|
||||
InvokerLocator serverLocator = new InvokerLocator(connection.getURI());
|
||||
if (!isAlreadyRunning(serverLocator)) {
|
||||
server = new MageTransporterServer(serverLocator, new MageServerImpl(adminPassword, testMode), MageServer.class.getName(), new MageServerInvocationHandler());
|
||||
server.start();
|
||||
logger.info("Started MAGE server - listening on " + connection.toString());
|
||||
if (testMode)
|
||||
logger.info("MAGE server running in test mode");
|
||||
initStatistics();
|
||||
}
|
||||
else {
|
||||
logger.fatal("Unable to start MAGE server - another server is already started");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.fatal("Failed to start server - " + connection.toString(), ex);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Failed to start server - " + connection.toString(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void initStatistics() {
|
||||
ServerMessagesUtil.getInstance().setStartDate(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
static boolean isAlreadyRunning(InvokerLocator serverLocator) {
|
||||
Map<String, String> metadata = new HashMap<String, String>();
|
||||
metadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
|
||||
metadata.put("generalizeSocketException", "true");
|
||||
try {
|
||||
MageServer testServer = (MageServer) TransporterClient.createTransporterClient(serverLocator.getLocatorURI(), MageServer.class, metadata);
|
||||
if (testServer != null) {
|
||||
testServer.getServerState();
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// assume server is not running
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static class ClientConnectionListener implements ConnectionListener {
|
||||
@Override
|
||||
public void handleConnectionException(Throwable throwable, Client client) {
|
||||
Session session = SessionManager.getInstance().getSession(client.getSessionId());
|
||||
if (session != null) {
|
||||
String sessionName;
|
||||
User user = UserManager.getInstance().getUser(session.getUserId());
|
||||
if (user != null)
|
||||
sessionName = user.getName() + " at " + session.getHost();
|
||||
else
|
||||
sessionName = session.getHost();
|
||||
if (throwable instanceof ClientDisconnectedException) {
|
||||
SessionManager.getInstance().disconnect(client.getSessionId(), false);
|
||||
logger.info("client disconnected - " + sessionName);
|
||||
}
|
||||
else {
|
||||
SessionManager.getInstance().disconnect(client.getSessionId(), false);
|
||||
logger.info("connection to client lost - " + sessionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class MageTransporterServer extends TransporterServer {
|
||||
|
||||
protected Connector connector;
|
||||
|
||||
public MageTransporterServer(InvokerLocator locator, Object target, String subsystem, MageServerInvocationHandler callback) throws Exception {
|
||||
super(locator, target, subsystem);
|
||||
connector.addInvocationHandler("callback", callback);
|
||||
connector.setLeasePeriod(5000);
|
||||
connector.addConnectionListener(new ClientConnectionListener());
|
||||
}
|
||||
|
||||
public Connector getConnector() throws Exception {
|
||||
return connector;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Connector getConnector(InvokerLocator locator, Map config, Element xmlConfig) throws Exception {
|
||||
Connector c = super.getConnector(locator, config, xmlConfig);
|
||||
this.connector = c;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
static class MageServerInvocationHandler implements ServerInvocationHandler {
|
||||
|
||||
@Override
|
||||
public void setMBeanServer(MBeanServer server) {}
|
||||
|
||||
@Override
|
||||
public void setInvoker(ServerInvoker invoker) {}
|
||||
|
||||
@Override
|
||||
public Object invoke(final InvocationRequest invocation) throws Throwable {
|
||||
String sessionId = invocation.getSessionId();
|
||||
Map map = invocation.getRequestPayload();
|
||||
String host;
|
||||
if (map != null) {
|
||||
InetAddress clientAddress = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS);
|
||||
host = clientAddress.getHostAddress();
|
||||
} else {
|
||||
host = "localhost";
|
||||
}
|
||||
SessionManager.getInstance().getSession(sessionId).setHost(host);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(InvokerCallbackHandler callbackHandler) {
|
||||
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
|
||||
try {
|
||||
String sessionId = handler.getClientSessionId();
|
||||
SessionManager.getInstance().createSession(sessionId, callbackHandler);
|
||||
} catch (Throwable ex) {
|
||||
logger.fatal("", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(InvokerCallbackHandler callbackHandler) {
|
||||
logger.fatal("removeListener called");
|
||||
// ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
|
||||
// String sessionId = handler.getCallbackClient().getSessionId();
|
||||
// SessionManager.getInstance().disconnect(sessionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Class<?> loadPlugin(Plugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading plugin: " + plugin.getClassName());
|
||||
return Class.forName(plugin.getClassName(), true, classLoader);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Plugin not Found:" + plugin.getJar() + " - check plugin folder");
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading plugin " + plugin.getJar(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static MatchType loadGameType(GamePlugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading game type: " + plugin.getClassName());
|
||||
return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Game type not found:" + plugin.getJar() + " - check plugin folder");
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading game type " + plugin.getJar(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TournamentType loadTournamentType(GamePlugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading tournament type: " + plugin.getClassName());
|
||||
return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Tournament type not found:" + plugin.getJar() + " - check plugin folder");
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading game type " + plugin.getJar(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void deleteSavedGames() {
|
||||
File directory = new File("saved/");
|
||||
if (!directory.exists())
|
||||
directory.mkdirs();
|
||||
File[] files = directory.listFiles(
|
||||
new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".game");
|
||||
}
|
||||
}
|
||||
);
|
||||
for (File file : files)
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static MageVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public static boolean isTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.server;
|
||||
|
||||
import mage.cards.repository.CardScanner;
|
||||
import mage.game.match.MatchType;
|
||||
import mage.game.tournament.TournamentType;
|
||||
import mage.interfaces.MageServer;
|
||||
import mage.remote.Connection;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.game.GameFactory;
|
||||
import mage.server.game.PlayerFactory;
|
||||
import mage.server.tournament.TournamentFactory;
|
||||
import mage.server.util.ConfigSettings;
|
||||
import mage.server.util.PluginClassLoader;
|
||||
import mage.server.util.ServerMessagesUtil;
|
||||
import mage.server.util.SystemUtil;
|
||||
import mage.server.util.config.GamePlugin;
|
||||
import mage.server.util.config.Plugin;
|
||||
import mage.utils.MageVersion;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.*;
|
||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
|
||||
import org.jboss.remoting.transport.Connector;
|
||||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||
import org.jboss.remoting.transporter.TransporterClient;
|
||||
import org.jboss.remoting.transporter.TransporterServer;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
private static Logger logger = Logger.getLogger(Main.class);
|
||||
|
||||
private static final String testModeArg = "-testMode=";
|
||||
private static final String adminPasswordArg = "-adminPassword=";
|
||||
private static final String pluginFolder = "plugins";
|
||||
private static MageVersion version = new MageVersion(1, 0, 1, "");
|
||||
|
||||
public static PluginClassLoader classLoader = new PluginClassLoader();
|
||||
public static TransporterServer server;
|
||||
protected static boolean testMode;
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
logger.info("Starting MAGE server version " + version);
|
||||
logger.info("Logging level: " + logger.getEffectiveLevel());
|
||||
CardScanner.scan();
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = ConfigSettings.getInstance();
|
||||
for (GamePlugin plugin: config.getGameTypes()) {
|
||||
GameFactory.getInstance().addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (GamePlugin plugin: config.getTournamentTypes()) {
|
||||
TournamentFactory.getInstance().addTournamentType(plugin.getName(), loadTournamentType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getPlayerTypes()) {
|
||||
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getDeckTypes()) {
|
||||
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
String adminPassword = "";
|
||||
for (String arg: args) {
|
||||
if (arg.startsWith(testModeArg)) {
|
||||
testMode = Boolean.valueOf(arg.replace(testModeArg, ""));
|
||||
}
|
||||
else if (arg.startsWith(adminPasswordArg)) {
|
||||
adminPassword = arg.replace(adminPasswordArg, "");
|
||||
adminPassword = SystemUtil.sanitize(adminPassword);
|
||||
}
|
||||
}
|
||||
Connection connection = new Connection();
|
||||
connection.setHost(config.getServerAddress());
|
||||
connection.setPort(config.getPort());
|
||||
try {
|
||||
InvokerLocator serverLocator = new InvokerLocator(connection.getURI());
|
||||
if (!isAlreadyRunning(serverLocator)) {
|
||||
server = new MageTransporterServer(serverLocator, new MageServerImpl(adminPassword, testMode), MageServer.class.getName(), new MageServerInvocationHandler());
|
||||
server.start();
|
||||
logger.info("Started MAGE server - listening on " + connection.toString());
|
||||
if (testMode) {
|
||||
logger.info("MAGE server running in test mode");
|
||||
}
|
||||
initStatistics();
|
||||
}
|
||||
else {
|
||||
logger.fatal("Unable to start MAGE server - another server is already started");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.fatal("Failed to start server - " + connection.toString(), ex);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Failed to start server - " + connection.toString(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void initStatistics() {
|
||||
ServerMessagesUtil.getInstance().setStartDate(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
static boolean isAlreadyRunning(InvokerLocator serverLocator) {
|
||||
Map<String, String> metadata = new HashMap<String, String>();
|
||||
metadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
|
||||
metadata.put("generalizeSocketException", "true");
|
||||
try {
|
||||
MageServer testServer = (MageServer) TransporterClient.createTransporterClient(serverLocator.getLocatorURI(), MageServer.class, metadata);
|
||||
if (testServer != null) {
|
||||
testServer.getServerState();
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// assume server is not running
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static class ClientConnectionListener implements ConnectionListener {
|
||||
@Override
|
||||
public void handleConnectionException(Throwable throwable, Client client) {
|
||||
Session session = SessionManager.getInstance().getSession(client.getSessionId());
|
||||
if (session != null) {
|
||||
String sessionName;
|
||||
User user = UserManager.getInstance().getUser(session.getUserId());
|
||||
if (user != null) {
|
||||
sessionName = user.getName() + " at " + session.getHost();
|
||||
} else {
|
||||
sessionName = session.getHost();
|
||||
}
|
||||
if (throwable instanceof ClientDisconnectedException) {
|
||||
SessionManager.getInstance().disconnect(client.getSessionId(), false);
|
||||
logger.info("client disconnected - " + sessionName);
|
||||
}
|
||||
else {
|
||||
SessionManager.getInstance().disconnect(client.getSessionId(), false);
|
||||
logger.info("connection to client lost - " + sessionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class MageTransporterServer extends TransporterServer {
|
||||
|
||||
protected Connector connector;
|
||||
|
||||
public MageTransporterServer(InvokerLocator locator, Object target, String subsystem, MageServerInvocationHandler callback) throws Exception {
|
||||
super(locator, target, subsystem);
|
||||
connector.addInvocationHandler("callback", callback);
|
||||
connector.setLeasePeriod(5000);
|
||||
connector.addConnectionListener(new ClientConnectionListener());
|
||||
}
|
||||
|
||||
public Connector getConnector() throws Exception {
|
||||
return connector;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Connector getConnector(InvokerLocator locator, Map config, Element xmlConfig) throws Exception {
|
||||
Connector c = super.getConnector(locator, config, xmlConfig);
|
||||
this.connector = c;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
static class MageServerInvocationHandler implements ServerInvocationHandler {
|
||||
|
||||
@Override
|
||||
public void setMBeanServer(MBeanServer server) {}
|
||||
|
||||
@Override
|
||||
public void setInvoker(ServerInvoker invoker) {}
|
||||
|
||||
@Override
|
||||
public Object invoke(final InvocationRequest invocation) throws Throwable {
|
||||
String sessionId = invocation.getSessionId();
|
||||
Map map = invocation.getRequestPayload();
|
||||
String host;
|
||||
if (map != null) {
|
||||
InetAddress clientAddress = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS);
|
||||
host = clientAddress.getHostAddress();
|
||||
} else {
|
||||
host = "localhost";
|
||||
}
|
||||
SessionManager.getInstance().getSession(sessionId).setHost(host);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(InvokerCallbackHandler callbackHandler) {
|
||||
ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
|
||||
try {
|
||||
String sessionId = handler.getClientSessionId();
|
||||
SessionManager.getInstance().createSession(sessionId, callbackHandler);
|
||||
} catch (Throwable ex) {
|
||||
logger.fatal("", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(InvokerCallbackHandler callbackHandler) {
|
||||
logger.fatal("removeListener called");
|
||||
// ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler;
|
||||
// String sessionId = handler.getCallbackClient().getSessionId();
|
||||
// SessionManager.getInstance().disconnect(sessionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Class<?> loadPlugin(Plugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading plugin: " + plugin.getClassName());
|
||||
return Class.forName(plugin.getClassName(), true, classLoader);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Plugin not Found:" + plugin.getJar() + " - check plugin folder");
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading plugin " + plugin.getJar(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static MatchType loadGameType(GamePlugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading game type: " + plugin.getClassName());
|
||||
return (MatchType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Game type not found:" + plugin.getJar() + " - check plugin folder");
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading game type " + plugin.getJar(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TournamentType loadTournamentType(GamePlugin plugin) {
|
||||
try {
|
||||
classLoader.addURL(new File(pluginFolder + "/" + plugin.getJar()).toURI().toURL());
|
||||
logger.info("Loading tournament type: " + plugin.getClassName());
|
||||
return (TournamentType) Class.forName(plugin.getTypeName(), true, classLoader).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.warn("Tournament type not found:" + plugin.getJar() + " - check plugin folder");
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error loading game type " + plugin.getJar(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void deleteSavedGames() {
|
||||
File directory = new File("saved/");
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
File[] files = directory.listFiles(
|
||||
new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".game");
|
||||
}
|
||||
}
|
||||
);
|
||||
for (File file : files)
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static MageVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public static boolean isTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class Session {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Session.class);
|
||||
private static final Logger logger = Logger.getLogger(Session.class);
|
||||
|
||||
private String sessionId;
|
||||
private UUID userId;
|
||||
|
|
|
@ -45,8 +45,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
*/
|
||||
public class SessionManager {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(SessionManager.class);
|
||||
private final static SessionManager INSTANCE = new SessionManager();
|
||||
private static final Logger logger = Logger.getLogger(SessionManager.class);
|
||||
private static final SessionManager INSTANCE = new SessionManager();
|
||||
|
||||
public static SessionManager getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -72,7 +72,7 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
public class TableController {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TableController.class);
|
||||
private static final Logger logger = Logger.getLogger(TableController.class);
|
||||
|
||||
private UUID userId;
|
||||
private UUID chatId;
|
||||
|
|
|
@ -56,8 +56,8 @@ public class TableManager {
|
|||
|
||||
protected static ScheduledExecutorService expireExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
private final static TableManager INSTANCE = new TableManager();
|
||||
private final static Logger logger = Logger.getLogger(TableManager.class);
|
||||
private static final TableManager INSTANCE = new TableManager();
|
||||
private static final Logger logger = Logger.getLogger(TableManager.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<UUID, TableController>();
|
||||
private ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
||||
|
|
|
@ -50,7 +50,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class User {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(User.class);
|
||||
private static final Logger logger = Logger.getLogger(User.class);
|
||||
|
||||
public enum UserState {
|
||||
Created, Connected, Disconnected, Reconnected;
|
||||
|
|
|
@ -49,8 +49,8 @@ public class UserManager {
|
|||
|
||||
protected static ScheduledExecutorService expireExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
private final static UserManager INSTANCE = new UserManager();
|
||||
private final static Logger logger = Logger.getLogger(UserManager.class);
|
||||
private static final UserManager INSTANCE = new UserManager();
|
||||
private static final Logger logger = Logger.getLogger(UserManager.class);
|
||||
|
||||
public static UserManager getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -51,7 +51,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class DraftController {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(GameController.class);
|
||||
private static final Logger logger = Logger.getLogger(GameController.class);
|
||||
public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
|
||||
|
||||
private ConcurrentHashMap<UUID, DraftSession> draftSessions = new ConcurrentHashMap<UUID, DraftSession>();
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.view.DraftPickView;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DraftManager {
|
||||
private final static DraftManager INSTANCE = new DraftManager();
|
||||
private static final DraftManager INSTANCE = new DraftManager();
|
||||
|
||||
public static DraftManager getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -41,8 +41,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class DeckValidatorFactory {
|
||||
|
||||
private final static DeckValidatorFactory INSTANCE = new DeckValidatorFactory();
|
||||
private final static Logger logger = Logger.getLogger(DeckValidatorFactory.class);
|
||||
private static final DeckValidatorFactory INSTANCE = new DeckValidatorFactory();
|
||||
private static final Logger logger = Logger.getLogger(DeckValidatorFactory.class);
|
||||
|
||||
private Map<String, Class> deckTypes = new LinkedHashMap<String, Class>();
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ import org.apache.log4j.Logger;
|
|||
public class GameController implements GameCallback {
|
||||
|
||||
private static ExecutorService gameExecutor = ThreadExecutor.getInstance().getGameExecutor();
|
||||
private final static Logger logger = Logger.getLogger(GameController.class);
|
||||
private static final Logger logger = Logger.getLogger(GameController.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
|
||||
private ConcurrentHashMap<UUID, GameWatcher> watchers = new ConcurrentHashMap<UUID, GameWatcher>();
|
||||
|
|
|
@ -45,8 +45,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class GameFactory {
|
||||
|
||||
private final static GameFactory INSTANCE = new GameFactory();
|
||||
private final static Logger logger = Logger.getLogger(GameFactory.class);
|
||||
private static final GameFactory INSTANCE = new GameFactory();
|
||||
private static final Logger logger = Logger.getLogger(GameFactory.class);
|
||||
|
||||
private Map<String, Class<Match>> games = new HashMap<String, Class<Match>>();
|
||||
private Map<String, MatchType> gameTypes = new HashMap<String, MatchType>();
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.view.GameView;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GameManager {
|
||||
private final static GameManager INSTANCE = new GameManager();
|
||||
private static final GameManager INSTANCE = new GameManager();
|
||||
|
||||
public static GameManager getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class GameReplay {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(GameReplay.class);
|
||||
private static final Logger logger = Logger.getLogger(GameReplay.class);
|
||||
|
||||
private GameStates savedGame;
|
||||
private Game game;
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.concurrent.Callable;
|
|||
*/
|
||||
public class GameWorker implements Callable {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(GameWorker.class);
|
||||
private static final Logger logger = Logger.getLogger(GameWorker.class);
|
||||
|
||||
private GameCallback result;
|
||||
private Game game;
|
||||
|
|
|
@ -60,7 +60,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(GamesRoomImpl.class);
|
||||
private static final Logger logger = Logger.getLogger(GamesRoomImpl.class);
|
||||
|
||||
private static ScheduledExecutorService updateExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
private static List<TableView> tableView = new ArrayList<TableView>();
|
||||
|
|
|
@ -37,8 +37,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
*/
|
||||
public class GamesRoomManager {
|
||||
|
||||
private final static GamesRoomManager INSTANCE = new GamesRoomManager();
|
||||
// private final static Logger logger = Logger.getLogger(GamesRoomManager.class);
|
||||
private static final GamesRoomManager INSTANCE = new GamesRoomManager();
|
||||
// private static final Logger logger = Logger.getLogger(GamesRoomManager.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<UUID, GamesRoom>();
|
||||
private UUID mainRoomId;
|
||||
|
|
|
@ -42,8 +42,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class PlayerFactory {
|
||||
|
||||
private final static PlayerFactory INSTANCE = new PlayerFactory();
|
||||
private final static Logger logger = Logger.getLogger(PlayerFactory.class);
|
||||
private static final PlayerFactory INSTANCE = new PlayerFactory();
|
||||
private static final Logger logger = Logger.getLogger(PlayerFactory.class);
|
||||
|
||||
private Map<String, Class> playerTypes = new LinkedHashMap<String, Class>();
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import mage.server.UserManager;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ReplayManager {
|
||||
private final static ReplayManager INSTANCE = new ReplayManager();
|
||||
private static final ReplayManager INSTANCE = new ReplayManager();
|
||||
|
||||
public static ReplayManager getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ReplaySession implements GameCallback {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ReplaySession.class);
|
||||
private static final Logger logger = Logger.getLogger(ReplaySession.class);
|
||||
private GameReplay replay;
|
||||
protected UUID userId;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
*/
|
||||
public class TournamentController {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TournamentController.class);
|
||||
private static final Logger logger = Logger.getLogger(TournamentController.class);
|
||||
|
||||
private UUID chatId;
|
||||
private UUID tableId;
|
||||
|
|
|
@ -45,8 +45,8 @@ import org.apache.log4j.Logger;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TournamentFactory {
|
||||
private final static TournamentFactory INSTANCE = new TournamentFactory();
|
||||
private final static Logger logger = Logger.getLogger(TournamentFactory.class);
|
||||
private static final TournamentFactory INSTANCE = new TournamentFactory();
|
||||
private static final Logger logger = Logger.getLogger(TournamentFactory.class);
|
||||
|
||||
private Map<String, Class<Tournament>> tournaments = new HashMap<String, Class<Tournament>>();
|
||||
private Map<String, TournamentType> tournamentTypes = new HashMap<String, TournamentType>();
|
||||
|
|
|
@ -40,7 +40,7 @@ import mage.view.TournamentView;
|
|||
*/
|
||||
public class TournamentManager {
|
||||
|
||||
private final static TournamentManager INSTANCE = new TournamentManager();
|
||||
private static final TournamentManager INSTANCE = new TournamentManager();
|
||||
|
||||
private ConcurrentHashMap<UUID, TournamentController> controllers = new ConcurrentHashMap<UUID, TournamentController>();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Config.class);
|
||||
private static final Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
static {
|
||||
Properties p = new Properties();
|
||||
|
|
|
@ -44,8 +44,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ConfigSettings {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ConfigSettings.class);
|
||||
private final static ConfigSettings INSTANCE = new ConfigSettings();
|
||||
private static final Logger logger = Logger.getLogger(ConfigSettings.class);
|
||||
private static final ConfigSettings INSTANCE = new ConfigSettings();
|
||||
|
||||
private Config config;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ThreadExecutor {
|
|||
((ThreadPoolExecutor)timeoutExecutor).allowCoreThreadTimeOut(true);
|
||||
}
|
||||
|
||||
private final static ThreadExecutor INSTANCE = new ThreadExecutor();
|
||||
private static final ThreadExecutor INSTANCE = new ThreadExecutor();
|
||||
|
||||
public static ThreadExecutor getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -50,7 +50,7 @@ import mage.filter.predicate.mageobject.AbilityPredicate;
|
|||
*/
|
||||
public class BloodfireDwarf extends CardImpl<BloodfireDwarf> {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature without flying");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature without flying");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class)));
|
||||
|
|
|
@ -48,7 +48,7 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public class DiversionaryTactics extends CardImpl<DiversionaryTactics> {
|
||||
|
||||
private final static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creatures you control");
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creatures you control");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new TappedPredicate()));
|
||||
|
|
|
@ -44,7 +44,7 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*/
|
||||
public class OvergrownEstate extends CardImpl<OvergrownEstate> {
|
||||
|
||||
private final static FilterControlledPermanent filter = new FilterControlledLandPermanent("a land");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a land");
|
||||
|
||||
public OvergrownEstate(UUID ownerId) {
|
||||
super(ownerId, 113, "Overgrown Estate", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{B}{G}{W}");
|
||||
|
|
|
@ -51,7 +51,7 @@ import mage.target.common.TargetControlledCreaturePermanent;
|
|||
*/
|
||||
public class QuagmireDruid extends CardImpl<QuagmireDruid> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("enchantment");
|
||||
private static final FilterPermanent filter = new FilterPermanent("enchantment");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class Smash extends CardImpl<Smash> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("artifact");
|
||||
private static final FilterPermanent filter = new FilterPermanent("artifact");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TranquilPath extends CardImpl<TranquilPath> {
|
|||
|
||||
class TranquilPathEffect extends OneShotEffect<TranquilPathEffect> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("");
|
||||
private static final FilterPermanent filter = new FilterPermanent("");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
|
|
|
@ -51,7 +51,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class AngelOfJubilation extends CardImpl<AngelOfJubilation> {
|
||||
|
||||
private final static FilterCreaturePermanent filterNonBlack = new FilterCreaturePermanent("nonblack creatures");
|
||||
private static final FilterCreaturePermanent filterNonBlack = new FilterCreaturePermanent("nonblack creatures");
|
||||
|
||||
static {
|
||||
filterNonBlack.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
|
||||
|
|
|
@ -61,7 +61,7 @@ public class DevoutChaplain extends CardImpl<DevoutChaplain> {
|
|||
new CardTypePredicate(CardType.ENCHANTMENT)));
|
||||
}
|
||||
|
||||
private final static FilterControlledPermanent humanFilter = new FilterControlledPermanent("untapped Human you control");
|
||||
private static final FilterControlledPermanent humanFilter = new FilterControlledPermanent("untapped Human you control");
|
||||
|
||||
static {
|
||||
humanFilter.add(Predicates.not(new TappedPredicate()));
|
||||
|
|
|
@ -56,7 +56,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class GallowsAtWillowHill extends CardImpl<GallowsAtWillowHill> {
|
||||
|
||||
private final static FilterControlledPermanent humanFilter = new FilterControlledPermanent("untapped Human you control");
|
||||
private static final FilterControlledPermanent humanFilter = new FilterControlledPermanent("untapped Human you control");
|
||||
|
||||
static {
|
||||
humanFilter.add(Predicates.not(new TappedPredicate()));
|
||||
|
|
|
@ -51,7 +51,7 @@ import mage.game.permanent.token.SpiritToken;
|
|||
*/
|
||||
public class BakuAltar extends CardImpl<BakuAltar> {
|
||||
|
||||
private final static FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
|
||||
public BakuAltar(UUID ownerId) {
|
||||
super(ownerId, 152, "Baku Altar", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
|
|
|
@ -53,7 +53,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public class BlademaneBaku extends CardImpl<BlademaneBaku> {
|
||||
|
||||
private final static FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
|
||||
public BlademaneBaku(UUID ownerId) {
|
||||
super(ownerId, 95, "Blademane Baku", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{R}");
|
||||
|
|
|
@ -50,7 +50,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class ChiseiHeartOfOceans extends CardImpl<ChiseiHeartOfOceans> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterControlledPermanent("remove a counter from a permanent you control");
|
||||
private static final FilterPermanent filter = new FilterControlledPermanent("remove a counter from a permanent you control");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(Constants.TargetController.YOU));
|
||||
|
|
|
@ -49,8 +49,8 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public class ClashOfRealities extends CardImpl<ClashOfRealities> {
|
||||
|
||||
private final static FilterCreaturePermanent filterSpirit = new FilterCreaturePermanent("Spirit creature");
|
||||
private final static FilterCreaturePermanent filterNotSpirit = new FilterCreaturePermanent("non-Spirit creature");
|
||||
private static final FilterCreaturePermanent filterSpirit = new FilterCreaturePermanent("Spirit creature");
|
||||
private static final FilterCreaturePermanent filterNotSpirit = new FilterCreaturePermanent("non-Spirit creature");
|
||||
|
||||
static {
|
||||
filterSpirit.add(new SubtypePredicate("Spirit"));
|
||||
|
|
|
@ -44,7 +44,7 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
|
|||
*/
|
||||
public class DayOfDestiny extends CardImpl<DayOfDestiny> {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("Legendary creatures");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Legendary creatures");
|
||||
|
||||
static {
|
||||
filter.add(new SupertypePredicate("Legendary"));
|
||||
|
|
|
@ -63,7 +63,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class FaithfulSquire extends CardImpl<FaithfulSquire> {
|
||||
|
||||
private final static FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
|
||||
public FaithfulSquire(UUID ownerId) {
|
||||
super(ownerId, 3, "Faithful Squire", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{W}{W}");
|
||||
|
|
|
@ -67,7 +67,7 @@ public class FinalJudgment extends CardImpl<FinalJudgment> {
|
|||
|
||||
class FinalJudgmentEffect extends OneShotEffect<FinalJudgmentEffect> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("");
|
||||
private static final FilterPermanent filter = new FilterPermanent("");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.CREATURE));
|
||||
|
|
|
@ -50,7 +50,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class Floodbringer extends CardImpl<Floodbringer> {
|
||||
|
||||
private final static FilterControlledPermanent filter = new FilterControlledLandPermanent("a land you control (return to hand)");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a land you control (return to hand)");
|
||||
|
||||
public Floodbringer(UUID ownerId) {
|
||||
super(ownerId, 34, "Floodbringer", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
|
||||
|
|
|
@ -55,7 +55,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class GenjuOfTheCedars extends CardImpl<GenjuOfTheCedars> {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent("Forest");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Forest");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Forest"));
|
||||
|
|
|
@ -56,7 +56,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class GenjuOfTheFalls extends CardImpl<GenjuOfTheFalls> {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Island"));
|
||||
|
|
|
@ -60,7 +60,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class GenjuOfTheFens extends CardImpl<GenjuOfTheFens> {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent("Swamp");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Swamp");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Swamp"));
|
||||
|
|
|
@ -58,7 +58,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class GenjuOfTheFields extends CardImpl<GenjuOfTheFields> {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent("Plains");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Plains");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Plains"));
|
||||
|
|
|
@ -55,7 +55,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class GenjuOfTheRealm extends CardImpl<GenjuOfTheRealm> {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent();
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent();
|
||||
|
||||
public GenjuOfTheRealm(UUID ownerId) {
|
||||
super(ownerId, 151, "Genju of the Realm", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{W}{U}{B}{R}{G}");
|
||||
|
|
|
@ -55,7 +55,7 @@ import mage.target.common.TargetLandPermanent;
|
|||
*/
|
||||
public class GenjuOfTheSpires extends CardImpl<GenjuOfTheSpires> {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent("Mountain");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Mountain");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Mountain"));
|
||||
|
|
|
@ -42,7 +42,7 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public class HerosDemise extends CardImpl<HerosDemise> {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("legendary creature");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("legendary creature");
|
||||
|
||||
static {
|
||||
filter.add(new SupertypePredicate("Legendary"));
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.target.common.TargetCreatureOrPlayer;
|
|||
*/
|
||||
public class IreOfKaminari extends CardImpl<IreOfKaminari> {
|
||||
|
||||
private final static FilterCard filter = new FilterCard("Arcane");
|
||||
private static final FilterCard filter = new FilterCard("Arcane");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Arcane"));
|
||||
|
|
|
@ -50,7 +50,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class IsaoEnlightenedBushi extends CardImpl<IsaoEnlightenedBushi> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("Samurai");
|
||||
private static final FilterPermanent filter = new FilterPermanent("Samurai");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Samurai"));
|
||||
|
|
|
@ -45,7 +45,7 @@ import mage.filter.common.FilterSpiritOrArcaneCard;
|
|||
*/
|
||||
public class KamiOfTatteredShoji extends CardImpl<KamiOfTatteredShoji> {
|
||||
|
||||
private final static FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
|
||||
public KamiOfTatteredShoji(UUID ownerId) {
|
||||
super(ownerId, 11, "Kami of Tattered Shoji", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{W}");
|
||||
|
|
|
@ -48,7 +48,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class NezumiShadowWatcher extends CardImpl<NezumiShadowWatcher> {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("Ninja");
|
||||
private static final FilterPermanent filter = new FilterPermanent("Ninja");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Ninja"));
|
||||
|
|
|
@ -45,7 +45,7 @@ import mage.game.permanent.token.Token;
|
|||
*/
|
||||
public class OyobiWhoSplitTheHeavens extends CardImpl<OyobiWhoSplitTheHeavens> {
|
||||
|
||||
private final static FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
|
||||
public OyobiWhoSplitTheHeavens(UUID ownerId) {
|
||||
super(ownerId, 18, "Oyobi, Who Split the Heavens", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{6}{W}");
|
||||
|
|
|
@ -53,7 +53,7 @@ import mage.players.Player;
|
|||
*/
|
||||
public class PetalmaneBaku extends CardImpl<PetalmaneBaku> {
|
||||
|
||||
private final static FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();
|
||||
|
||||
public PetalmaneBaku(UUID ownerId) {
|
||||
super(ownerId, 139, "Petalmane Baku", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{G}");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue