Skip to content

Commit

Permalink
Catch NPE with /denizen listener command when player has no active li…
Browse files Browse the repository at this point in the history
…steners.
  • Loading branch information
aufdemrand committed Apr 9, 2013
1 parent 58fbf67 commit d5356ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/net/aufdemrand/denizen/CommandHandler.java
Expand Up @@ -730,6 +730,13 @@ public void listener(CommandContext args, CommandSender sender, NPC npc) throws

if (player == null) throw new CommandException("Specified player not online or not found!");

Map<String,AbstractListener> listeners = denizen.getListenerRegistry().getListenersFor(player);

if (listeners == null || listeners.isEmpty()) {
Messaging.send(sender, ChatColor.GREEN + player.getName() + " has no active listeners.");
return;
}

if (args.hasValueFlag("report")) {
for (AbstractListener quest : denizen.getListenerRegistry().getListenersFor(player).values())
if (quest.getListenerId().equalsIgnoreCase(args.getFlag("report")))
Expand Down Expand Up @@ -765,8 +772,6 @@ public void listener(CommandContext args, CommandSender sender, NPC npc) throws
paginator.header("Active quest listeners for " + player.getName() + ":");
paginator.addLine("<e>Key: <a>Type <b>ID");

Map<String,AbstractListener> listeners = denizen.getListenerRegistry().getListenersFor(player);

if (listeners == null || listeners.isEmpty())
paginator.addLine("None.");
else for (AbstractListener quest : listeners.values())
Expand Down

0 comments on commit d5356ff

Please sign in to comment.