mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 03:57:35 +01:00
Add --registry argument to /npc list
This commit is contained in:
parent
c651c61c37
commit
41e36da000
@ -617,7 +617,7 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "list (page) ((-a) --owner (owner) --type (type) --char (char))",
|
usage = "list (page) ((-a) --owner (owner) --type (type) --char (char) --registry (name))",
|
||||||
desc = "List NPCs",
|
desc = "List NPCs",
|
||||||
flags = "a",
|
flags = "a",
|
||||||
modifiers = { "list" },
|
modifiers = { "list" },
|
||||||
@ -626,14 +626,18 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.list")
|
permission = "citizens.npc.list")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void list(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void list(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
NPCRegistry source = args.hasValueFlag("registry") ? CitizensAPI.getNamedNPCRegistry(args.getFlag("registry"))
|
||||||
|
: npcRegistry;
|
||||||
|
if (source == null)
|
||||||
|
throw new CommandException();
|
||||||
List<NPC> npcs = new ArrayList<NPC>();
|
List<NPC> npcs = new ArrayList<NPC>();
|
||||||
|
|
||||||
if (args.hasFlag('a')) {
|
if (args.hasFlag('a')) {
|
||||||
for (NPC add : npcRegistry.sorted()) {
|
for (NPC add : source.sorted()) {
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
} else if (args.getValueFlags().size() == 0 && sender instanceof Player) {
|
} else if (args.getValueFlags().size() == 0 && sender instanceof Player) {
|
||||||
for (NPC add : npcRegistry.sorted()) {
|
for (NPC add : source.sorted()) {
|
||||||
if (!npcs.contains(add) && add.getTrait(Owner.class).isOwnedBy(sender)) {
|
if (!npcs.contains(add) && add.getTrait(Owner.class).isOwnedBy(sender)) {
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
@ -641,7 +645,7 @@ public class NPCCommands {
|
|||||||
} else {
|
} else {
|
||||||
if (args.hasValueFlag("owner")) {
|
if (args.hasValueFlag("owner")) {
|
||||||
String name = args.getFlag("owner");
|
String name = args.getFlag("owner");
|
||||||
for (NPC add : npcRegistry.sorted()) {
|
for (NPC add : source.sorted()) {
|
||||||
if (!npcs.contains(add) && add.getTrait(Owner.class).isOwnedBy(name)) {
|
if (!npcs.contains(add) && add.getTrait(Owner.class).isOwnedBy(name)) {
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
@ -654,7 +658,7 @@ public class NPCCommands {
|
|||||||
if (type == null)
|
if (type == null)
|
||||||
throw new CommandException(Messages.COMMAND_INVALID_MOBTYPE, type);
|
throw new CommandException(Messages.COMMAND_INVALID_MOBTYPE, type);
|
||||||
|
|
||||||
for (NPC add : npcRegistry) {
|
for (NPC add : source) {
|
||||||
if (!npcs.contains(add) && add.getTrait(MobType.class).getType() == type)
|
if (!npcs.contains(add) && add.getTrait(MobType.class).getType() == type)
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user