mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-05 15:01:26 +01:00
Add --registry arg to /npc select
This commit is contained in:
parent
0add70d397
commit
da5a611014
@ -1727,7 +1727,7 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "select|sel [id|name] (--r range)",
|
usage = "select|sel [id|name] (--r range) (--registry [name])",
|
||||||
desc = "Select a NPC with the given ID or name",
|
desc = "Select a NPC with the given ID or name",
|
||||||
modifiers = { "select", "sel" },
|
modifiers = { "select", "sel" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -1746,6 +1746,8 @@ public class NPCCommands {
|
|||||||
Messaging.sendWithNPC(sender, Setting.SELECTION_MESSAGE.asString(), toSelect);
|
Messaging.sendWithNPC(sender, Setting.SELECTION_MESSAGE.asString(), toSelect);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
NPCRegistry registry = args.hasValueFlag("registry") ? CitizensAPI.getNamedNPCRegistry(args.getFlag("registry"))
|
||||||
|
: CitizensAPI.getNPCRegistry();
|
||||||
if (args.argsLength() <= 1) {
|
if (args.argsLength() <= 1) {
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player))
|
||||||
throw new ServerCommandException();
|
throw new ServerCommandException();
|
||||||
@ -1761,15 +1763,14 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (Entity possibleNPC : search) {
|
for (Entity possibleNPC : search) {
|
||||||
NPC test = CitizensAPI.getNPCRegistry().getNPC(possibleNPC);
|
NPC test = registry.getNPC(possibleNPC);
|
||||||
if (test == null)
|
if (test == null)
|
||||||
continue;
|
continue;
|
||||||
callback.run(test);
|
callback.run(test);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NPCCommandSelector.startWithCallback(callback, CitizensAPI.getNPCRegistry(), sender, args,
|
NPCCommandSelector.startWithCallback(callback, registry, sender, args, args.getString(1));
|
||||||
args.getString(1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user