Cleanup part 2.

This commit is contained in:
KrewsOrg 2020-04-30 14:37:42 +01:00
parent a71853d0c2
commit 649005cb90

View File

@ -13,13 +13,10 @@ public class CheckPetNameEvent extends MessageHandler {
public void handle() throws Exception {
String petName = this.packet.readString();
int minLength = Emulator.getConfig().getInt("hotel.pets.name.length.min");
int maxLength = Emulator.getConfig().getInt("hotel.pets.name.length.max");
if (petName.length() < PET_NAME_LENGTH_MINIMUM) {
this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_TO_SHORT, minLength + ""));
} else if (petName.length() > maxLength) {
this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_TO_LONG, maxLength + ""));
this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_TO_SHORT, PET_NAME_LENGTH_MINIMUM + ""));
} else if (petName.length() > PET_NAME_LENGTH_MAXIMUM) {
this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.NAME_TO_LONG, PET_NAME_LENGTH_MAXIMUM + ""));
} else if (!StringUtils.isAlphanumeric(petName)) {
this.client.sendResponse(new PetNameErrorComposer(PetNameErrorComposer.FORBIDDEN_CHAR, petName));
} else {