From 922e35ff1cd1d4b647bed1a72aedcebb8dbed6da Mon Sep 17 00:00:00 2001 From: magenoxx Date: Thu, 2 Oct 2014 12:17:25 +0400 Subject: [PATCH] Fixed NPE in tooltips for Emblem choose-trigger --- .../mage/client/util/gui/GuiDisplayUtil.java | 19 ++++++++----------- Mage.Common/src/mage/view/CardView.java | 3 +-- Mage/src/mage/constants/MageObjectType.java | 3 ++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java index 8ac61b8732..c3075ed050 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java @@ -1,24 +1,19 @@ package mage.client.util.gui; -import java.awt.*; -import java.util.ArrayList; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.SwingConstants; -import mage.client.cards.Permanent; - import mage.constants.CardType; import mage.constants.MageObjectType; import mage.utils.CardUtil; import mage.view.CardView; import mage.view.CounterView; import mage.view.PermanentView; - import org.jdesktop.swingx.JXPanel; import org.mage.card.arcane.ManaSymbols; import org.mage.card.arcane.UI; +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + public class GuiDisplayUtil { private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15); private static final Insets DEFAULT_INSETS = new Insets(0, 0, 70, 25); @@ -228,8 +223,10 @@ public class GuiDisplayUtil { buffer.append("[only controlled] "); } } - buffer.append(card.getMageObjectType().toString()).append(""); - buffer.append(""); + if (!card.getMageObjectType().equals(MageObjectType.NULL)) { + buffer.append(card.getMageObjectType().toString()); + } + buffer.append(""); StringBuilder rule = new StringBuilder("
"); if (card.isSplitCard()) { diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index ccb8bf7a72..352589f098 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -50,7 +50,6 @@ import mage.target.Targets; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.game.permanent.PermanentCard; /** * @author BetaSteward_at_googlemail.com @@ -73,7 +72,7 @@ public class CardView extends SimpleCardView { protected int convertedManaCost; protected Rarity rarity; - protected MageObjectType mageObjectType; + protected MageObjectType mageObjectType = MageObjectType.NULL; protected boolean isAbility; protected AbilityType abilityType; diff --git a/Mage/src/mage/constants/MageObjectType.java b/Mage/src/mage/constants/MageObjectType.java index 05fc18383f..1a7edd8322 100644 --- a/Mage/src/mage/constants/MageObjectType.java +++ b/Mage/src/mage/constants/MageObjectType.java @@ -32,7 +32,8 @@ public enum MageObjectType { SPELL ("Spell", false, true), PERMANENT ("Permanent", true, true), EMBLEM ("Emblem", false, false), - COMMANDER ("Commander", false, false); + COMMANDER ("Commander", false, false), + NULL("NullObject", false, false); private final String text; private final boolean permanent;