mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-05 02:10:10 +01:00
Check for online players in /npc remove --owner
This commit is contained in:
parent
98c2d3492a
commit
665e19d472
@ -1838,8 +1838,12 @@ public class NPCCommands {
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user