diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index bd314929..f2dc7aae 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -753,36 +753,6 @@ public class PlayerCharacter extends AbstractCharacter { public static PlayerCharacter generatePCFromCommitNewCharacterMsg(Account a, CommitNewCharacterMsg msg, ClientConnection clientConnection) { - String firstName = msg.getFirstName().trim(); - String lastName = msg.getLastName().trim(); - - if (firstName.length() < 3) { - LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_MUST_BE_LONGER, - clientConnection); - return null; - } - - // Ensure names are below required length - if (firstName.length() > 15 || lastName.length() > 15) { - LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTANDLAST_MUST_BE_SHORTER, - clientConnection); - return null; - } - - // Check if firstname is valid - if (MiscUtils.checkIfFirstNameInvalid(firstName)) { - LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_PLEASE_CHOOSE_ANOTHER_FIRSTNAME, - clientConnection); - return null; - } - - // Check if last name is valid - if (MiscUtils.checkIfLastNameInvalid(lastName)) { - LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_LASTNAME_UNAVAILABLE, - clientConnection); - return null; - } - // Verify Race int raceID = msg.getRace(); diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index e2beefd3..48bc2158 100644 --- a/src/engine/server/login/LoginServerMsgHandler.java +++ b/src/engine/server/login/LoginServerMsgHandler.java @@ -30,6 +30,7 @@ import engine.server.MBServerStatics; import engine.session.CSSession; import engine.session.Session; import engine.util.ByteUtils; +import engine.util.MiscUtils; import engine.util.StringUtils; import org.pmw.tinylog.Logger; @@ -343,12 +344,40 @@ public class LoginServerMsgHandler implements NetMsgHandler { this.sendCharacterSelectScreen(session); return; } + String firstName = commitNewCharacterMessage.getFirstName().trim(); + String lastName = commitNewCharacterMessage.getLastName().trim(); + if (firstName.length() < 3) { + LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_MUST_BE_LONGER, + clientConnection); + return; + } + + // Ensure names are below required length + if (firstName.length() > 15 || lastName.length() > 15) { + LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTANDLAST_MUST_BE_SHORTER, + clientConnection); + return; + } + + // Check if firstname is valid + if (MiscUtils.checkIfFirstNameInvalid(firstName)) { + LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_PLEASE_CHOOSE_ANOTHER_FIRSTNAME, + clientConnection); + return; + } + + // Check if last name is valid + if (MiscUtils.checkIfLastNameInvalid(lastName)) { + LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_LASTNAME_UNAVAILABLE, + clientConnection); + return; + } PlayerCharacter pc = PlayerCharacter.generatePCFromCommitNewCharacterMsg(session.getAccount(), commitNewCharacterMessage, clientConnection); if (pc == null) { Logger.info("Player returned null while creating character."); - //this.sendCharacterSelectScreen(session, true); + this.sendCharacterSelectScreen(session, true); return; } PlayerCharacter.initializePlayer(pc);