From d6506657d65cfb894a6bb558bfeb1995b7a37d37 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 15 Apr 2023 14:13:51 +0400 Subject: [PATCH] Fixed NPE --- .../target/common/TargetPermanentOrPlayer.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java index 9d08556a9d..5dd9cebcae 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java @@ -219,10 +219,22 @@ public class TargetPermanentOrPlayer extends TargetImpl { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { sb.append(permanent.getLogName()).append(' '); - } else { - Player player = game.getPlayer(targetId); - sb.append(player.getLogName()).append(' '); + continue; } + + Player player = game.getPlayer(targetId); + if (player != null) { + sb.append(player.getLogName()).append(' '); + continue; + } + + MageObject object = game.getObject(targetId); + if (object != null) { + sb.append(object.getLogName()).append(' '); + continue; + } + + sb.append("ERROR"); } return sb.toString().trim(); }