Lint: fix 'declarations should use interfaces instead of classes' bugs (#11082)

This commit is contained in:
arcox 2023-08-31 13:42:45 -04:00 committed by GitHub
parent e3229d7eab
commit 2f0c1d84c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 26 deletions

View file

@ -7,7 +7,10 @@ import mage.util.CardUtil;
import mage.view.CardsView; import mage.view.CardsView;
import java.awt.*; import java.awt.*;
import java.util.*; import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
/** /**
* GUI: parameters for dialogs, uses to store useful data * GUI: parameters for dialogs, uses to store useful data
@ -102,7 +105,7 @@ public class DlgParams {
return stringList; return stringList;
} }
public void setStringList(ArrayList<String> stringList) { public void setStringList(List<String> stringList) {
this.stringList = stringList; this.stringList = stringList;
} }
@ -118,7 +121,7 @@ public class DlgParams {
return objectList; return objectList;
} }
public void setObjectList(ArrayList<Object> objectList) { public void setObjectList(List<Object> objectList) {
this.objectList = objectList; this.objectList = objectList;
} }

View file

@ -1213,7 +1213,7 @@ public class HumanPlayer extends PlayerImpl {
Zone zone = game.getState().getZone(object.getId()); Zone zone = game.getState().getZone(object.getId());
if (zone != null) { if (zone != null) {
// look at card or try to cast/activate abilities // look at card or try to cast/activate abilities
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = new LinkedHashMap<>(); Map<UUID, ActivatedAbility> useableAbilities = new LinkedHashMap<>();
Player actingPlayer = null; Player actingPlayer = null;
if (playerId.equals(game.getPriorityPlayerId())) { if (playerId.equals(game.getPriorityPlayerId())) {
@ -1559,7 +1559,7 @@ public class HumanPlayer extends PlayerImpl {
Zone zone = game.getState().getZone(object.getId()); Zone zone = game.getState().getZone(object.getId());
if (zone != null) { if (zone != null) {
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getUseableManaAbilities(object, zone, game); Map<UUID, ActivatedManaAbilityImpl> useableAbilities = getUseableManaAbilities(object, zone, game);
if (!useableAbilities.isEmpty()) { if (!useableAbilities.isEmpty()) {
// Added to ensure that mana is not being autopaid for spells that care about the color of mana being paid // Added to ensure that mana is not being autopaid for spells that care about the color of mana being paid
// See https://github.com/magefree/mage/issues/9070 // See https://github.com/magefree/mage/issues/9070
@ -2164,7 +2164,7 @@ public class HumanPlayer extends PlayerImpl {
return super.activateAbility(ability, game); return super.activateAbility(ability, game);
} }
protected void activateAbility(LinkedHashMap<UUID, ? extends ActivatedAbility> abilities, MageObject object, Game game) { protected void activateAbility(Map<UUID, ? extends ActivatedAbility> abilities, MageObject object, Game game) {
if (gameInCheckPlayableState(game)) { if (gameInCheckPlayableState(game)) {
return; return;
} }
@ -2268,7 +2268,7 @@ public class HumanPlayer extends PlayerImpl {
MageObject object = game.getObject(card.getId()); // must be object to find real abilities (example: commander) MageObject object = game.getObject(card.getId()); // must be object to find real abilities (example: commander)
if (object != null) { if (object != null) {
String message = "Choose ability to cast" + (noMana ? " for FREE" : "") + "<br>" + object.getLogName(); String message = "Choose ability to cast" + (noMana ? " for FREE" : "") + "<br>" + object.getLogName();
LinkedHashMap<UUID, SpellAbility> useableAbilities = PlayerImpl.getCastableSpellAbilities(game, playerId, object, game.getState().getZone(object.getId()), noMana); Map<UUID, SpellAbility> useableAbilities = PlayerImpl.getCastableSpellAbilities(game, playerId, object, game.getState().getZone(object.getId()), noMana);
if (useableAbilities != null if (useableAbilities != null
&& useableAbilities.size() == 1) { && useableAbilities.size() == 1) {
return useableAbilities.values().iterator().next(); return useableAbilities.values().iterator().next();

View file

@ -33,7 +33,7 @@ public class DraftController {
private final Draft draft; private final Draft draft;
private final UUID tableId; private final UUID tableId;
public DraftController(ManagerFactory managerFactory, Draft draft, ConcurrentHashMap<UUID, UUID> userPlayerMap, UUID tableId) { public DraftController(ManagerFactory managerFactory, Draft draft, ConcurrentMap<UUID, UUID> userPlayerMap, UUID tableId) {
this.managerFactory = managerFactory; this.managerFactory = managerFactory;
draftSessionId = UUID.randomUUID(); draftSessionId = UUID.randomUUID();
this.userPlayerMap = userPlayerMap; this.userPlayerMap = userPlayerMap;

View file

@ -1,6 +1,7 @@
package mage.cards.f; package mage.cards.f;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
@ -95,9 +96,9 @@ class FatalGrudgeEffect extends OneShotEffect {
class FatalGrudgePredicate implements Predicate<MageObject> { class FatalGrudgePredicate implements Predicate<MageObject> {
private final HashSet<CardType> types; private final Set<CardType> types;
public FatalGrudgePredicate(HashSet<CardType> types) { public FatalGrudgePredicate(Set<CardType> types) {
this.types = types; this.types = types;
} }

View file

@ -3209,7 +3209,7 @@ public class TestPlayer implements Player {
} }
@Override @Override
public LinkedHashMap<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game) { public Map<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game) {
return computerPlayer.getPlayableActivatedAbilities(object, zone, game); return computerPlayer.getPlayableActivatedAbilities(object, zone, game);
} }

View file

@ -144,15 +144,15 @@ public final class MtgJsonService {
private static final class AtomicCardsModel { private static final class AtomicCardsModel {
// list by card names, each name can havem multiple cards (two faces, different cards with same name from un-sets) // list by card names, each name can have multiple cards (two faces, different cards with same name from un-sets)
public HashMap<String, ArrayList<MtgJsonCard>> data; public Map<String, ArrayList<MtgJsonCard>> data;
private boolean containsSameNames(ArrayList<MtgJsonCard> list) { private boolean containsSameNames(ArrayList<MtgJsonCard> list) {
Set<String> names = list.stream().map(MtgJsonCard::getNameAsFace).collect(Collectors.toSet()); Set<String> names = list.stream().map(MtgJsonCard::getNameAsFace).collect(Collectors.toSet());
return names.size() == 1; return names.size() == 1;
} }
public HashMap<String, MtgJsonCard> prepareIndex() { public Map<String, MtgJsonCard> prepareIndex() {
HashMap<String, MtgJsonCard> index = new HashMap<>(); HashMap<String, MtgJsonCard> index = new HashMap<>();
for (Map.Entry<String, ArrayList<MtgJsonCard>> rec : data.entrySet()) { for (Map.Entry<String, ArrayList<MtgJsonCard>> rec : data.entrySet()) {
if (rec.getValue().size() == 1) { if (rec.getValue().size() == 1) {
@ -179,7 +179,7 @@ public final class MtgJsonService {
} }
private static final class AllPrintingsModel { private static final class AllPrintingsModel {
public HashMap<String, MtgJsonSet> data; public Map<String, MtgJsonSet> data;
public MtgJsonMetadata meta; public MtgJsonMetadata meta;
} }

View file

@ -9,6 +9,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Set;
/** /**
* *
@ -18,13 +19,13 @@ import java.util.EnumSet;
public class EquippedHasSupertypeCondition implements Condition { public class EquippedHasSupertypeCondition implements Condition {
private SuperType superType; private SuperType superType;
private EnumSet<SuperType> superTypes = EnumSet.noneOf(SuperType.class); // scope = Any private Set<SuperType> superTypes = EnumSet.noneOf(SuperType.class); // scope = Any
public EquippedHasSupertypeCondition(SuperType supertype) { public EquippedHasSupertypeCondition(SuperType supertype) {
this.superType = supertype; this.superType = supertype;
} }
public EquippedHasSupertypeCondition(EnumSet<SuperType> superTypes) { public EquippedHasSupertypeCondition(Set<SuperType> superTypes) {
this.superTypes = superTypes; this.superTypes = superTypes;
} }

View file

@ -811,7 +811,7 @@ public interface Player extends MageItem, Copyable<Player> {
PlayableObjectsList getPlayableObjects(Game game, Zone zone); PlayableObjectsList getPlayableObjects(Game game, Zone zone);
LinkedHashMap<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game); Map<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game);
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game); boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game);

View file

@ -1534,7 +1534,7 @@ public abstract class PlayerImpl implements Player, Serializable {
* @param noMana * @param noMana
* @return * @return
*/ */
public static LinkedHashMap<UUID, SpellAbility> getCastableSpellAbilities(Game game, UUID playerId, MageObject object, Zone zone, boolean noMana) { public static Map<UUID, SpellAbility> getCastableSpellAbilities(Game game, UUID playerId, MageObject object, Zone zone, boolean noMana) {
// it uses simple check from spellCanBeActivatedRegularlyNow // it uses simple check from spellCanBeActivatedRegularlyNow
// reason: no approved info here (e.g. forced to choose spell ability from cast card) // reason: no approved info here (e.g. forced to choose spell ability from cast card)
LinkedHashMap<UUID, SpellAbility> useable = new LinkedHashMap<>(); LinkedHashMap<UUID, SpellAbility> useable = new LinkedHashMap<>();
@ -1607,7 +1607,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
@Override @Override
public LinkedHashMap<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game) { public Map<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game) {
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>(); LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>();
// stack abilities - can't activate anything // stack abilities - can't activate anything
// spell ability - can activate additional abilities (example: "Lightning Storm") // spell ability - can activate additional abilities (example: "Lightning Storm")
@ -1634,7 +1634,7 @@ public abstract class PlayerImpl implements Player, Serializable {
return useable; return useable;
} }
protected LinkedHashMap<UUID, ActivatedManaAbilityImpl> getUseableManaAbilities(MageObject object, Zone zone, Game game) { protected Map<UUID, ActivatedManaAbilityImpl> getUseableManaAbilities(MageObject object, Zone zone, Game game) {
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>(); LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>();
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game); boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) { for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) {

View file

@ -62,10 +62,10 @@ public final class ManaUtil {
* *
* @param unpaid Mana we need to pay. Can be null (it is for X costs now). * @param unpaid Mana we need to pay. Can be null (it is for X costs now).
* @param useableAbilities List of mana abilities permanent may produce * @param useableAbilities List of mana abilities permanent may produce
* @return List of mana abilities permanent may produce and are reasonable * @return Map of mana abilities permanent may produce and are reasonable
* for unpaid mana * for unpaid mana
*/ */
public static LinkedHashMap<UUID, ActivatedManaAbilityImpl> tryToAutoPay(ManaCost unpaid, LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities) { public static Map<UUID, ActivatedManaAbilityImpl> tryToAutoPay(ManaCost unpaid, Map<UUID, ActivatedManaAbilityImpl> useableAbilities) {
// first check if we have only basic mana abilities // first check if we have only basic mana abilities
for (ActivatedManaAbilityImpl ability : useableAbilities.values()) { for (ActivatedManaAbilityImpl ability : useableAbilities.values()) {
@ -141,7 +141,7 @@ public final class ManaUtil {
return false; return false;
} }
private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> getManaAbilitiesUsingManaSymbols(LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities, ManaSymbols symbols, Mana unpaidMana) { private static Map<UUID, ActivatedManaAbilityImpl> getManaAbilitiesUsingManaSymbols(Map<UUID, ActivatedManaAbilityImpl> useableAbilities, ManaSymbols symbols, Mana unpaidMana) {
Set<ManaSymbol> countColored = new HashSet<>(); Set<ManaSymbol> countColored = new HashSet<>();
ActivatedManaAbilityImpl chosenManaAbility = null; ActivatedManaAbilityImpl chosenManaAbility = null;
@ -355,7 +355,7 @@ public final class ManaUtil {
* @param useableAbilities * @param useableAbilities
* @return * @return
*/ */
private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> getManaAbilitiesUsingMana(ManaCost unpaid, LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities) { private static Map<UUID, ActivatedManaAbilityImpl> getManaAbilitiesUsingMana(ManaCost unpaid, Map<UUID, ActivatedManaAbilityImpl> useableAbilities) {
Mana mana = unpaid.getMana(); Mana mana = unpaid.getMana();
int countColorfull = 0; int countColorfull = 0;
@ -408,7 +408,7 @@ public final class ManaUtil {
return replace(useableAbilities, chosenManaAbility); return replace(useableAbilities, chosenManaAbility);
} }
private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> replace(LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities, ActivatedManaAbilityImpl chosenManaAbility) { private static Map<UUID, ActivatedManaAbilityImpl> replace(Map<UUID, ActivatedManaAbilityImpl> useableAbilities, ActivatedManaAbilityImpl chosenManaAbility) {
// modify the map with the chosen mana ability // modify the map with the chosen mana ability
useableAbilities.clear(); useableAbilities.clear();
useableAbilities.put(chosenManaAbility.getId(), chosenManaAbility); useableAbilities.put(chosenManaAbility.getId(), chosenManaAbility);