Add /npc remove --world

This commit is contained in:
fullwall 2022-04-19 11:54:05 +08:00
parent f4e3786514
commit 733064c18d
2 changed files with 15 additions and 3 deletions

View File

@ -30,9 +30,8 @@ public class AdminCommands {
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(

View File

@ -1761,7 +1761,7 @@ public class NPCCommands {
@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,
@ -1779,6 +1779,19 @@ public class NPCCommands {
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) {