Skip to content

Commit

Permalink
Add /npc remove --world
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 19, 2022
1 parent f4e3786 commit 733064c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Expand Up @@ -30,9 +30,8 @@ public AdminCommands(Citizens plugin) {
public void citizens(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Messaging.send(sender, StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
Messaging.send(sender, " <7>-- <c>Author: fullwall");
Messaging.send(sender, " <7>-- <c>Source Code: http://github.com/CitizensDev");
Messaging.send(sender, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
Messaging.send(sender, " <7>-- <c>Report an issue: http://github.com/CitizensDev/Citizens2/issues");
Messaging.send(sender, " <7>-- <c>Support: https://discord.gg/Q6pZGSR");
}

@Command(
Expand Down
15 changes: 14 additions & 1 deletion main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -1761,7 +1761,7 @@ public void rabbitType(CommandContext args, CommandSender sender, NPC npc) throw

@Command(
aliases = { "npc" },
usage = "remove|rem (all|id|name| --owner [owner] | --eid [entity uuid])",
usage = "remove|rem (all|id|name| --owner [owner] | --eid [entity uuid] | --world [world])",
desc = "Remove a NPC",
modifiers = { "remove", "rem" },
min = 1,
Expand All @@ -1779,6 +1779,19 @@ public void remove(final CommandContext args, final CommandSender sender, NPC np
Messaging.sendTr(sender, Messages.NPCS_REMOVED);
return;
}
if (args.hasValueFlag("world")) {
String world = args.getFlag("world");
for (NPC rem : Lists.newArrayList(CitizensAPI.getNPCRegistry())) {
Location loc = npc.getStoredLocation();
if (loc != null && loc.getWorld() != null && (loc.getWorld().getUID().toString().equals(world)
|| loc.getWorld().getName().equalsIgnoreCase(world))) {
history.add(sender, new RemoveNPCHistoryItem(rem));
rem.destroy(sender);
}
}
Messaging.sendTr(sender, Messages.NPCS_REMOVED);
return;
}
if (args.hasValueFlag("eid")) {
Entity entity = Bukkit.getServer().getEntity(UUID.fromString(args.getFlag("eid")));
if (entity != null && (npc = CitizensAPI.getNPCRegistry().getNPC(entity)) != null) {
Expand Down

0 comments on commit 733064c

Please sign in to comment.