Skip to content

Commit

Permalink
Add --onnpc option to /npc mount
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 31, 2016
1 parent 1b71c60 commit d44b7bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -862,13 +863,27 @@ public void minecart(CommandContext args, CommandSender sender, NPC npc) throws

@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());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/citizensnpcs/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d44b7bf

Please sign in to comment.