Skip to content
Snippets Groups Projects
Commit d7b1870e authored by Schuh Martin's avatar Schuh Martin
Browse files

Update: Minor improvements

parent 833f3ecb
No related branches found
No related tags found
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!27Player can now place bombs that have a explosion radius that dont go through the wall.,!23Update: coreMaps.json (added final mapdata to Arena1)
......@@ -2,7 +2,9 @@ package de.hdm_stuttgart.battlearena.Controller;
import de.hdm_stuttgart.battlearena.Controller.Utilities.SceneLoader;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.DatabaseException;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.ParserException;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Persistence;
import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.Parser;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
......@@ -36,11 +38,15 @@ public class LoginController {
Thread thread = new Thread(() -> {
try {
persistence.login(playerName.getText(), password.getText());
persistence.loadPlayerStatistics();
Parser.playerStatsValid(persistence.getStatistics());
Platform.runLater(() -> switchScene("MainMenu"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (DatabaseException e) {
Platform.runLater(() -> errorMessage.setText(e.getMessage()));
} catch (ParserException e) {
throw new RuntimeException(e);
}
});
......
......@@ -465,25 +465,16 @@ public class Persistence {
try {
String hash = HashGenerator.hashAndHex(password);
if (hash.equals(db.checkCredentials(userName))) {
PlayerAccount playerAccount = new PlayerAccount(userName, hash, AccountType.ONLINE);
gsonHandler.saveAccount(playerAccount);
gsonHandler.loadAccount();
db.getStatistics(userName);
Parser.playerStatsValid(statistics);
account = new PlayerAccount(userName, hash, AccountType.ONLINE);
gsonHandler.saveAccount(account);
log.info("Login successful!");
} else {
throw new DatabaseException();
throw new DatabaseException("Wrong password!");
}
}
catch (GSONException | SQLException e) {
throw new RuntimeException(e);
}
catch (DatabaseException e) {
throw new DatabaseException("Wrong password!");
}
catch (ParserException e) {
throw new DatabaseException("Player statistics data corrupted!");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment