final List<DomesticAnimal> animals = player.getAnimals();
if (animals.isEmpty()) {
player.sendPrivateText("You don't own any " + curName);
} else {
DomesticAnimal animal = null;
do {
animal = player.searchAnimal(curName, false);
if (animal != null) {
// remove quotes, if present
if ((newName.charAt(0) == '\'') && (newName.charAt(newName.length() - 1) == '\'')) {
newName = newName.substring(1, newName.length() - 1);
}
newName = newName.trim();
// check only if the pet is actually named newName, rather than just recognises it
if (player.searchAnimal(newName, true) != null) {
player.sendPrivateText("You own already a pet named '" + newName + "'");
} else if (newName.length() > 0) {
if (newName.length() > 20) {
player.sendPrivateText("The new name of your pet must not be longer than 20 characters.");
} else {
final String oldName = animal.getTitle();
animal.setTitle(newName);
if (oldName != null) {
player.sendPrivateText("You changed the name of '" + oldName + "' to '" + newName
+ "'");
} else {
player.sendPrivateText("Congratulations, your " + curName + " is now called '"
+ newName + "'.");
}
new GameEvent(player.getName(), "name", animal.getRPClass().getName(), newName).raise();
}
} else {
player.sendPrivateText("Please don't use empty names.");
}
} else {