mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Refactor: Remove redundant boxing/unboxing to parse int primitives (#9065)
This commit is contained in:
parent
95ede50523
commit
3ae5f4979d
13 changed files with 19 additions and 19 deletions
|
|
@ -1317,7 +1317,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (arg.startsWith(PORT_ARG)) {
|
if (arg.startsWith(PORT_ARG)) {
|
||||||
startPort = Integer.valueOf(args[i + 1]);
|
startPort = Integer.parseInt(args[i + 1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (arg.startsWith(DEBUG_ARG)) {
|
if (arg.startsWith(DEBUG_ARG)) {
|
||||||
|
|
|
||||||
|
|
@ -673,7 +673,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
s.separateCreatures = Boolean.valueOf(m.group(2));
|
s.separateCreatures = Boolean.valueOf(m.group(2));
|
||||||
}
|
}
|
||||||
if (m.groupCount() > 2) {
|
if (m.groupCount() > 2) {
|
||||||
s.cardSize = Integer.valueOf(m.group(3));
|
s.cardSize = Integer.parseInt(m.group(3));
|
||||||
} else {
|
} else {
|
||||||
s.cardSize = 50;
|
s.cardSize = 50;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3361,7 +3361,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
String port = getCachedValue(KEY_PROXY_PORT, "");
|
String port = getCachedValue(KEY_PROXY_PORT, "");
|
||||||
if (!host.isEmpty() && !port.isEmpty()) {
|
if (!host.isEmpty() && !port.isEmpty()) {
|
||||||
connection.setProxyHost(host);
|
connection.setProxyHost(host);
|
||||||
connection.setProxyPort(Integer.valueOf(port));
|
connection.setProxyPort(Integer.parseInt(port));
|
||||||
String username = getCachedValue(KEY_PROXY_USERNAME, "");
|
String username = getCachedValue(KEY_PROXY_USERNAME, "");
|
||||||
connection.setProxyUsername(username);
|
connection.setProxyUsername(username);
|
||||||
if (getCachedValue(KEY_PROXY_REMEMBER, "false").equals("true")) {
|
if (getCachedValue(KEY_PROXY_REMEMBER, "false").equals("true")) {
|
||||||
|
|
@ -3620,7 +3620,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
public static int getSelectedAvatar() {
|
public static int getSelectedAvatar() {
|
||||||
try {
|
try {
|
||||||
selectedAvatarId = Integer.valueOf(MageFrame.getPreferences().get(KEY_AVATAR, String.valueOf(DEFAULT_AVATAR_ID)));
|
selectedAvatarId = Integer.parseInt(MageFrame.getPreferences().get(KEY_AVATAR, String.valueOf(DEFAULT_AVATAR_ID)));
|
||||||
} catch (NumberFormatException n) {
|
} catch (NumberFormatException n) {
|
||||||
selectedAvatarId = DEFAULT_AVATAR_ID;
|
selectedAvatarId = DEFAULT_AVATAR_ID;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ public class RegisterUserDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
connection = new Connection();
|
connection = new Connection();
|
||||||
connection.setHost(this.txtServer.getText().trim());
|
connection.setHost(this.txtServer.getText().trim());
|
||||||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
connection.setPort(Integer.parseInt(this.txtPort.getText().trim()));
|
||||||
connection.setUsername(this.txtUserName.getText().trim());
|
connection.setUsername(this.txtUserName.getText().trim());
|
||||||
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
|
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
|
||||||
connection.setEmail(this.txtEmail.getText().trim());
|
connection.setEmail(this.txtEmail.getText().trim());
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ public class ResetPasswordDialog extends MageDialog {
|
||||||
|
|
||||||
connection = new Connection();
|
connection = new Connection();
|
||||||
connection.setHost(this.txtServer.getText().trim());
|
connection.setHost(this.txtServer.getText().trim());
|
||||||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
connection.setPort(Integer.parseInt(this.txtPort.getText().trim()));
|
||||||
PreferencesDialog.setProxyInformation(connection);
|
PreferencesDialog.setProxyInformation(connection);
|
||||||
connection.setEmail(this.txtEmail.getText().trim());
|
connection.setEmail(this.txtEmail.getText().trim());
|
||||||
|
|
||||||
|
|
@ -286,7 +286,7 @@ public class ResetPasswordDialog extends MageDialog {
|
||||||
|
|
||||||
connection = new Connection();
|
connection = new Connection();
|
||||||
connection.setHost(this.txtServer.getText().trim());
|
connection.setHost(this.txtServer.getText().trim());
|
||||||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
connection.setPort(Integer.parseInt(this.txtPort.getText().trim()));
|
||||||
PreferencesDialog.setProxyInformation(connection);
|
PreferencesDialog.setProxyInformation(connection);
|
||||||
connection.setEmail(this.txtEmail.getText().trim());
|
connection.setEmail(this.txtEmail.getText().trim());
|
||||||
connection.setAuthToken(this.txtAuthToken.getText().trim());
|
connection.setAuthToken(this.txtAuthToken.getText().trim());
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ public class ConnectDialog extends JDialog {
|
||||||
JOptionPane.showMessageDialog(rootPane, "Please provide a port number");
|
JOptionPane.showMessageDialog(rootPane, "Please provide a port number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Integer.valueOf(txtPort.getText()) < 1 || Integer.valueOf(txtPort.getText()) > 65535) {
|
if (Integer.parseInt(txtPort.getText()) < 1 || Integer.parseInt(txtPort.getText()) > 65535) {
|
||||||
JOptionPane.showMessageDialog(rootPane, "Invalid port number");
|
JOptionPane.showMessageDialog(rootPane, "Invalid port number");
|
||||||
txtPort.setText(ConsoleFrame.getPreferences().get("serverPort", Integer.toString(17171)));
|
txtPort.setText(ConsoleFrame.getPreferences().get("serverPort", Integer.toString(17171)));
|
||||||
return;
|
return;
|
||||||
|
|
@ -350,13 +350,13 @@ public class ConnectDialog extends JDialog {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
connection = new Connection();
|
connection = new Connection();
|
||||||
connection.setHost(this.txtServer.getText());
|
connection.setHost(this.txtServer.getText());
|
||||||
connection.setPort(Integer.valueOf(this.txtPort.getText()));
|
connection.setPort(Integer.parseInt(this.txtPort.getText()));
|
||||||
connection.setAdminPassword(new String(txtPassword.getPassword()));
|
connection.setAdminPassword(new String(txtPassword.getPassword()));
|
||||||
connection.setUsername("Admin");
|
connection.setUsername("Admin");
|
||||||
connection.setProxyType((ProxyType) this.cbProxyType.getSelectedItem());
|
connection.setProxyType((ProxyType) this.cbProxyType.getSelectedItem());
|
||||||
if (!this.cbProxyType.getSelectedItem().equals(ProxyType.NONE)) {
|
if (!this.cbProxyType.getSelectedItem().equals(ProxyType.NONE)) {
|
||||||
connection.setProxyHost(this.txtProxyServer.getText());
|
connection.setProxyHost(this.txtProxyServer.getText());
|
||||||
connection.setProxyPort(Integer.valueOf(this.txtProxyPort.getText()));
|
connection.setProxyPort(Integer.parseInt(this.txtProxyPort.getText()));
|
||||||
connection.setProxyUsername(this.txtProxyUserName.getText());
|
connection.setProxyUsername(this.txtProxyUserName.getText());
|
||||||
connection.setProxyPassword(new String(this.txtPasswordField.getPassword()));
|
connection.setProxyPassword(new String(this.txtPasswordField.getPassword()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
|
||||||
Collections.sort(list, new Comparator<Combat>() {
|
Collections.sort(list, new Comparator<Combat>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Combat o1, Combat o2) {
|
public int compare(Combat o1, Combat o2) {
|
||||||
return Integer.valueOf(o2.getGroups().size()).compareTo(Integer.valueOf(o1.getGroups().size()));
|
return Integer.valueOf(o2.getGroups().size()).compareTo(o1.getGroups().size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ public class MCTSNode {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while(playablesIterator.hasNext()) {
|
while(playablesIterator.hasNext()) {
|
||||||
String next = playablesIterator.next();
|
String next = playablesIterator.next();
|
||||||
int cacheTurn = Integer.valueOf(next.split(":", 2)[0].substring(1));
|
int cacheTurn = Integer.parseInt(next.split(":", 2)[0].substring(1));
|
||||||
if (cacheTurn < turnNum) {
|
if (cacheTurn < turnNum) {
|
||||||
playablesIterator.remove();
|
playablesIterator.remove();
|
||||||
count++;
|
count++;
|
||||||
|
|
@ -518,7 +518,7 @@ public class MCTSNode {
|
||||||
Set<String> attacksKeys = attacksCache.keySet();
|
Set<String> attacksKeys = attacksCache.keySet();
|
||||||
Iterator<String> attacksIterator = attacksKeys.iterator();
|
Iterator<String> attacksIterator = attacksKeys.iterator();
|
||||||
while(attacksIterator.hasNext()) {
|
while(attacksIterator.hasNext()) {
|
||||||
int cacheTurn = Integer.valueOf(attacksIterator.next().split(":", 2)[0].substring(1));
|
int cacheTurn = Integer.parseInt(attacksIterator.next().split(":", 2)[0].substring(1));
|
||||||
if (cacheTurn < turnNum) {
|
if (cacheTurn < turnNum) {
|
||||||
attacksIterator.remove();
|
attacksIterator.remove();
|
||||||
count++;
|
count++;
|
||||||
|
|
@ -528,7 +528,7 @@ public class MCTSNode {
|
||||||
Set<String> blocksKeys = blocksCache.keySet();
|
Set<String> blocksKeys = blocksCache.keySet();
|
||||||
Iterator<String> blocksIterator = blocksKeys.iterator();
|
Iterator<String> blocksIterator = blocksKeys.iterator();
|
||||||
while(blocksIterator.hasNext()) {
|
while(blocksIterator.hasNext()) {
|
||||||
int cacheTurn = Integer.valueOf(blocksIterator.next().split(":", 2)[0].substring(1));
|
int cacheTurn = Integer.parseInt(blocksIterator.next().split(":", 2)[0].substring(1));
|
||||||
if (cacheTurn < turnNum) {
|
if (cacheTurn < turnNum) {
|
||||||
blocksIterator.remove();
|
blocksIterator.remove();
|
||||||
count++;
|
count++;
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ class ElementalResonanceEffect extends OneShotEffect {
|
||||||
Integer generic = 0;
|
Integer generic = 0;
|
||||||
for (String str : Arrays.asList(manaString.replaceAll("[^-?0-9]+", " ").trim().split(" "))) {
|
for (String str : Arrays.asList(manaString.replaceAll("[^-?0-9]+", " ").trim().split(" "))) {
|
||||||
if (!str.equals("")) {
|
if (!str.equals("")) {
|
||||||
generic += Integer.valueOf(str);
|
generic += Integer.parseInt(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.setColorless(generic);
|
out.setColorless(generic);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,6 @@ class FirstComeFirstServedPredicate implements Predicate<Permanent> {
|
||||||
String str = input.getCardNumber();
|
String str = input.getCardNumber();
|
||||||
Matcher matcher = Pattern.compile("\\d+").matcher(str);
|
Matcher matcher = Pattern.compile("\\d+").matcher(str);
|
||||||
matcher.find();
|
matcher.find();
|
||||||
return Integer.valueOf(matcher.group());
|
return Integer.parseInt(matcher.group());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ public class TestPlayer implements Player {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (indexedMatcher.matches()) {
|
if (indexedMatcher.matches()) {
|
||||||
filteredName = indexedMatcher.group(1);
|
filteredName = indexedMatcher.group(1);
|
||||||
index = Integer.valueOf(indexedMatcher.group(2));
|
index = Integer.parseInt(indexedMatcher.group(2));
|
||||||
}
|
}
|
||||||
filter.add(new NamePredicate(filteredName, true)); // must find any cards even without names
|
filter.add(new NamePredicate(filteredName, true)); // must find any cards even without names
|
||||||
List<Permanent> allPermanents = game.getBattlefield().getAllActivePermanents(filter, controllerID, game);
|
List<Permanent> allPermanents = game.getBattlefield().getAllActivePermanents(filter, controllerID, game);
|
||||||
|
|
|
||||||
|
|
@ -1616,7 +1616,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (indexedMatcher.matches()) {
|
if (indexedMatcher.matches()) {
|
||||||
cardName = indexedMatcher.group(1);
|
cardName = indexedMatcher.group(1);
|
||||||
index = Integer.valueOf(indexedMatcher.group(2));
|
index = Integer.parseInt(indexedMatcher.group(2));
|
||||||
}
|
}
|
||||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||||
if (permanent.getName().equals(cardName)) {
|
if (permanent.getName().equals(cardName)) {
|
||||||
|
|
|
||||||
|
|
@ -459,7 +459,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
}
|
}
|
||||||
if (symbol.length() == 1 || isNumeric(symbol)) {
|
if (symbol.length() == 1 || isNumeric(symbol)) {
|
||||||
if (Character.isDigit(symbol.charAt(0))) {
|
if (Character.isDigit(symbol.charAt(0))) {
|
||||||
this.add(new GenericManaCost(Integer.valueOf(symbol)));
|
this.add(new GenericManaCost(Integer.parseInt(symbol)));
|
||||||
} else if (symbol.equals("S")) {
|
} else if (symbol.equals("S")) {
|
||||||
this.add(new SnowManaCost());
|
this.add(new SnowManaCost());
|
||||||
} else if (symbol.equals("C")) {
|
} else if (symbol.equals("C")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue