int clientid = message.getClientID();
int protocolVersion = message.getProtocolVersion();
SocketChannel channel = message.getSocketChannel();
if (message instanceof MessageC2SCreateCharacter) {
MessageC2SCreateCharacter msg = (MessageC2SCreateCharacter) message;
RPObject template = msg.getTemplate();
String character = msg.getCharacter();
PlayerEntry entry = playerContainer.get(clientid);
String address = msg.getAddress().getHostAddress();
// verify event
if (!isValidEvent(msg, entry, ClientState.LOGIN_COMPLETE)) {
logger.warn("invalid create character event (client unknown, not logged in or wrong ip-address)");
return;
}
int maxNumberOfCharacters = Configuration.getConfiguration().getInt("limit_characters_per_account", Integer.MAX_VALUE);
if (entry.characterCounter >= maxNumberOfCharacters) {
Result result = Result.FAILED_TOO_MANY;
MessageS2CCreateCharacterNACK msgCreateCharacterNACK = new MessageS2CCreateCharacterNACK(channel, result);
msgCreateCharacterNACK.setClientID(clientid);
msgCreateCharacterNACK.setProtocolVersion(protocolVersion);
netMan.sendMessage(msgCreateCharacterNACK);
return;
}
createCharacter(entry.username, character, template, clientid, address, channel,
protocolVersion, true);
} else {
MessageP2SCreateCharacter msg = (MessageP2SCreateCharacter) message;
RPObject template = msg.getTemplate();
String character = msg.getCharacter();
String address = msg.getForwardedFor();
if ((msg.getCredentials() != null)
&& (msg.getCredentials().equals(Configuration.getConfiguration().get(
"proxy_credentials")))) {
createCharacter(msg.getUsername(), character, template, clientid, address,
channel, protocolVersion, false);
} else {
logger.warn("Invalid credentials for proxy method.");
}
}