forked from External/mage
All 1-character strings converted to primitives
"b" + "r" now changed to 'b' + 'w'. It's more straight-forward, and may cause perfomance improvements - character primitives allocation is faster and less expensive than string creation.
This commit is contained in:
parent
31589778ca
commit
f60ebfbb1f
451 changed files with 989 additions and 978 deletions
|
|
@ -483,7 +483,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
default:
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
logger.fatal("Invalid from zone [" + fromZone + "] for card [" + this.getIdName()
|
||||
+ "] source [" + (sourceObject != null ? sourceObject.getName() : "null") + "]");
|
||||
+ "] source [" + (sourceObject != null ? sourceObject.getName() : "null") + ']');
|
||||
break;
|
||||
}
|
||||
if (removed) {
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
}
|
||||
Collections.sort(cards);
|
||||
for (String name : cards) {
|
||||
sb.append(name).append(":");
|
||||
sb.append(name).append(':');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
List<List<List<DeckCardInfo>>> cardGrid = layout.getCards();
|
||||
int height = cardGrid.size();
|
||||
int width = (height > 0) ? cardGrid.get(0).size() : 0;
|
||||
out.print("(" + height + "," + width + ")");
|
||||
out.print("(" + height + ',' + width + ')');
|
||||
out.print(layout.getSettings());
|
||||
out.print("|");
|
||||
for (List<List<DeckCardInfo>> row : cardGrid) {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public class Deck implements Serializable {
|
|||
cardInfo = CardRepository.instance.findCard("Silvercoat Lion");
|
||||
Logger.getLogger(Deck.class).error("Tried to restart the DB: " + (cardInfo == null ? "not successful" : "successful"));
|
||||
}
|
||||
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + " for deck - " + deckName + "\n"
|
||||
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + " for deck - " + deckName + '\n'
|
||||
+ "Possible reason is, that you use cards in your deck, that are only supported in newer versions of the server.\n"
|
||||
+ "So it can help to use the same card from another set, that's already supported from this server.");
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ public class InvalidDeckException extends GameException {
|
|||
@Override
|
||||
public String getMessage() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.getMessage()).append("\n");
|
||||
sb.append(super.getMessage()).append('\n');
|
||||
for (Entry<String, String> entry: invalid.entrySet()) {
|
||||
sb.append(entry.getKey()).append(" ").append(entry.getValue()).append("\n");
|
||||
sb.append(entry.getKey()).append(' ').append(entry.getValue()).append('\n');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class DckDeckImporter extends DeckImporter {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
sbMessage.append("Could not find card '").append("' at line ").append(lineCount).append(": ").append(line).append("\n");
|
||||
sbMessage.append("Could not find card '").append("' at line ").append(lineCount).append(": ").append(line).append('\n');
|
||||
}
|
||||
} else if (line.startsWith("NAME:")) {
|
||||
deckList.setName(line.substring(5, line.length()));
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class DecDeckImporter extends DeckImporter {
|
|||
int num = Integer.parseInt(lineNum);
|
||||
CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(lineName, true);
|
||||
if (cardInfo == null) {
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append('\n');
|
||||
} else {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (!sideboard) {
|
||||
|
|
@ -68,7 +68,7 @@ public class DecDeckImporter extends DeckImporter {
|
|||
}
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class DekDeckImporter extends DeckImporter {
|
|||
Boolean isSideboard = "true".equals(extractAttribute(line, "Sideboard"));
|
||||
CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardName, true);
|
||||
if (cardInfo == null) {
|
||||
sbMessage.append("Could not find card: '").append(cardName).append("' at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Could not find card: '").append(cardName).append("' at line ").append(lineCount).append('\n');
|
||||
} else {
|
||||
for (int i = 0; i < cardCount; i++) {
|
||||
DeckCardInfo deckCardInfo = new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode());
|
||||
|
|
@ -35,7 +35,7 @@ public class DekDeckImporter extends DeckImporter {
|
|||
}
|
||||
}
|
||||
}catch (NumberFormatException nfe) {
|
||||
sbMessage.append("Invalid number: ").append(extractAttribute(line, "Quantity")).append(" at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Invalid number: ").append(extractAttribute(line, "Quantity")).append(" at line ").append(lineCount).append('\n');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ public class DekDeckImporter extends DeckImporter {
|
|||
private String extractAttribute(String line, String name) {
|
||||
String searchString = name+"=\"";
|
||||
int startDelim = line.indexOf(searchString)+searchString.length();
|
||||
int endDelim = line.substring(startDelim).indexOf("\"");
|
||||
int endDelim = line.substring(startDelim).indexOf('\"');
|
||||
return line.substring(startDelim, startDelim+endDelim);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class MWSDeckImporter extends DeckImporter {
|
|||
}
|
||||
|
||||
if (cardInfo == null) {
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append('\n');
|
||||
} else {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (!sideboard) {
|
||||
|
|
@ -90,7 +90,7 @@ public class MWSDeckImporter extends DeckImporter {
|
|||
}
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class TxtDeckImporter extends DeckImporter {
|
|||
int num = Integer.parseInt(lineNum.replaceAll("\\D+", ""));
|
||||
CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(lineName, true);
|
||||
if (cardInfo == null) {
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Could not find card: '").append(lineName).append("' at line ").append(lineCount).append('\n');
|
||||
} else {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (!sideboard) {
|
||||
|
|
@ -100,7 +100,7 @@ public class TxtDeckImporter extends DeckImporter {
|
|||
}
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append("\n");
|
||||
sbMessage.append("Invalid number: ").append(lineNum).append(" at line ").append(lineCount).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public class CardInfo {
|
|||
if (spellAbility != null) {
|
||||
SpellAbilityType spellAbilityType = spellAbility.getSpellAbilityType();
|
||||
if (spellAbilityType == SpellAbilityType.SPLIT_LEFT || spellAbilityType == SpellAbilityType.SPLIT_RIGHT) {
|
||||
this.className = this.setCode + "." + this.name;
|
||||
this.className = this.setCode + '.' + this.name;
|
||||
this.splitCardHalf = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ public enum CardRepository {
|
|||
try {
|
||||
String sqlName = name.toLowerCase().replaceAll("\'", "\'\'");
|
||||
GenericRawResults<CardInfo> rawResults = cardDao.queryRaw(
|
||||
"select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + "'",
|
||||
"select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'',
|
||||
cardDao.getRawRowMapper());
|
||||
List<CardInfo> result = new ArrayList<>();
|
||||
for (CardInfo cardinfo : rawResults) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue