More work on cities

Fixed some bugs, more work on city management terminal
This commit is contained in:
Light2
2014-06-13 03:41:07 +02:00
parent eb83dde930
commit 6eea20bf36
10 changed files with 505 additions and 184 deletions
+6 -1
View File
@@ -75,6 +75,7 @@ public class CharacterService implements INetworkDispatch {
private DatabaseConnection databaseConnection2;
private engine.resources.common.NameGen nameGenerator;
private static final String allowedCharsRegex = "['-]?[A-Za-z]('[a-zA-Z]|-[a-zA-Z]|[a-zA-Z])*['-]?$";
private static final String allowedCharsRegexWithSpace = "['-]?[A-Za-z]('[a-zA-Z]|-[a-zA-Z]|[a-zA-Z]| )*['-]?$";
public CharacterService(NGECore core) {
@@ -89,9 +90,13 @@ public class CharacterService implements INetworkDispatch {
}
public boolean checkName(String name, Client client) {
return checkName(name, client, false);
}
public boolean checkName(String name, Client client, boolean allowSpaces) {
// TODO: check for dev names, profane names, iconic names etc
try {
if(checkForDuplicateName(name, client.getAccountId()) || !name.matches(allowedCharsRegex))
if(checkForDuplicateName(name, client.getAccountId()) || (!allowSpaces && !name.matches(allowedCharsRegex)) || (allowSpaces && !name.matches(allowedCharsRegexWithSpace)))
return false;
} catch (SQLException e) {
e.printStackTrace();