style: remove some static imports

This commit is contained in:
xenohedron 2024-06-11 23:46:51 -04:00
parent d61de05eb8
commit b85d2883e3
11 changed files with 18 additions and 34 deletions

View file

@ -25,8 +25,6 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static mage.server.DisconnectReason.LostConnection;
/**
* @author BetaSteward_at_googlemail.com, JayDi85
*/
@ -456,13 +454,13 @@ public class Session {
// do not send data anymore (user must reconnect)
this.valid = false;
managerFactory.sessionManager().disconnect(sessionId, LostConnection, true);
managerFactory.sessionManager().disconnect(sessionId, DisconnectReason.LostConnection, true);
} catch (Throwable ex) {
logger.error("SESSION CALLBACK UNKNOWN EXCEPTION - " + ThreadUtils.findRootException(ex) + ", userId " + userId + ", messageId: " + call.getMessageId(), ex);
// do not send data anymore (user must reconnect)
this.valid = false;
managerFactory.sessionManager().disconnect(sessionId, LostConnection, true);
managerFactory.sessionManager().disconnect(sessionId, DisconnectReason.LostConnection, true);
} finally {
if (lockSet) {
callBackLock.unlock();

View file

@ -21,8 +21,6 @@ import mage.target.TargetPermanent;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetCreaturePermanent;
import static mage.cards.l.LostInThought.keyString;
/**
*
* @author xenohedron
@ -175,7 +173,7 @@ class LostInThoughtIgnoreEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
String key = source.getSourceId().toString() + source.getSourceObjectZoneChangeCounter() + keyString + game.getTurnNum() + ((ActivatedAbilityImpl) source).getActivatorId();
String key = source.getSourceId().toString() + source.getSourceObjectZoneChangeCounter() + LostInThought.keyString + game.getTurnNum() + ((ActivatedAbilityImpl) source).getActivatorId();
game.getState().setValue(key, true);
return true;
}

View file

@ -1,6 +1,5 @@
package mage.cards.r;
import static java.lang.Integer.min;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
@ -69,7 +68,7 @@ class RansackEffect extends OneShotEffect {
Player player = game.getPlayer(source.getFirstTarget());
FilterCard filter = new FilterCard("cards to put on the bottom of your library");
if (player != null) {
int number = min(player.getLibrary().size(), 5);
int number = Integer.min(player.getLibrary().size(), 5);
Set<Card> cards = player.getLibrary().getTopCards(game, number);
Cards cardsRemaining = new CardsImpl();
cardsRemaining.addAllCards(cards);

View file

@ -8,7 +8,6 @@ import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import static mage.cards.u.UnstableShapeshifter.filterAnotherCreature;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
@ -77,7 +76,7 @@ class UnstableShapeshifterEffect extends OneShotEffect {
if (targetCreature != null && permanent != null) {
Permanent blueprintPermanent = game.copyPermanent(Duration.Custom, targetCreature, permanent.getId(), source, new EmptyCopyApplier());
blueprintPermanent.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD,
new UnstableShapeshifterEffect(), filterAnotherCreature, false, SetTargetPointer.PERMANENT), source.getSourceId(), game);
new UnstableShapeshifterEffect(), UnstableShapeshifter.filterAnotherCreature, false, SetTargetPointer.PERMANENT), source.getSourceId(), game);
return true;
}
return false;

View file

@ -25,8 +25,6 @@ import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
import static mage.cards.v.VolrathsCurse.keyString;
/**
* @author LevelX2
*/
@ -82,7 +80,7 @@ class VolrathsCurseRestrictionEffect extends RestrictionEffect {
Permanent attachment = game.getPermanent(source.getSourceId());
if (attachment != null && attachment.getAttachedTo() != null
&& permanent.getId().equals(attachment.getAttachedTo())) {
String key = source.getSourceId().toString() + attachment.getZoneChangeCounter(game) + keyString + game.getTurnNum() + permanent.getControllerId();
String key = source.getSourceId().toString() + attachment.getZoneChangeCounter(game) + VolrathsCurse.keyString + game.getTurnNum() + permanent.getControllerId();
return game.getState().getValue(key) == null;
}
return false;
@ -132,7 +130,7 @@ class VolrathsCurseCantActivateAbilitiesEffect extends ContinuousRuleModifyingEf
if (event.getSourceId().equals(enchantment.getAttachedTo())) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (enchanted != null) {
String key = source.getSourceId().toString() + enchantment.getZoneChangeCounter(game) + keyString + game.getTurnNum() + enchanted.getControllerId();
String key = source.getSourceId().toString() + enchantment.getZoneChangeCounter(game) + VolrathsCurse.keyString + game.getTurnNum() + enchanted.getControllerId();
return game.getState().getValue(key) == null;
}
}
@ -146,7 +144,7 @@ class VolrathsCurseSpecialAction extends SpecialAction {
public VolrathsCurseSpecialAction() {
super(Zone.BATTLEFIELD);
this.addCost(new SacrificeTargetCost(StaticFilters.FILTER_PERMANENT));
this.addEffect(new VolrathsCurseIgnoreEffect(keyString));
this.addEffect(new VolrathsCurseIgnoreEffect(VolrathsCurse.keyString));
this.setMayActivate(TargetController.CONTROLLER_ATTACHED_TO);
}
@ -178,7 +176,7 @@ class VolrathsCurseIgnoreEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
String key = source.getSourceId().toString() + source.getSourceObjectZoneChangeCounter() + keyString + game.getTurnNum() + ((ActivatedAbilityImpl) source).getActivatorId();
String key = source.getSourceId().toString() + source.getSourceObjectZoneChangeCounter() + VolrathsCurse.keyString + game.getTurnNum() + ((ActivatedAbilityImpl) source).getActivatorId();
game.getState().setValue(key, true);
return true;
}

View file

@ -1,8 +1,6 @@
package mage.abilities.effects.common;
import static java.lang.Integer.min;
import java.util.UUID;
import mage.abilities.Ability;
@ -41,7 +39,7 @@ public class ReplaceOpponentCardsInHandWithSelectedEffect extends OneShotEffect
targetOpponent.putCardsOnTopOfLibrary(targetOpponent.getHand(), game, source, false);
int librarySize = targetOpponent.getLibrary().size();
int searchLibraryForNum = min(originalHandSize, librarySize);
int searchLibraryForNum = Integer.min(originalHandSize, librarySize);
TargetCardInLibrary target = new TargetCardInLibrary(searchLibraryForNum, searchLibraryForNum, new FilterCard());

View file

@ -12,8 +12,6 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static mage.cards.decks.CardNameUtil.CARD_NAME_PATTERN;
/**
* Deck import: MTGA official app
*/
@ -23,7 +21,7 @@ public class MtgaImporter extends PlainTextDeckImporter {
private static final Pattern MTGA_PATTERN = Pattern.compile(
"(\\p{Digit}+)" +
"\\p{javaWhitespace}+" +
"(" + CARD_NAME_PATTERN.pattern() + ")" +
"(" + CardNameUtil.CARD_NAME_PATTERN.pattern() + ")" +
"(?:\\p{javaWhitespace}+\\()?" +
"(\\p{Alnum}+)?" +
"(?:\\)\\p{javaWhitespace}+)?" +

View file

@ -9,6 +9,7 @@ import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.File;
@ -16,8 +17,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static javax.xml.xpath.XPathConstants.NODESET;
/**
* Deck import: helper class for all xml base formats
*/
@ -27,7 +26,7 @@ public abstract class XmlDeckImporter extends DeckImporter {
private final DocumentBuilder builder = getDocumentBuilder();
protected List<Node> getNodes(Document doc, String xpathExpression) throws XPathExpressionException {
NodeList nodes = (NodeList) xpathFactory.newXPath().evaluate(xpathExpression, doc, NODESET);
NodeList nodes = (NodeList) xpathFactory.newXPath().evaluate(xpathExpression, doc, XPathConstants.NODESET);
List<Node> list = new ArrayList<>();
for (int i = 0; i < nodes.getLength(); i++) {
list.add(nodes.item(i));

View file

@ -1,6 +1,5 @@
package mage.game;
import static java.util.Collections.emptyList;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.*;
@ -1639,7 +1638,7 @@ public class GameState implements Serializable, Copyable<GameState> {
}
public List<FilterCreaturePermanent> getActivePowerInsteadOfToughnessForDamageLethalityFilters() {
return usePowerInsteadOfToughnessForDamageLethalityFilters.isEmpty() ? emptyList() : getBattlefield().getAllActivePermanents().stream()
return usePowerInsteadOfToughnessForDamageLethalityFilters.isEmpty() ? Collections.emptyList() : getBattlefield().getAllActivePermanents().stream()
.map(Card::getId)
.filter(usePowerInsteadOfToughnessForDamageLethalityFilters::containsKey)
.map(usePowerInsteadOfToughnessForDamageLethalityFilters::get)

View file

@ -5,7 +5,6 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.constants.EnterEventType;
import static mage.constants.EnterEventType.SELF;
import mage.constants.Zone;
import mage.game.permanent.Permanent;

View file

@ -1,5 +1,6 @@
package mage.players;
import com.google.common.collect.Iterables;
import mage.MageItem;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -33,8 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import static com.google.common.collect.Iterables.getOnlyElement;
/**
* Empty player, do nothing, used for tests only
*/
@ -61,7 +60,7 @@ public class StubPlayer extends PlayerImpl {
@Override
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
UUID cardId = getOnlyElement(cards.getCards(game)).getId();
UUID cardId = Iterables.getOnlyElement(cards.getCards(game)).getId();
if (chooseScry(game, cardId)) {
target.add(cardId, game);
return true;