mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Make Riking's stuff work
This commit is contained in:
parent
4342abca3d
commit
c85d52e594
@ -105,10 +105,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
public void saveUser(PlayerProfile profile) {
|
public void saveUser(PlayerProfile profile) {
|
||||||
checkConnected();
|
checkConnected();
|
||||||
int userId = readId(profile.getPlayerName());
|
int userId = readId(profile.getPlayerName());
|
||||||
if (userId == 0) {
|
if (userId == -1) {
|
||||||
newUser(profile.getPlayerName());
|
newUser(profile.getPlayerName());
|
||||||
userId = readId(profile.getPlayerName());
|
userId = readId(profile.getPlayerName());
|
||||||
if (userId == 0) {
|
if (userId == -1) {
|
||||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
|
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
statement.setLong(2, System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
statement.setLong(2, System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
|
||||||
int id = statement.getGeneratedKeys().getInt("id");
|
int id = readId(playerName);
|
||||||
writeMissingRows(id);
|
writeMissingRows(id);
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
@ -375,7 +375,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
int id = readId(playerName);
|
int id = readId(playerName);
|
||||||
|
|
||||||
if (id == 0) {
|
if (id == -1) {
|
||||||
// There is no such user
|
// There is no such user
|
||||||
if (create) {
|
if (create) {
|
||||||
newUser(playerName);
|
newUser(playerName);
|
||||||
@ -910,7 +910,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* @return the value in the first row / first field
|
* @return the value in the first row / first field
|
||||||
*/
|
*/
|
||||||
private int readInt(PreparedStatement statement) {
|
private int readInt(PreparedStatement statement) {
|
||||||
int result = 0;
|
int result = -1;
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
@ -1046,10 +1046,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
* Retrieve the database id for a player
|
* Retrieve the database id for a player
|
||||||
*
|
*
|
||||||
* @param playerName The name of the user to retrieve the id for
|
* @param playerName The name of the user to retrieve the id for
|
||||||
* @return the requested id or 0 if not found
|
* @return the requested id or -1 if not found
|
||||||
*/
|
*/
|
||||||
private int readId(String playerName) {
|
private int readId(String playerName) {
|
||||||
int id = 0;
|
int id = -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT id FROM " + tablePrefix + "users WHERE user = ?");
|
PreparedStatement statement = connection.prepareStatement("SELECT id FROM " + tablePrefix + "users WHERE user = ?");
|
||||||
|
Loading…
Reference in New Issue
Block a user