Fix case-sensitive poses

This commit is contained in:
fullwall 2013-02-18 08:42:43 +08:00
parent c3d98cccde
commit e0a5b03c98
3 changed files with 6 additions and 4 deletions

View File

@ -738,7 +738,7 @@ public class NPCCommands {
if (trait.addPose(args.getFlag("save"), args.getSenderLocation())) {
Messaging.sendTr(sender, Messages.POSE_ADDED);
} else
throw new CommandException(Messages.POSE_ALREADY_EXISTS, args.getFlag("assume"));
throw new CommandException(Messages.POSE_ALREADY_EXISTS, args.getFlag("save"));
} else if (args.hasValueFlag("assume")) {
String pose = args.getFlag("assume");
if (pose.isEmpty())

View File

@ -25,10 +25,11 @@ public class Poses extends Trait {
}
public boolean addPose(String name, Location location) {
name = name.toLowerCase();
Pose newPose = new Pose(name, location.getPitch(), location.getYaw());
if (poses.containsValue(newPose) || poses.containsKey(name))
return false;
poses.put(name.toLowerCase(), newPose);
poses.put(name, newPose);
return true;
}
@ -68,6 +69,7 @@ public class Poses extends Trait {
@Override
public void load(DataKey key) throws NPCLoadException {
poses.clear();
for (DataKey sub : key.getRelative("list").getIntegerSubKeys())
try {
String[] parts = sub.getString("").split(";");

View File

@ -53,9 +53,9 @@ citizens.commands.npc.pathfindingrange.set=Pathfinding range set to [[{0}]].
citizens.commands.npc.playerlist.added=Added [[{0}]] to the player list.
citizens.commands.npc.playerlist.removed=Removed [[{0}]] from the player list.
citizens.commands.npc.pose.added=Pose added.
citizens.commands.npc.pose.already-exists=The pose {0} already exists.
citizens.commands.npc.pose.already-exists=The pose [[{0}]] already exists.
citizens.commands.npc.pose.invalid-name=Invalid pose name.
citizens.commands.npc.pose.missing=The pose {1} does not exist.
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.