03.02.2015, 17:10
I have a problem with my login dialog;
I have managed to show the dialog again if the player insterted the wrong password. The dialog appears but the caption and the message are not changed.
PHP код:
DscGamemode.get().getShoebill().runOnSampThread(()->
{
InputDialog.create(player, DscGamemode.get().getEventManager())
.caption("Login for Player " + player.getName())
.message("Please enter the password for account " + player.getName())
.buttonCancel("Disconnect")
.buttonOk("Login")
.onClickOk(new DialogLogin())
.onClickCancel(abstractDialog -> player.kick())
.build()
.show();
});
public class DialogLogin implements ClickOkHandler{
public DialogLogin()
{
}
@Override
public void onClickOk(InputDialog dialog, String testo) {
Player player = dialog.getPlayer();
Utente utente = Utente.getUtente(player);
String hashPassCmp = Metodi.criptaPass(testo, utente.getSalt()); //Get the hash from inputtext and salt
if (hashPassCmp.equals(utente.getHashPass()))
{
utente.setLoggato(true); //set the user logged in
player.sendMessage(Color.LIGHTGREEN, "You succesful logged in");
}
else
{
utente.aggiungiTentativo(); //user login attempts count
dialog.setCaption("Login failed");
dialog.setMessage("You entered the wrong password.\nTry again.");
dialog.show();
}
}
}