mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Merge pull request #2759 from sotovdev/master
We can't invoke equals method on object that can be null
This commit is contained in:
commit
0e9b46bdc1
13 changed files with 23 additions and 43 deletions
|
|
@ -16,7 +16,7 @@ public class ExpansionInfo {
|
|||
|
||||
@DatabaseField(unique = true)
|
||||
protected String name;
|
||||
@DatabaseField(unique = true)
|
||||
@DatabaseField(id = true,unique = true)
|
||||
protected String code;
|
||||
@DatabaseField
|
||||
protected String blockName;
|
||||
|
|
|
|||
|
|
@ -132,6 +132,6 @@ public class TargetSpell extends TargetObject {
|
|||
private boolean canBeChosen(StackObject stackObject, UUID sourceID, UUID sourceControllerId, Game game) {
|
||||
return stackObject instanceof Spell
|
||||
&& game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId())
|
||||
&& filter.match((Spell) stackObject, sourceID, sourceControllerId, game);
|
||||
&& filter.match(stackObject, sourceID, sourceControllerId, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
package mage.target.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
|
|
|||
|
|
@ -56,16 +56,6 @@ public class TargetOpponent extends TargetPlayer {
|
|||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
return super.canChoose(sourceId, sourceControllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetOpponent copy() {
|
||||
return new TargetOpponent(this);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class CardUtil {
|
|||
|
||||
private static final String SOURCE_EXILE_ZONE_TEXT = "SourceExileZone";
|
||||
|
||||
static String numberStrings[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
|
||||
static final String[] numberStrings = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
|
||||
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "ninteen", "twenty"};
|
||||
|
||||
public static final String[] NON_CHANGELING_SUBTYPES_VALUES = new String[]{
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||
//TODO: might have to make E extend Copyable
|
||||
|
||||
protected List<E> list = new ArrayList<>();
|
||||
protected final List<E> list = new ArrayList<>();
|
||||
|
||||
protected final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
|
|
@ -357,8 +357,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
private class CircularIterator<E> implements Iterator<E> {
|
||||
|
||||
int cursor;
|
||||
int lastIndex;
|
||||
int curModCount;
|
||||
final int lastIndex;
|
||||
final int curModCount;
|
||||
boolean hasMoved = false;
|
||||
|
||||
private CircularIterator() {
|
||||
|
|
@ -399,9 +399,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
private class CircularListIterator<E> implements ListIterator<E> {
|
||||
|
||||
int cursor;
|
||||
int lastIndex;
|
||||
int firstIndex;
|
||||
int curModCount;
|
||||
final int lastIndex;
|
||||
final int firstIndex;
|
||||
final int curModCount;
|
||||
boolean hasMoved = false;
|
||||
|
||||
private CircularListIterator() {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ import mage.target.Target;
|
|||
*/
|
||||
public class TargetAddress {
|
||||
|
||||
protected int spellAbilityIndex;
|
||||
protected UUID mode;
|
||||
protected int targetIndex;
|
||||
protected final int spellAbilityIndex;
|
||||
protected final UUID mode;
|
||||
protected final int targetIndex;
|
||||
|
||||
public TargetAddress(int spellAbilityIndex, UUID mode, int targetIndex) {
|
||||
this.spellAbilityIndex = spellAbilityIndex;
|
||||
|
|
@ -68,7 +68,7 @@ public class TargetAddress {
|
|||
|
||||
protected static class TargetAddressIterator implements Iterator<TargetAddress> {
|
||||
|
||||
protected Iterator<SpellAbility> spellAbilityIterator;
|
||||
protected final Iterator<SpellAbility> spellAbilityIterator;
|
||||
protected Integer lastSpellAbilityIndex = null;
|
||||
protected Iterator<UUID> modeIterator = null;
|
||||
protected Modes modes = null;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package mage.util;
|
|||
*/
|
||||
public class ThreadLocalStringBuilder extends ThreadLocal<StringBuilder> {
|
||||
|
||||
private int size;
|
||||
private final int size;
|
||||
|
||||
public ThreadLocalStringBuilder(int size) {
|
||||
this.size = size;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
package mage.watchers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -43,7 +42,7 @@ public class Watchers extends HashMap<String, Watcher> {
|
|||
}
|
||||
|
||||
public Watchers(final Watchers watchers) {
|
||||
watchers.entrySet().stream().forEach((entry) -> this.put(entry.getKey(), entry.getValue().copy()));
|
||||
watchers.entrySet().forEach((entry) -> this.put(entry.getKey(), entry.getValue().copy()));
|
||||
}
|
||||
|
||||
public Watchers copy() {
|
||||
|
|
@ -63,7 +62,7 @@ public class Watchers extends HashMap<String, Watcher> {
|
|||
}
|
||||
|
||||
public void reset() {
|
||||
this.values().stream().forEach(Watcher::reset);
|
||||
this.values().forEach(Watcher::reset);
|
||||
}
|
||||
|
||||
public Watcher get(String key, UUID id) {
|
||||
|
|
|
|||
|
|
@ -66,11 +66,7 @@ public class CastFromGraveyardWatcher extends Watcher {
|
|||
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone().equals(Zone.GRAVEYARD)) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell != null) {
|
||||
HashSet<Integer> zcc = spellsCastFromGraveyard.get(spell.getSourceId());
|
||||
if (zcc == null) {
|
||||
zcc = new HashSet<>();
|
||||
spellsCastFromGraveyard.put(spell.getSourceId(), zcc);
|
||||
}
|
||||
HashSet<Integer> zcc = spellsCastFromGraveyard.computeIfAbsent(spell.getSourceId(), k -> new HashSet<>());
|
||||
zcc.add(spell.getZoneChangeCounter(game));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,9 +64,4 @@ public class FirstTimeStepWatcher extends Watcher {
|
|||
condition = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue