Remove forum integration, save the account file into a folder in the server. Upon login, load the password and check if it matches the password from the account file. If it doesn't, don't allow a login, otherwise allow the login.
Example of how I get the login result for a player attempting a login. This is just the way I have done it in the past, works without any problems & bugs. You may wish to use any other parsing you like. I used json in this case.
Code:
@Override
public LoginResult getLoginResult(PlayerDetails playerDetails) {
/**
* The return code, default set to a successful login.
*/
int returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
/**
* The registeree currently, is nobody.
*/
Player registeree = null;
/**
* Check if the player actually exists.
* If it does, read their account password from their file.
* If its equal to their entered password, allow them to login.
* Otherwise return the code for the invalid username or password.
* Also check for any punishments which needs to prevent login such as ban.
*/
if (exists(playerDetails.getLoginName())) {
JsonObject obj = null;
Gson builder = new GsonBuilder().setPrettyPrinting().create();
try {
obj = new JsonParser().parse(new FileReader(
new File(SAVE_PATH, playerDetails.getLoginName() + EXTENSION))).getAsJsonObject();
} catch (JsonIOException | JsonSyntaxException | FileNotFoundException e) {
e.printStackTrace();
returnCode = LoginConstants.ERROR_LOADING_PROFILE.getReturnCode();
}
/**
* Check if the account has a punishment on it.
* These punishments are the ones which affect login.
*/
Punishment punishment = builder.fromJson(obj.get("punishment"), Punishment.class) == null ? Punishment.NONE :
builder.fromJson(obj.get("punishment"), Punishment.class);
switch(punishment) {
case BAN:
returnCode = LoginConstants.ACCOUNT_BANNED.getReturnCode();
break;
case IP_BAN:
returnCode = LoginConstants.COMPUTER_ADDRESS_BLOCKED.getReturnCode();
break;
case LOCK:
returnCode = LoginConstants.ACCOUNT_LOCKED.getReturnCode();
break;
case PERMANENT_BAN:
returnCode = LoginConstants.ACCOUNT_BANNED.getReturnCode();
break;
case NONE:
returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
break;
default:
returnCode = LoginConstants.LOGIN_SUCCESS.getReturnCode();
break;
}
/**
* Check if the account is already logged on.
*/
if (Game.getWorld().getPlayerInGame(playerDetails.getLoginName(), true) != null)
returnCode = LoginConstants.ALREADY_ONLINE.getReturnCode();
/**
* Read the player's actual password from their account file.
*/
String password = obj.get("password").getAsString();
/**
* Compare the actual password to the password entered.
* If it isn't correct, notify.
*/
if (!playerDetails.getPassword().equalsIgnoreCase(password)) {
returnCode = LoginConstants.INVALID_USERNAME_OR_PASSWORD.getReturnCode();
}
}
/**
* If the player doesn't exist, create the new player.
*/
if (returnCode == LoginConstants.CONNECTION_ID.getReturnCode() || returnCode == LoginConstants.LOGIN_SUCCESS.getReturnCode()) {
registeree = new Player(playerDetails);
registeree.setCreatedDate(registeree.getCreationDate());
}
return new LoginResult(registeree, returnCode);
}
In the login decoder, you could have something like this (please note this is not entirely done, I have removed most of the code since I won't spoon feed you it) :
Code:
/**
* Loads the player by the details they've entered.
* @param details
* @param loggingIntoLobby
*/
public void loadPlayer(final PlayerDetails details, final boolean loggingIntoLobby) {
/**
* Check the login result.
*/
LoginResult loginResult = persistence.getLoginResult(details);
Player player = loginResult.getPlayer();
PacketBuilder bldr = new PacketBuilder();
bldr.writeByte(loginResult.getReturnCode());
/**
* Write the login result return code.
*/
details.getChannel().write(bldr.buildPacket());
/**
* If it is a successful login.
*/
if (loginResult.getReturnCode() == LoginConstants.LOGIN_SUCCESS.getReturnCode()) {
/**
* Set if the player is in lobby or not.
*/
player.setIsInLobby(loggingIntoLobby);
/**
* Register the player into the required network.
* Whether it is the lobby or directly into the game.
*/
if (loggingIntoLobby) {
//Do this part yourself.
} else {
//Do this part yourself.
}
}
}