Fix set Profession, set skeletontype and set rabbittype commands

This commit is contained in:
sanjay900 2014-12-18 23:52:32 +13:00
parent 46e1ecdd2a
commit 1447380e83
2 changed files with 13 additions and 11 deletions

View File

@ -58,6 +58,7 @@ import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.StringHelper;
import net.citizensnpcs.util.Util;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.GameMode;
@ -1039,7 +1040,7 @@ public class NPCCommands {
String profession = args.getString(1);
Profession parsed = Util.matchEnum(Profession.values(), profession.toUpperCase());
if (parsed == null) {
throw new CommandException(Messages.INVALID_PROFESSION);
throw new CommandException(Messages.INVALID_PROFESSION,args.getString(1),StringUtils.join(Profession.values(), ","));
}
npc.getTrait(VillagerProfession.class).setProfession(parsed);
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
@ -1088,7 +1089,7 @@ public class NPCCommands {
aliases = { "npc" },
usage = "rabbittype [type]",
desc = "Set the Type of a Rabbit NPC",
modifiers = { "rabbittype" },
modifiers = { "rabbittype","rbtype" },
min = 2,
permission = "citizens.npc.rabbittype")
@Requirements(selected = true, ownership = true, types = { EntityType.RABBIT })
@ -1097,7 +1098,7 @@ public class NPCCommands {
try {
type = RabbitTypes.valueOf(args.getString(1).toUpperCase());
} catch (IllegalArgumentException ex) {
throw new CommandException(Messages.INVALID_RABBIT_TYPE);
throw new CommandException(Messages.INVALID_RABBIT_TYPE,StringUtils.join(RabbitTypes.values(), ","));
}
npc.getTrait(RabbitType.class).setType(type);
Messaging.sendTr(sender, Messages.RABBIT_TYPE_SET, npc.getName(), type.name());
@ -1197,9 +1198,12 @@ public class NPCCommands {
"skeletontype", "sktype" }, min = 2, max = 2, permission = "citizens.npc.skeletontype")
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
SkeletonType type = SkeletonType.valueOf(args.getString(1).toUpperCase());
if (type == null)
throw new CommandException(Messages.INVALID_SKELETON_TYPE);
SkeletonType type;
try {
type = SkeletonType.valueOf(args.getString(1).toUpperCase());
} catch (IllegalArgumentException ex) {
throw new CommandException(Messages.INVALID_SKELETON_TYPE,StringUtils.join(SkeletonType.values(), ","));
}
npc.getTrait(NPCSkeletonType.class).setType(type);
Messaging.sendTr(sender, Messages.SKELETON_TYPE_SET, npc.getName(), type);
}

View File

@ -81,9 +81,9 @@ citizens.commands.npc.pose.missing=The pose [[{0}]] does not exist.
citizens.commands.npc.pose.removed=Pose removed.
citizens.commands.npc.powered.set=[[{0}]] will now be powered.
citizens.commands.npc.powered.stopped=[[{0}]] will no longer be powered.
citizens.commands.npc.profession.invalid-profession={0} is not a valid profession.
citizens.commands.npc.profession.invalid-profession=[[{0}]] is not a valid profession. Try one of the following: [[{1}]].
citizens.commands.npc.profession.set=[[{0}]] is now a [[{1}]].
citizens.commands.npc.rabbittype.invalid-type=Invalid rabbit type.
citizens.commands.npc.rabbittype.invalid-type=Invalid rabbit type. Try one of the following: [[{0}]].
citizens.commands.npc.rabbittype.type-set=[[{0}]]''s rabbit type has been set to [[{1}]]
citizens.commands.npc.remove.incorrect-syntax=Incorrect syntax. /npc remove (all)
citizens.commands.npc.remove.removed-all=You permanently removed all NPCs.
@ -100,9 +100,7 @@ citizens.commands.npc.sound.invalid-sound=Invalid sound.
citizens.commands.npc.sound.set={0}''s sounds are now: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].
citizens.commands.npc.sound.info={0}''s sounds are: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].<br><br>Valid sounds are {4}.
citizens.commands.npc.skeletontype.set={0}''s skeleton type set to [[{1}]].
citizens.commands.npc.skeletontype.invalid-type=Invalid skeleton type.
citizens.commands.npc.rabbittype.set={0}''s rabbit type set to [[{1}]].
citizens.commands.npc.rabbittype.invalid-type=Invalid rabbit Type.
citizens.commands.npc.skeletontype.invalid-type=Invalid skeleton type. Try one of the following: [[{0}]].
citizens.commands.npc.spawn.already-spawned=[[{0}]] is already spawned at another location. Use ''/npc tphere'' to teleport the NPC to your location.
citizens.commands.npc.spawn.missing-npc-id=No NPC with the ID {0} exists.
citizens.commands.npc.spawn.no-location=No stored location available - command must be used ingame.