Skip to content

Commit

Permalink
Use uuids for sqlite and postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
garagepoort committed Sep 7, 2020
1 parent 0338592 commit 05296e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.util.UuidUtils;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
Expand All @@ -24,6 +25,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong;
import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
Expand Down Expand Up @@ -444,6 +446,8 @@ public boolean setTotpKey(String user, String totpKey) {
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
String salt = col.SALT.isEmpty() ? null : row.getString(col.SALT);
int group = col.GROUP.isEmpty() ? -1 : row.getInt(col.GROUP);
UUID uuid = col.PLAYER_UUID.isEmpty()
? null : UuidUtils.parseUuidSafely(row.getString(col.PLAYER_UUID));
return PlayerAuth.builder()
.name(row.getString(col.NAME))
.realName(row.getString(col.REAL_NAME))
Expand All @@ -461,6 +465,7 @@ private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
.locZ(row.getDouble(col.LASTLOC_Z))
.locYaw(row.getFloat(col.LASTLOC_YAW))
.locPitch(row.getFloat(col.LASTLOC_PITCH))
.uuid(uuid)
.build();
}
}
6 changes: 5 additions & 1 deletion src/main/java/fr/xephi/authme/datasource/SQLite.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fr.xephi.authme.output.ConsoleLoggerFactory;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.util.UuidUtils;

import java.io.File;
import java.sql.Connection;
Expand All @@ -21,6 +22,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong;
import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
Expand Down Expand Up @@ -366,7 +368,8 @@ public boolean setTotpKey(String user, String totpKey) {

private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
String salt = !col.SALT.isEmpty() ? row.getString(col.SALT) : null;

UUID uuid = col.PLAYER_UUID.isEmpty()
? null : UuidUtils.parseUuidSafely(row.getString(col.PLAYER_UUID));
return PlayerAuth.builder()
.name(row.getString(col.NAME))
.email(row.getString(col.EMAIL))
Expand All @@ -383,6 +386,7 @@ private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
.locWorld(row.getString(col.LASTLOC_WORLD))
.locYaw(row.getFloat(col.LASTLOC_YAW))
.locPitch(row.getFloat(col.LASTLOC_PITCH))
.uuid(uuid)
.build();
}

Expand Down

0 comments on commit 05296e5

Please sign in to comment.