Allow mobs to have name length 64

This commit is contained in:
fullwall 2014-03-07 23:13:36 +08:00
parent 22759739f1
commit 4b5100b9ce

View File

@ -290,9 +290,10 @@ public class NPCCommands {
@Requirements @Requirements
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException { public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
String name = Colorizer.parseColors(args.getJoinedStrings(1).trim()); String name = Colorizer.parseColors(args.getJoinedStrings(1).trim());
if (name.length() > 16) { int nameLength = npc.getTrait(MobType.class).getType() == EntityType.PLAYER ? 16 : 64;
if (name.length() > nameLength) {
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG); Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
name = name.substring(0, 16); name = name.substring(0, nameLength);
} }
if (name.length() == 0) if (name.length() == 0)
throw new CommandException(); throw new CommandException();
@ -1069,9 +1070,10 @@ public class NPCCommands {
public void rename(CommandContext args, CommandSender sender, NPC npc) { public void rename(CommandContext args, CommandSender sender, NPC npc) {
String oldName = npc.getName(); String oldName = npc.getName();
String newName = Colorizer.parseColors(args.getJoinedStrings(1)); String newName = Colorizer.parseColors(args.getJoinedStrings(1));
if (newName.length() > 16) { int nameLength = npc.getTrait(MobType.class).getType() == EntityType.PLAYER ? 16 : 64;
if (newName.length() > nameLength) {
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG); Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
newName = newName.substring(0, 15); newName = newName.substring(0, nameLength);
} }
Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null; Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
npc.despawn(DespawnReason.PENDING_RESPAWN); npc.despawn(DespawnReason.PENDING_RESPAWN);