Merge pull request #2891 from kubikrubikvkube/master

Nulls to optional. Also there was bug with AetherChaser
This commit is contained in:
ingmargoudt 2017-02-27 17:51:35 +01:00 committed by GitHub
commit afbf5ce2b6
131 changed files with 188 additions and 183 deletions

View file

@ -20,7 +20,7 @@ import mage.view.*;
/**
* Created by IGOUDT on 15-9-2016.
*/
public class SessionHandler {
public final class SessionHandler {
private static Session session;

View file

@ -12,7 +12,7 @@ import java.util.Optional;
import java.util.StringTokenizer;
import java.util.UUID;
public class LocalCommands {
public final class LocalCommands {
private static final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);

View file

@ -26,7 +26,7 @@ public class MageRoundPane extends JPanel {
private int Y_OFFSET = 30;
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200);
private Color backgroundColor = defaultBackgroundColor;
private final int alpha = 0;
private static final int alpha = 0;
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final Map<Key, BufferedImage> IMAGE_CACHE;

View file

@ -16,7 +16,7 @@ public class BackgroundPainter extends AbstractPainter {
private final Color bgColor = Color.black;
final float bgalpha = 0.6f;
static final float bgalpha = 0.6f;
public BackgroundPainter() {
super();

View file

@ -7,7 +7,7 @@ import javax.swing.*;
/**
* @author ayratn
*/
public class TestMageFloatPane {
public final class TestMageFloatPane {
public static void main(String... args) {
JFrame f = new JFrame();

View file

@ -22,7 +22,7 @@ public class DialogContainer extends JPanel {
private Color backgroundColor = new Color(0, 255, 255, 60);
private int alpha = 50;
private final boolean isGradient = false;
private static final boolean isGradient = false;
private final TexturePaint tp = null;
private final Image gradient = null;
private BufferedImage b;

View file

@ -52,7 +52,7 @@ import mage.util.TournamentUtil;
* @author nantuko
* @author Simown
*/
public class DeckGenerator {
public final class DeckGenerator {
public static class DeckGeneratorException extends RuntimeException {

View file

@ -62,7 +62,7 @@ public class DeckArea extends javax.swing.JPanel {
private BigCard lastBigCard = null;
private int dividerLocationNormal = 0;
private int dividerLocationLimited = 0;
private final boolean isLimitedBuildingOrientation = false;
private static final boolean isLimitedBuildingOrientation = false;
public DeckCardLayout getCardLayout() {
return deckList.getCardLayout();

View file

@ -57,7 +57,7 @@ public final class CollectionViewerPanel extends JPanel {
private static final Logger logger = Logger.getLogger(CollectionViewerPanel.class);
protected static final String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig";
protected static final String FORMAT_CONFIG_KEY = "collectionViewerFormat";
private static final String FORMAT_CONFIG_KEY = "collectionViewerFormat";
public CollectionViewerPanel() {
initComponents();

View file

@ -346,7 +346,7 @@ public class MageBook extends JComponent {
/**
* Defines the position of the next card on the mage book
*/
private static class CardPosition {
private static final class CardPosition {
private CardPosition() {
}

View file

@ -37,7 +37,7 @@ import mage.view.CardView;
*
* @author nantuko
*/
public class CardHelper {
public final class CardHelper {
private CardHelper() {
}

View file

@ -86,8 +86,8 @@ public class NewTournamentDialog extends MageDialog {
private JTextArea txtRandomPacks;
private final List<TournamentPlayerPanel> players = new ArrayList<>();
private final List<JComboBox> packs = new ArrayList<>();
private final int CONSTRUCTION_TIME_MIN = 6;
private final int CONSTRUCTION_TIME_MAX = 30;
private static final int CONSTRUCTION_TIME_MIN = 6;
private static final int CONSTRUCTION_TIME_MAX = 30;
private boolean isRandom = false;
private boolean isRichMan = false;
private String cubeFromDeckFilename = "";

View file

@ -8,7 +8,7 @@ import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
// TODO: Move all preference related logic from MageFrame and PreferencesDialog to this class.
public class MagePreferences {
public final class MagePreferences {
private static final String KEY_SERVER_ADDRESS = "serverAddress";
private static final String KEY_SERVER_PORT = "serverPort";

View file

@ -39,7 +39,7 @@ import mage.view.*;
*
* @author BetaSteward_at_googlemail.com
*/
public class CardsViewUtil {
public final class CardsViewUtil {
public static CardsView convertSimple(SimpleCardsView view) {
CardsView cards = new CardsView();

View file

@ -38,7 +38,7 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config {
public final class Config {
// TODO: Remove this class completely
private static final Logger logger = Logger.getLogger(Config.class);

View file

@ -41,7 +41,7 @@ import org.apache.log4j.Logger;
*
* @author nantuko
*/
public class DeckUtil {
public final class DeckUtil {
private static final Logger log = Logger.getLogger(DeckUtil.class);

View file

@ -34,7 +34,7 @@ import java.util.Date;
*
* @author LevelX2
*/
public class Format {
public final class Format {
/**
* calculates the duration between two dates and returns a string in the format hhh:mm:ss

View file

@ -19,7 +19,7 @@ import org.mage.card.arcane.CardRenderer;
*
* @author LevelX2
*/
public class GUISizeHelper {
public final class GUISizeHelper {
// relate the native image card size to a value of the size scale
final static int CARD_IMAGE_WIDTH = 312;

View file

@ -8,7 +8,7 @@ import mage.view.ChatMessage;
import java.util.Arrays;
import java.util.Set;
public class IgnoreList {
public final class IgnoreList {
private static final String USAGE = "<br/><font color=yellow>\\ignore - shows current ignore list on this server."
+ "<br/>\\ignore [username] - add a username to your ignore list on this server."

View file

@ -34,7 +34,7 @@ import java.util.Map;
*
* @author draxdyn
*/
public class ImageCaches {
public final class ImageCaches {
private final static ArrayList<Map> IMAGE_CACHES;

View file

@ -47,7 +47,7 @@ import org.mage.card.arcane.UI;
*
* @author BetaSteward_at_googlemail.com
*/
public class ImageHelper {
public final class ImageHelper {
protected static final HashMap<String, BufferedImage> images = new HashMap<>();
protected static final HashMap<String, BufferedImage> backgrounds = new HashMap<>();

View file

@ -6,7 +6,7 @@ import java.lang.reflect.Method;
/**
* @author noxx
*/
public class SystemUtil {
public final class SystemUtil {
public static final String OS_NAME = "os.name";
public static final String MAC_OS_X = "Mac OS X";

View file

@ -20,7 +20,7 @@ import java.util.Map;
*
* @author user
*/
public class TransformedImageCache {
public final class TransformedImageCache {
private final static class Key {
@ -68,7 +68,7 @@ public class TransformedImageCache {
}
}
static final Map<Key, Map<BufferedImage, BufferedImage>> IMAGE_CACHE;
private static final Map<Key, Map<BufferedImage, BufferedImage>> IMAGE_CACHE;
static {
// TODO: can we use a single map?
@ -85,17 +85,17 @@ public class TransformedImageCache {
private static BufferedImage rotateImage(BufferedImage image, double angle) {
double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
int w = image.getWidth(), h = image.getHeight();
int neww = (int) Math.floor(w * cos + h * sin), newh = (int) Math.floor(h * cos + w * sin);
int width = image.getWidth(), height = image.getHeight();
int newWidth = (int) Math.floor(width * cos + height * sin), newHeight = (int) Math.floor(height * cos + width * sin);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.TRANSLUCENT);
BufferedImage result = gc.createCompatibleImage(newWidth, newHeight, Transparency.TRANSLUCENT);
Graphics2D g = result.createGraphics();
g.translate((neww - w) / 2, (newh - h) / 2);
g.rotate(angle, w / 2, h / 2);
g.translate((newWidth - width) / 2, (newHeight - height) / 2);
g.rotate(angle, width / 2, height / 2);
g.drawRenderedImage(image, null);
g.dispose();
return result;

View file

@ -14,7 +14,7 @@ import java.util.UUID;
/**
* @author noxx
*/
public class ArrowUtil {
public final class ArrowUtil {
private ArrowUtil() {}

View file

@ -26,7 +26,7 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
public class GuiDisplayUtil {
public final class GuiDisplayUtil {
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
private static final Insets DEFAULT_INSETS = new Insets(0, 0, 70, 25);

View file

@ -13,7 +13,7 @@ import mage.client.dialog.PreferencesDialog;
*
* @author LevelX2
*/
public class TableUtil {
public final class TableUtil {
/**
*

View file

@ -18,7 +18,7 @@ import org.apache.log4j.Logger;
*
* @author LevelX2
*/
public class CountryUtil {
public final class CountryUtil {
private static final Logger LOGGER = Logger.getLogger(CountryUtil.class);
private static final Map<String, ImageIcon> FLAG_ICON_CACHE = new HashMap<>();

View file

@ -13,7 +13,7 @@ import java.util.Calendar;
*
* @author ayrat
*/
public class SaveObjectUtil {
public final class SaveObjectUtil {
/**
* Defines should data be saved or not.

View file

@ -16,7 +16,7 @@ import mage.deck.Standard;
*
* @author nantuko
*/
public class ConstructedFormats {
public final class ConstructedFormats {
public static final String ALL = "- All Sets";
public static final String STANDARD = "- Standard";

View file

@ -3,7 +3,7 @@ package mage.client.util.stats;
/**
* @author noxx
*/
public class MemoryUsageStatUtil {
public final class MemoryUsageStatUtil {
private MemoryUsageStatUtil() {}

View file

@ -22,7 +22,7 @@ import java.util.regex.Pattern;
*
* Various static utilities for use in the card renderer
*/
public class CardRendererUtils {
public final class CardRendererUtils {
/**
* Convert an abstract image, whose underlying implementation may or may not

View file

@ -31,7 +31,7 @@ import mage.client.util.gui.BufferedImageBuilder;
import org.apache.log4j.Logger;
import org.mage.plugins.card.constants.Constants;
public class ManaSymbols {
public final class ManaSymbols {
private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
private static final Map<Integer, Map<String, BufferedImage>> manaImages = new HashMap<>();

View file

@ -18,7 +18,7 @@ import org.apache.log4j.Logger;
*
* @author StravantUser
*/
public class TextboxRuleParser {
public final class TextboxRuleParser {
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);

View file

@ -46,7 +46,7 @@ import javax.swing.text.html.ImageView;
/**
* UI utility functions.
*/
public class UI {
public final class UI {
private static final ConcurrentMap<URI, Image> imageCache = new ConcurrentHashMap<>();
public static JToggleButton getToggleButton () {

View file

@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit;
import javax.swing.SwingUtilities;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Util {
public final class Util {
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase().contains("windows");

View file

@ -68,12 +68,12 @@ public class CardPluginImpl implements CardPlugin {
private static final float STACK_SPACING_Y = 0.10f;
private static final float ATTACHMENT_SPACING_Y = 0.13f;
private final int landStackMax = 5;
private static final int landStackMax = 5;
// private int cardWidthMin = 50, cardWidthMax = Constants.CARD_SIZE_FULL.width;
private int cardWidthMin = (int) GUISizeHelper.battlefieldCardMinDimension.getWidth();
private int cardWidthMax = (int) GUISizeHelper.battlefieldCardMaxDimension.getWidth();
private final boolean stackVertical = false;
private static final boolean stackVertical = false;
private int playAreaWidth, playAreaHeight;
private int cardWidth, cardHeight;

View file

@ -3,7 +3,7 @@ package org.mage.plugins.card.constants;
import java.awt.Rectangle;
import java.io.File;
public class Constants {
public final class Constants {
public static final String RESOURCE_PATH_SET = File.separator + "sets" + File.separator;

View file

@ -15,7 +15,7 @@ import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
import org.mage.plugins.card.properties.SettingsManager;
public class CardImageUtils {
public final class CardImageUtils {
private static final HashMap<CardDownloadData, String> pathCache = new HashMap<>();
private static final Logger log = Logger.getLogger(CardImageUtils.class);

View file

@ -11,14 +11,14 @@ import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;
public class Transparency {
public final class Transparency {
public static Image makeColorTransparent(Image im, final Color color) {
ImageFilter filter = new RGBImageFilter() {
// the color we are looking for... Alpha bits are set to opaque
public final int markerRGB = color.getRGB() | 0xFF000000;
@Override
public final int filterRGB(int x, int y, int rgb) {
public int filterRGB(int x, int y, int rgb) {
if ((rgb | 0xFF000000) == markerRGB) {
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;

View file

@ -10,7 +10,7 @@ import java.util.List;
/**
* @author noxx
*/
public class EntityManagerTest {
public final class EntityManagerTest {
private static DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.FULL);

View file

@ -7,7 +7,7 @@ import java.util.*;
/**
* @author noxx
*/
public class Statistics {
public final class Statistics {
public static void main(String[] args) throws Exception {
List<Log> logs = EntityManager.instance.getAllLogs();

View file

@ -13,7 +13,7 @@ import mage.view.CardView;
* @version 0.1 02.11.2010
* @author nantuko
*/
public class CardUtil {
public final class CardUtil {
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";

View file

@ -8,7 +8,7 @@ import mage.remote.traffic.ZippedObjectImpl;
*
* @author ayrat
*/
public class CompressUtil {
public final class CompressUtil {
/**
* Defines should data be compressed or not. True by default. Read from

View file

@ -21,7 +21,7 @@ import mage.util.RandomUtil;
*
* @author nantuko
*/
public class DeckBuilder {
public final class DeckBuilder {
private static final int DECK_COUNT40[] = {3, 6, 6, 4, 3, 2};
private static final int DECK_COUNT60[] = {4, 9, 9, 5, 5, 3};

View file

@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
* @author ayrat
*/
@SuppressWarnings("unchecked")
public class ThreadUtils {
public final class ThreadUtils {
public static final ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool2;

View file

@ -9,7 +9,7 @@ import java.util.Properties;
/**
* @author noxx
*/
public class PropertiesUtil {
public final class PropertiesUtil {
private static final Logger logger = Logger.getLogger(PropertiesUtil.class);

View file

@ -3,7 +3,7 @@ package mage.utils.properties;
/**
* @author noxx
*/
public class PropertyKeys {
public final class PropertyKeys {
public static final String KEY_DB_LOG_URL = "db.log.url";
public static final String KEY_DB_FEEDBACK_URL = "db.feedback.url";

View file

@ -40,7 +40,7 @@ import java.util.Properties;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config2 {
public final class Config2 {
private static final Logger logger = Logger.getLogger(Config2.class);

View file

@ -18,7 +18,7 @@ import org.apache.log4j.Logger;
* this evaluator is only good for two player games
*
*/
public class GameStateEvaluator2 {
public final class GameStateEvaluator2 {
private static final Logger logger = Logger.getLogger(GameStateEvaluator2.class);

View file

@ -14,7 +14,7 @@ import mage.game.permanent.Permanent;
/**
* @author ubeefx, nantuko
*/
public class ArtificialScoringSystem {
public final class ArtificialScoringSystem {
public static final int WIN_GAME_SCORE = 100000000;
public static final int LOSE_GAME_SCORE = -WIN_GAME_SCORE;

View file

@ -9,7 +9,7 @@ import java.util.Map;
/**
* @author nantuko
*/
public class MagicAbility {
public final class MagicAbility {
private static Map<String, Integer> scores = new HashMap<String, Integer>() {{
put(DeathtouchAbility.getInstance().getRule(), 60);

View file

@ -21,7 +21,7 @@ import java.util.*;
*
* @author noxx
*/
public class CombatUtil {
public final class CombatUtil {
private static final List<Permanent> emptyList = new ArrayList<Permanent>();

View file

@ -21,7 +21,7 @@ import java.util.*;
*
* @author nantuko
*/
public class RateCard {
public final class RateCard {
private static Map<String, Integer> ratings;
private static final Map<String, Integer> rated = new HashMap<>();

View file

@ -39,7 +39,7 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config {
public final class Config {
private static final Logger logger = Logger.getLogger(Config.class);

View file

@ -51,7 +51,7 @@ import org.apache.log4j.Logger;
* this evaluator is only good for two player games
*
*/
public class GameStateEvaluator {
public final class GameStateEvaluator {
private static final Logger logger = Logger.getLogger(GameStateEvaluator.class);

View file

@ -37,7 +37,7 @@ import java.util.Scanner;
/**
* @author Lymia
*/
public class ExtensionPackageLoader {
public final class ExtensionPackageLoader {
public static ExtensionPackage loadExtension(File directory) throws IOException {
if(!directory.exists ()) throw new RuntimeException("File not found "+directory);
if(!directory.isDirectory()) throw new RuntimeException(directory+" is not a directory");

View file

@ -28,7 +28,7 @@ import javax.mail.internet.MimeMessage;
import mage.server.util.ConfigSettings;
import org.apache.log4j.Logger;
public class GmailClient {
public final class GmailClient {
private static final Logger logger = Logger.getLogger(Main.class);
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();

View file

@ -10,7 +10,7 @@ import javax.mail.internet.MimeMessage;
import mage.server.util.ConfigSettings;
import org.apache.log4j.Logger;
public class MailClient {
public final class MailClient {
private static final Logger logger = Logger.getLogger(Main.class);

View file

@ -9,7 +9,7 @@ import javax.ws.rs.core.MediaType;
import mage.server.util.ConfigSettings;
import org.apache.log4j.Logger;
public class MailgunClient {
public final class MailgunClient {
private static final Logger logger = Logger.getLogger(Main.class);

View file

@ -70,7 +70,7 @@ import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
public class Main {
public final class Main {
private static final Logger logger = Logger.getLogger(Main.class);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);

View file

@ -27,14 +27,6 @@
*/
package mage.server;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import mage.MageException;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists;
@ -68,6 +60,15 @@ import mage.server.util.ThreadExecutor;
import mage.view.ChatMessage;
import org.apache.log4j.Logger;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -195,8 +196,9 @@ public class TableController {
return false;
}
Player player = createPlayer(name, seat.getPlayerType(), skill);
if (player != null) {
Optional<Player> playerOptional = createPlayer(name, seat.getPlayerType(), skill);
if (playerOptional.isPresent()) {
Player player = playerOptional.get();
if (!player.canJoinTable(table)) {
user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
return false;
@ -227,10 +229,11 @@ public class TableController {
}
public synchronized boolean replaceDraftPlayer(Player oldPlayer, String name, String playerType, int skill) {
Player newPlayer = createPlayer(name, playerType, skill);
if (newPlayer == null || table.getState() != TableState.DRAFTING) {
Optional<Player> newPlayerOpt = createPlayer(name, playerType, skill);
if (!newPlayerOpt.isPresent() || table.getState() != TableState.DRAFTING) {
return false;
}
Player newPlayer = newPlayerOpt.get();
TournamentPlayer oldTournamentPlayer = tournament.getPlayer(oldPlayer.getId());
tournament.removePlayer(oldPlayer.getId());
tournament.addPlayer(newPlayer, playerType);
@ -331,13 +334,14 @@ public class TableController {
}
}
Player player = createPlayer(name, seat.getPlayerType(), skill);
if (player == null) {
Optional<Player> playerOpt = createPlayer(name, seat.getPlayerType(), skill);
if (!playerOpt.isPresent()) {
String message = new StringBuilder("Could not create player ").append(name).append(" of type ").append(seat.getPlayerType()).toString();
logger.warn(new StringBuilder("User: ").append(user.getName()).append(" => ").append(message).toString());
user.showUserMessage("Join Table", message);
return false;
}
Player player = playerOpt.get();
logger.debug("DECK validated: " + table.getValidator().getName() + ' ' + player.getName() + ' ' + deck.getName());
if (!player.canJoinTable(table)) {
user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
@ -468,17 +472,18 @@ public class TableController {
// ReplayManager.getInstance().replayGame(table.getId(), userId);
// return true;
// }
private Player createPlayer(String name, String playerType, int skill) {
Player player;
private Optional<Player> createPlayer(String name, String playerType, int skill) {
Optional<Player> playerOpt;
if (options == null) {
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
playerOpt = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
} else {
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
playerOpt = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
}
if (player != null) {
if (playerOpt.isPresent()) {
Player player = playerOpt.get();
logger.trace("Player " + player.getName() + " created id: " + player.getId());
}
return player;
return playerOpt;
}
public void leaveTableAll() {

View file

@ -28,14 +28,16 @@
package mage.server.game;
import java.lang.reflect.Constructor;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import mage.constants.RangeOfInfluence;
import mage.players.Player;
import org.apache.log4j.Logger;
import java.lang.reflect.Constructor;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/**
*
* @author BetaSteward_at_googlemail.com
@ -53,14 +55,14 @@ public class PlayerFactory {
private PlayerFactory() {}
public Player createPlayer(String playerType, String name, RangeOfInfluence range, int skill) {
public Optional<Player> createPlayer(String playerType, String name, RangeOfInfluence range, int skill) {
try {
Class playerTypeClass = playerTypes.get(playerType);
if (playerTypeClass != null) {
Constructor<?> con = playerTypeClass.getConstructor(String.class, RangeOfInfluence.class, int.class);
Player player = (Player) con.newInstance(name, range, skill);
logger.trace("Player created: " + name + " - " + player.getId());
return player;
return Optional.of(player);
}
else {
logger.fatal("Unknown player type: " + playerType);
@ -68,7 +70,7 @@ public class PlayerFactory {
} catch (Exception ex) {
logger.fatal("PlayerFactory error ", ex);
}
return null;
return Optional.empty();
}
public Set<String> getPlayerTypes() {

View file

@ -36,7 +36,7 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config {
public final class Config {
private static final Logger logger = Logger.getLogger(Config.class);

View file

@ -9,7 +9,7 @@ import mage.players.Player;
/**
* @author nantuko
*/
public class Splitter {
public final class Splitter {
public static List<UUID> split(Game game, UUID playerId) {
List<UUID> players = new ArrayList<>();

View file

@ -19,7 +19,7 @@ import java.util.regex.Pattern;
/**
* @author nantuko
*/
public class SystemUtil {
public final class SystemUtil {
public static final DateFormat dateFormat = new SimpleDateFormat("yy-M-dd HH:mm:ss");

View file

@ -59,7 +59,7 @@ public class AbzanBattlePriest extends CardImpl {
filter.add(new CounterPredicate(CounterType.P1P1));
}
final String rule = "Each creature you control with a +1/+1 counter on it has lifelink";
static final String rule = "Each creature you control with a +1/+1 counter on it has lifelink";
public AbzanBattlePriest(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}");

View file

@ -27,7 +27,6 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -41,6 +40,8 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.game.permanent.token.ServoToken;
import java.util.UUID;
/**
*
* @author fireshoes
@ -62,7 +63,7 @@ public class AetherChaser extends CardImpl {
this.addAbility(new EntersBattlefieldTriggeredAbility(new GetEnergyCountersControllerEffect(2)));
// Whenever Aether Chaser attacks, you may pay {E}{E}. If you do, create a 1/1 colorless Servo artifact creature token.
this.addAbility(new AttacksTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new ServoToken()), new PayEnergyCost(2)), false,
this.addAbility(new AttacksTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new ServoToken()), new PayEnergyCost(2)), true,
"Whenever {this} attacks you may pay {E}{E}. If you do, create a 1/1 colorless Servo artifact creature token."));
}

View file

@ -60,7 +60,7 @@ public class AinokBondKin extends CardImpl {
filter.add(new CounterPredicate(CounterType.P1P1));
}
final String rule = "Each creature you control with a +1/+1 counter on it has first strike";
static final String rule = "Each creature you control with a +1/+1 counter on it has first strike";
public AinokBondKin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");

View file

@ -84,8 +84,8 @@ public class AquamorphEntity extends CardImpl {
class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
private final String choice51 = "a 5/1 creature";
private final String choice15 = "a 1/5 creature";
private static final String choice51 = "a 5/1 creature";
private static final String choice15 = "a 1/5 creature";
public AquamorphEntityReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);

View file

@ -64,7 +64,7 @@ public class Aurification extends CardImpl {
filter.add(new CounterPredicate(CounterType.GOLD));
}
final String rule = "Each creature with a gold counter on it is a Wall in addition to its other creature types and has defender.";
static final String rule = "Each creature with a gold counter on it is a Wall in addition to its other creature types and has defender.";
public Aurification(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}{W}");

View file

@ -47,7 +47,7 @@ import mage.counters.CounterType;
*/
public class BalothPup extends CardImpl {
private final String rule = "{this} has trample as long as it has a +1/+1 counter on it";
private static final String rule = "{this} has trample as long as it has a +1/+1 counter on it";
public BalothPup(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}");

View file

@ -47,7 +47,7 @@ import mage.cards.CardSetInfo;
*/
public class BladeTribeBerserkers extends CardImpl {
private final String effectText = "Metalcraft - When Blade-Tribe Berserkers enters the battlefield, if you control three or more artifacts, Blade-Tribe Berserkers gets +3/+3 and gains haste until end of turn.";
private static final String effectText = "Metalcraft - When Blade-Tribe Berserkers enters the battlefield, if you control three or more artifacts, Blade-Tribe Berserkers gets +3/+3 and gains haste until end of turn.";
public BladeTribeBerserkers(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}");

View file

@ -47,7 +47,7 @@ import mage.target.TargetPlayer;
*/
public class BleakCovenVampires extends CardImpl {
private final String effectText = "Metalcraft - When Bleak Coven Vampires enters the battlefield, if you control three or more artifacts, target player loses 4 life and you gain 4 life.";
private static final String effectText = "Metalcraft - When Bleak Coven Vampires enters the battlefield, if you control three or more artifacts, target player loses 4 life and you gain 4 life.";
public BleakCovenVampires(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}{B}");

View file

@ -51,7 +51,7 @@ import mage.filter.predicate.permanent.AnotherPredicate;
*/
public class CrabappleCohort extends CardImpl {
private final String rule = "{this} gets +1/+1 as long as you control another green creature";
private static final String rule = "{this} gets +1/+1 as long as you control another green creature";
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();

View file

@ -50,7 +50,7 @@ import mage.filter.predicate.permanent.AnotherPredicate;
*/
public class EldraziAggressor extends CardImpl {
private final String rule = "{this} has haste as long as you control another colorless creature";
private static final String rule = "{this} has haste as long as you control another colorless creature";
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another colorless creature");
static {

View file

@ -62,7 +62,7 @@ public class ExavaRakdosBloodWitch extends CardImpl {
filter.add(new AnotherPredicate());
}
final String rule = "Each other creature you control with a +1/+1 counter on it has haste";
static final String rule = "Each other creature you control with a +1/+1 counter on it has haste";
public ExavaRakdosBloodWitch(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{R}");
this.supertype.add("Legendary");

View file

@ -49,7 +49,7 @@ import mage.cards.CardSetInfo;
* @author Loki
*/
public class EzurisBrigade extends CardImpl {
private final String text = "Metalcraft - As long as you control three or more artifacts, Ezuri's Brigade gets +4/+4 and has trample";
private static final String text = "Metalcraft - As long as you control three or more artifacts, Ezuri's Brigade gets +4/+4 and has trample";
public EzurisBrigade (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}{G}");

View file

@ -42,7 +42,7 @@ import mage.target.common.TargetCreatureOrPlayer;
*/
public class GalvanicBlast extends CardImpl {
private final String effectText = "{this} deals 2 damage to target creature or player.<br>Metalcraft - {this} deals 4 damage to that creature or player instead if you control three or more artifacts";
private static final String effectText = "{this} deals 2 damage to target creature or player.<br>Metalcraft - {this} deals 4 damage to that creature or player instead if you control three or more artifacts";
public GalvanicBlast(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{R}");

View file

@ -47,7 +47,7 @@ import mage.cards.CardSetInfo;
*/
public class GhalmasWarden extends CardImpl {
private final String text = "Metalcraft - Ghalma's Warden gets +2/+2 as long as you control three or more artifacts";
private static final String text = "Metalcraft - Ghalma's Warden gets +2/+2 as long as you control three or more artifacts";
public GhalmasWarden (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}");

View file

@ -60,8 +60,8 @@ public class GwyllionHedgeMage extends CardImpl {
filter2.add(new SubtypePredicate("Swamp"));
}
private final String rule1 = "When {this} enters the battlefield, if you control two or more Plains, you may create a 1/1 white Kithkin Soldier creature token.";
private final String rule2 = "When {this} enters the battlefield, if you control two or more Swamps, you may put a -1/-1 counter on target creature.";
private static final String rule1 = "When {this} enters the battlefield, if you control two or more Plains, you may create a 1/1 white Kithkin Soldier creature token.";
private static final String rule2 = "When {this} enters the battlefield, if you control two or more Swamps, you may put a -1/-1 counter on target creature.";
public GwyllionHedgeMage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W/B}");

View file

@ -50,7 +50,7 @@ import mage.counters.CounterType;
*/
public class HelixPinnacle extends CardImpl {
final String rule = "if there are 100 or more tower counters on Helix Pinnacle, you win the game";
static final String rule = "if there are 100 or more tower counters on Helix Pinnacle, you win the game";
public HelixPinnacle(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{G}");

View file

@ -47,7 +47,7 @@ import mage.filter.common.FilterCreaturePermanent;
*/
public class JorKadeenThePrevailer extends CardImpl {
private final String effectText = "Metalcraft - Creatures you control get +3/+0 as long as you control three or more artifacts.";
private static final String effectText = "Metalcraft - Creatures you control get +3/+0 as long as you control three or more artifacts.";
public JorKadeenThePrevailer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}{W}");

View file

@ -89,7 +89,7 @@ public class MaliciousAffliction extends CardImpl {
class CopySourceSpellEffect extends OneShotEffect {
final String rule = "copy {this} and may choose a new target for the copy";
static final String rule = "copy {this} and may choose a new target for the copy";
public CopySourceSpellEffect() {
super(Outcome.Benefit);

View file

@ -50,7 +50,7 @@ import mage.filter.predicate.permanent.AnotherPredicate;
*/
public class MarkovCrusader extends CardImpl {
private final String rule = "{this} has haste as long as you control another Vampire";
private static final String rule = "{this} has haste as long as you control another Vampire";
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another Vampire");
static {

View file

@ -60,9 +60,9 @@ public class MinotaurTactician extends CardImpl {
filterBlue.add(new ColorPredicate(ObjectColor.BLUE));
}
final private String ruleWhite = "{this} gets +1/+1 as long as you control another white creature";
static final private String ruleWhite = "{this} gets +1/+1 as long as you control another white creature";
final private String ruleBlue = "{this} gets +1/+1 as long as you control another white creature";
static final private String ruleBlue = "{this} gets +1/+1 as long as you control another white creature";
public MinotaurTactician(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}");

View file

@ -44,7 +44,7 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class MirranMettle extends CardImpl {
private final String effectText = "Metalcraft - That creature gets +4/+4 until end of turn instead if you control three or more artifacts.";
private static final String effectText = "Metalcraft - That creature gets +4/+4 until end of turn instead if you control three or more artifacts.";
public MirranMettle(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{G}");

View file

@ -52,7 +52,7 @@ import mage.filter.predicate.permanent.AnotherPredicate;
*/
public class MudbrawlerCohort extends CardImpl {
private final String rule = "{this} gets +1/+1 as long as you control another red creature";
private static final String rule = "{this} gets +1/+1 as long as you control another red creature";
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();

View file

@ -45,7 +45,7 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class Nefashu extends CardImpl {
final String rule = "Whenever Nefashu attacks, up to five target creatures each get -1/-1 until end of turn.";
static final String rule = "Whenever Nefashu attacks, up to five target creatures each get -1/-1 until end of turn.";
public Nefashu(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{B}{B}");

View file

@ -58,7 +58,7 @@ public class OgreBattledriver extends CardImpl {
filter.add(new AnotherPredicate());
}
private final String rule = "Whenever another creature enters the battlefield under your control, that creature gets +2/+0 and gains haste until end of turn.";
private static final String rule = "Whenever another creature enters the battlefield under your control, that creature gets +2/+0 and gains haste until end of turn.";
public OgreBattledriver(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{R}");

View file

@ -58,7 +58,7 @@ public class PathOfBravery extends CardImpl {
static {
filter.add(new ControllerPredicate(TargetController.YOU));
}
final String rule = "As long as your life total is greater than or equal to your starting life total, creatures you control get +1/+1";
static final String rule = "As long as your life total is greater than or equal to your starting life total, creatures you control get +1/+1";
public PathOfBravery(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");

View file

@ -78,9 +78,9 @@ public class PrimalClay extends CardImpl {
class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
private final String choice33 = "a 3/3 artifact creature";
private final String choice22 = "a 2/2 artifact creature with flying";
private final String choice16 = "a 1/6 artifact creature with defender";
private static final String choice33 = "a 3/3 artifact creature";
private static final String choice22 = "a 2/2 artifact creature with flying";
private static final String choice16 = "a 1/6 artifact creature with defender";
public PrimalPlasmaReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);

View file

@ -55,7 +55,7 @@ public class PrimalForcemage extends CardImpl {
filter.add(new AnotherPredicate());
}
private final String rule = "Whenever another creature enters the battlefield under your control, that creature gets +3/+3 until end of turn.";
private static final String rule = "Whenever another creature enters the battlefield under your control, that creature gets +3/+3 until end of turn.";
public PrimalForcemage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}");

View file

@ -79,9 +79,9 @@ public class PrimalPlasma extends CardImpl {
class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
private final String choice33 = "a 3/3 creature";
private final String choice22 = "a 2/2 creature with flying";
private final String choice16 = "a 1/6 creature with defender";
private static final String choice33 = "a 3/3 creature";
private static final String choice22 = "a 2/2 creature with flying";
private static final String choice16 = "a 1/6 creature with defender";
public PrimalPlasmaReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);

View file

@ -49,7 +49,7 @@ import mage.target.common.TargetCreatureOrPlayer;
*/
public class RekindledFlame extends CardImpl {
final String rule = "if an opponent has no cards in hand, you may return Rekindled Flame from your graveyard to your hand";
static final String rule = "if an opponent has no cards in hand, you may return Rekindled Flame from your graveyard to your hand";
public RekindledFlame(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{R}{R}");

View file

@ -56,7 +56,7 @@ public class SapphireDrake extends CardImpl {
filter.add(new CounterPredicate(CounterType.P1P1));
}
final String rule = "Each creature you control with a +1/+1 counter on it has flying";
static final String rule = "Each creature you control with a +1/+1 counter on it has flying";
public SapphireDrake(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{U}");

View file

@ -62,7 +62,7 @@ public class ScourgeOfValkas extends CardImpl {
filter2.add(new SubtypePredicate("Dragon"));
}
private final String rule = "Whenever {this} or another Dragon enters the battlefield under your control, it deals X damage to target creature or player, where X is the number of Dragons you control.";
private static final String rule = "Whenever {this} or another Dragon enters the battlefield under your control, it deals X damage to target creature or player, where X is the number of Dragons you control.";
public ScourgeOfValkas(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{R}{R}");

View file

@ -62,8 +62,8 @@ public class SelkieHedgeMage extends CardImpl {
filter3.add(new TappedPredicate());
}
private final String rule1 = "When {this} enters the battlefield, if you control two or more Forests, you may gain 3 life.";
private final String rule2 = "When {this} enters the battlefield, if you control two or more Islands, you may return target tapped creature to its owner's hand.";
private static final String rule1 = "When {this} enters the battlefield, if you control two or more Forests, you may gain 3 life.";
private static final String rule2 = "When {this} enters the battlefield, if you control two or more Islands, you may return target tapped creature to its owner's hand.";
public SelkieHedgeMage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G/U}");

View file

@ -47,7 +47,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
*/
public class ShepherdOfRot extends CardImpl {
final String rule = "Each player loses 1 life for each Zombie on the battlefield";
static final String rule = "Each player loses 1 life for each Zombie on the battlefield";
static final private FilterPermanent filter = new FilterPermanent("Zombie");

View file

@ -47,7 +47,7 @@ import mage.cards.CardSetInfo;
*/
public class SpiralingDuelist extends CardImpl {
private final String effectText = "Metalcraft - Spiraling Duelist has double strike as long as you control three or more artifacts.";
private static final String effectText = "Metalcraft - Spiraling Duelist has double strike as long as you control three or more artifacts.";
public SpiralingDuelist(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{R}");

View file

@ -76,7 +76,7 @@ public class ThoughtHemorrhage extends CardImpl {
class ThoughtHemorrhageEffect extends OneShotEffect {
final String rule = "Target player reveals his or her hand. {this} deals 3 damage to that player for each card with that name revealed this way. Search that player's graveyard, hand, and library for all cards with that name and exile them. Then that player shuffles his or her library";
static final String rule = "Target player reveals his or her hand. {this} deals 3 damage to that player for each card with that name revealed this way. Search that player's graveyard, hand, and library for all cards with that name and exile them. Then that player shuffles his or her library";
public ThoughtHemorrhageEffect() {
super(Outcome.Exile);

Some files were not shown because too many files have changed in this diff Show more