Add /npc ai command

This commit is contained in:
fullwall 2020-10-05 15:59:14 +08:00
parent 84ec48078d
commit 8f009d5598
3 changed files with 23 additions and 0 deletions

View File

@ -171,6 +171,25 @@ public class NPCCommands {
trait.setAge(age);
}
@Command(
aliases = { "npc" },
usage = "ai (true|false)",
desc = "Sets whether the NPC should use vanilla AI",
modifiers = { "ai" },
min = 1,
max = 2,
permission = "citizens.npc.ai")
public void ai(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
boolean useAI = npc.useMinecraftAI();
if (args.argsLength() == 1) {
useAI = !useAI;
} else {
useAI = Boolean.parseBoolean(args.getString(1));
}
npc.setUseMinecraftAI(useAI);
Messaging.sendTr(sender, useAI ? Messages.USING_MINECRAFT_AI : Messages.NOT_USING_MINECRAFT_AI);
}
@Command(
aliases = { "npc" },
usage = "anchor (--save [name]|--assume [name]|--remove [name]) (-a)(-c)",

View File

@ -225,6 +225,7 @@ public class Messages {
public static final String NO_NPC_WITH_ID_FOUND = "citizens.commands.npc.spawn.missing-npc-id";
public static final String NO_STORED_SPAWN_LOCATION = "citizens.commands.npc.spawn.no-location";
public static final String NOT_LIVING_MOBTYPE = "citizens.commands.npc.create.not-living-mobtype";
public static final String NOT_USING_MINECRAFT_AI = "citizens.commands.npc.ai.stopped";
public static final String NPC_ALREADY_SELECTED = "citizens.commands.npc.select.already-selected";
public static final String NPC_ALREADY_SPAWNED = "citizens.commands.npc.spawn.already-spawned";
public static final String NPC_COMMAND_HELP = "citizens.commands.npc.command.help";
@ -364,6 +365,7 @@ public class Messages {
public static final String TROPICALFISH_PATTERN_SET = "citizens.commands.npc.tropicalfish.pattern-set";
public static final String UNKNOWN_COMMAND = "citizens.commands.unknown-command";
public static final String UNKNOWN_MATERIAL = "citizens.commands.npc.item.unknown-material";
public static final String USING_MINECRAFT_AI = "citizens.commands.npc.ai.started";
public static final String VILLAGER_LEVEL_SET = "citizens.commands.npc.villager.level-set";
public static final String VILLAGER_TYPE_SET = "citizens.commands.npc.villager.type-set";
public static final String VULNERABLE_SET = "citizens.commands.npc.vulnerable.set";

View File

@ -8,6 +8,8 @@ citizens.commands.id-not-found=Couldn''t find any NPC with ID [[{0}]].
citizens.commands.invalid.class=Invalid external commands class.
citizens.commands.invalid-mobtype=[[{0}]] is not a valid mobtype.
citizens.commands.invalid-number=That is not a valid number.
citizens.commands.npc.ai.started=Now using Minecraft AI.
citizens.commands.npc.ai.stopped=No longer using Minecraft AI.
citizens.commands.npc.age.cannot-be-aged=The mob type {0} cannot be aged.
citizens.commands.npc.age.help=Can only be used on entities that can become babies. Use the [[-l]] flag to lock age over time (note: relogs may be required to see this).
citizens.commands.npc.age.invalid-age=Invalid age. Valid ages are adult, baby, number between -24000 and 0