Skip to content

Commit

Permalink
Check for online players in /npc remove --owner
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 8, 2022
1 parent 98c2d34 commit 665e19d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1838,8 +1838,12 @@ public void rabbitType(CommandContext args, CommandSender sender, NPC npc) throw
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
if (args.hasValueFlag("owner")) {
String owner = args.getFlag("owner");
Player playerOwner = Bukkit.getPlayerExact(owner);
for (NPC rem : Lists.newArrayList(CitizensAPI.getNPCRegistry())) {
if (rem.getOrAddTrait(Owner.class).isOwnedBy(owner)) {
if (playerOwner != null && rem.getOrAddTrait(Owner.class).isOwnedBy(playerOwner)) {
history.add(sender, new RemoveNPCHistoryItem(rem));
rem.destroy(sender);
} else if (rem.getOrAddTrait(Owner.class).isOwnedBy(owner)) {
history.add(sender, new RemoveNPCHistoryItem(rem));
rem.destroy(sender);
}
Expand Down

0 comments on commit 665e19d

Please sign in to comment.