mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
introduced StringUtil class with .isEmpty(String input) and .isNotEmpty(String input), to replace str != null && str.length()>0 statements
This commit is contained in:
parent
fb15c79964
commit
f1cf9e7adb
47 changed files with 132 additions and 96 deletions
|
|
@ -87,6 +87,7 @@ import mage.client.util.gui.ArrowBuilder;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.remote.Session;
|
||||
import mage.util.StringUtil;
|
||||
import mage.view.AbilityView;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CounterView;
|
||||
|
|
@ -248,7 +249,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
for (String rule : getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
|
||||
if (StringUtil.isNotEmpty(card.getExpansionSetCode())) {
|
||||
sb.append("\n").append(card.getCardNumber()).append(" - ");
|
||||
sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class CardArea extends JPanel implements MouseListener {
|
|||
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
int rowsOfCards = 20;
|
||||
int columns = 1;
|
||||
if (showCards != null && showCards.size() > 0) {
|
||||
if (showCards != null && !showCards.isEmpty()) {
|
||||
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
|
||||
int count = 0;
|
||||
for (CardView card : showCards.values()) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
|||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.StringUtil;
|
||||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
import org.mage.plugins.card.images.ImageCache;
|
||||
|
|
@ -124,7 +125,7 @@ public class Permanent extends Card {
|
|||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (permanent.getOriginal().getExpansionSetCode().length() > 0) {
|
||||
if (StringUtil.isNotEmpty(permanent.getOriginal().getExpansionSetCode())) {
|
||||
sb.append("\n").append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append("\n").append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(permanent.getOriginal().getRarity().toString());
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import javax.swing.JTextField;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.util.StringUtil;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.ChatMessage.MessageType;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
|
@ -221,13 +222,13 @@ public class ChatPanelBasic extends javax.swing.JPanel {
|
|||
textColor = MESSAGE_COLOR;
|
||||
userSeparator = ": ";
|
||||
}
|
||||
if (color.equals(MessageColor.ORANGE)) {
|
||||
if (color == MessageColor.ORANGE) {
|
||||
textColor = "Orange";
|
||||
}
|
||||
if (color.equals(MessageColor.YELLOW)) {
|
||||
if (color == MessageColor.YELLOW) {
|
||||
textColor = "Yellow";
|
||||
}
|
||||
if (username != null && !username.isEmpty()) {
|
||||
if (StringUtil.isNotEmpty(username)) {
|
||||
text.append(getColoredText(userColor, username + userSeparator));
|
||||
}
|
||||
text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.CHAT)));
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class MageTextArea extends JEditorPane {
|
|||
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
|
||||
|
||||
final String basicText = ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG);
|
||||
if (text.length() > 0) {
|
||||
if (!text.isEmpty()) {
|
||||
buffer.append(basicText);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
|
||||
//text += "<br>";
|
||||
|
||||
if (text.length() > 0) {
|
||||
if (!text.isEmpty()) {
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -405,33 +405,25 @@ public class NewTableDialog extends MageDialog {
|
|||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (SessionHandler.joinTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
this.player1Panel.getPlayerName(),
|
||||
"Human", 1,
|
||||
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
|
||||
this.txtPassword.getText())) {
|
||||
for (TablePlayerPanel player : players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTable(roomId, table.getTableId())) {
|
||||
// error message must be send by the server
|
||||
SessionHandler.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
if (SessionHandler.joinTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
this.player1Panel.getPlayerName(),
|
||||
"Human", 1,
|
||||
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
|
||||
this.txtPassword.getText())) {
|
||||
for (TablePlayerPanel player : players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTable(roomId, table.getTableId())) {
|
||||
// error message must be send by the server
|
||||
SessionHandler.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.hideDialog();
|
||||
return;
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
handleError(ex);
|
||||
} catch (IOException ex) {
|
||||
handleError(ex);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
handleError(ex);
|
||||
this.hideDialog();
|
||||
return;
|
||||
}
|
||||
// JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
SessionHandler.removeTable(roomId, table.getTableId());
|
||||
|
|
|
|||
|
|
@ -2173,7 +2173,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
choices,
|
||||
this.chosenHandKey);
|
||||
|
||||
if (newChosenHandKey != null && newChosenHandKey.length() > 0) {
|
||||
if (newChosenHandKey != null && !newChosenHandKey.isEmpty()) {
|
||||
this.chosenHandKey = newChosenHandKey;
|
||||
CardsView cards = handCards.get(chosenHandKey);
|
||||
handContainer.loadCards(cards, bigCard, gameId);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
|||
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
|
||||
}
|
||||
else {
|
||||
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
|
||||
int index = Integer.parseInt(Config.defaultOtherPlayerIndex);
|
||||
cbPlayerType.setSelectedIndex(index);
|
||||
}
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
public boolean joinTable(UUID roomId, UUID tableId) {
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.MageObjectType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.util.StringUtil;
|
||||
import mage.utils.CardUtil;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CounterView;
|
||||
|
|
@ -339,7 +340,7 @@ public class GuiDisplayUtil {
|
|||
}
|
||||
|
||||
String legal = rule.toString();
|
||||
if (legal.length() > 0) {
|
||||
if (StringUtil.isNotEmpty(legal)) {
|
||||
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this" : card.getName());
|
||||
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this" : card.getName());
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.TOOLTIP));
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import mage.client.plugins.impl.Plugins;
|
|||
import mage.client.util.audio.AudioManager;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.util.StringUtil;
|
||||
import mage.view.AbilityView;
|
||||
import mage.view.CardView;
|
||||
import mage.view.PermanentView;
|
||||
|
|
@ -725,7 +726,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
for (String rule : card.getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
|
||||
if (StringUtil.isNotEmpty(card.getExpansionSetCode())) {
|
||||
sb.append("\n").append(card.getCardNumber()).append(" - ");
|
||||
sb.append(card.getExpansionSetCode()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue