mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-30 08:08:12 +02:00
Add --onnpc option to /npc mount
This commit is contained in:
parent
5fc1fe33db
commit
b558617c2b
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -862,13 +863,27 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "mount",
|
||||
usage = "mount (--onnpc <npc id>)",
|
||||
desc = "Mounts a controllable NPC",
|
||||
modifiers = { "mount" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.controllable")
|
||||
public void mount(CommandContext args, Player player, NPC npc) {
|
||||
public void mount(CommandContext args, Player player, NPC npc) throws CommandException {
|
||||
if (args.hasValueFlag("onnpc")) {
|
||||
NPC mount;
|
||||
try {
|
||||
UUID uuid = UUID.fromString(args.getFlag("onnpc"));
|
||||
mount = CitizensAPI.getNPCRegistry().getByUniqueId(uuid);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
mount = CitizensAPI.getNPCRegistry().getById(args.getFlagInteger("onnpc"));
|
||||
}
|
||||
if (mount == null || !mount.isSpawned()) {
|
||||
throw new CommandException(Messaging.tr(Messages.MOUNT_NPC_MUST_BE_SPAWNED, args.getFlag("onnpc")));
|
||||
}
|
||||
NMS.mount(mount.getEntity(), npc.getEntity());
|
||||
return;
|
||||
}
|
||||
boolean enabled = npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled();
|
||||
if (!enabled) {
|
||||
Messaging.sendTr(player, Messages.NPC_NOT_CONTROLLABLE, npc.getName());
|
||||
|
@ -141,6 +141,7 @@ public class Messages {
|
||||
public static final String MISSING_TRANSLATIONS = "citizens.notifications.missing-translations";
|
||||
public static final String MOBTYPE_CANNOT_BE_AGED = "citizens.commands.npc.age.cannot-be-aged";
|
||||
public static final String MONEY_WITHDRAWN = "citizens.economy.money-withdrawn";
|
||||
public static final String MOUNT_NPC_MUST_BE_SPAWNED = "citizens.commands.npc.mount.must-be-spawned";
|
||||
public static final String MOVETO_FORMAT = "citizens.commands.npc.moveto.format";
|
||||
public static final String MOVETO_TELEPORTED = "citizens.commands.npc.moveto.teleported";
|
||||
public static final String NAMEPLATE_VISIBILITY_TOGGLED = "citizens.commands.npc.nameplate.toggled";
|
||||
|
@ -66,6 +66,7 @@ citizens.commands.npc.lookclose.set=[[{0}]] will now rotate when players are nea
|
||||
citizens.commands.npc.lookclose.stopped=[[{0}]] will no longer rotate when players are nearby.
|
||||
citizens.commands.npc.minecart.set=[[{0}]] now has item [[{1}]]:[[{2}]] with offset [[{3}]].
|
||||
citizens.commands.npc.mount.failed=Couldn''t mount [[{0}]].
|
||||
citizens.commands.npc.mount.must-be-spawned=Couldn''t mount [[{0}]]. Make sure that the destination NPC ID is correct and it is spawned.
|
||||
citizens.commands.npc.moveto.format=Format is x:y:z(:world) or x y z( world).
|
||||
citizens.commands.npc.moveto.teleported=[[{0}]] teleported to [[{1}]].
|
||||
citizens.commands.npc.nameplate.toggled=Nameplate visibility toggled.
|
||||
|
Loading…
Reference in New Issue
Block a user