forked from TuxCoding/FastLogin
Fix saving on name change
This commit is contained in:
@ -8,6 +8,8 @@
|
|||||||
* Fix skin applies for third-party plugins
|
* Fix skin applies for third-party plugins
|
||||||
* Switch to mcapi.ca for uuid lookups
|
* Switch to mcapi.ca for uuid lookups
|
||||||
* Fix BungeeCord not setting an premium uuid
|
* Fix BungeeCord not setting an premium uuid
|
||||||
|
* Fix setting skin on Cauldron
|
||||||
|
* Fix saving on name change
|
||||||
|
|
||||||
######1.6.2
|
######1.6.2
|
||||||
|
|
||||||
|
@ -155,28 +155,27 @@ public class Storage {
|
|||||||
con = dataSource.getConnection();
|
con = dataSource.getConnection();
|
||||||
|
|
||||||
UUID uuid = playerProfile.getUuid();
|
UUID uuid = playerProfile.getUuid();
|
||||||
if (playerProfile.getUserId() == -1) {
|
if (uuid != null) {
|
||||||
//User was authenticated with a premium authentication, so it's possible that the player is premium
|
//User was authenticated with a premium authentication, so it's possible that the player is premium
|
||||||
if (uuid != null) {
|
updateStmt = con.prepareStatement("UPDATE " + PREMIUM_TABLE
|
||||||
updateStmt = con.prepareStatement("UPDATE " + PREMIUM_TABLE
|
+ " SET NAME=?, LastIp=?, LastLogin=CURRENT_TIMESTAMP"
|
||||||
+ " SET NAME=?, LastIp=?, LastLogin=CURRENT_TIMESTAMP"
|
+ " WHERE UUID=?");
|
||||||
+ " WHERE UUID=? AND PREMIUM=1");
|
|
||||||
|
|
||||||
updateStmt.setString(1, playerProfile.getPlayerName());
|
updateStmt.setString(1, playerProfile.getPlayerName());
|
||||||
updateStmt.setString(2, playerProfile.getLastIp());
|
updateStmt.setString(2, playerProfile.getLastIp());
|
||||||
updateStmt.setString(3, uuid.toString().replace("-", ""));
|
updateStmt.setString(3, uuid.toString().replace("-", ""));
|
||||||
|
|
||||||
int affectedRows = updateStmt.executeUpdate();
|
int affectedRows = updateStmt.executeUpdate();
|
||||||
if (affectedRows > 0) {
|
if (affectedRows > 0) {
|
||||||
//username changed and we updated the existing database record
|
//username changed and we updated the existing database record
|
||||||
//so we don't need to run an insert
|
//so we don't need to run an insert
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerProfile.getUserId() == -1) {
|
||||||
saveStmt = con.prepareStatement("INSERT INTO " + PREMIUM_TABLE
|
saveStmt = con.prepareStatement("INSERT INTO " + PREMIUM_TABLE
|
||||||
+ " (UUID, Name, Premium, LastIp) VALUES (?, ?, ?, ?) "
|
+ " (UUID, Name, Premium, LastIp) VALUES (?, ?, ?, ?) ", Statement.RETURN_GENERATED_KEYS);
|
||||||
, Statement.RETURN_GENERATED_KEYS);
|
|
||||||
|
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
saveStmt.setString(1, null);
|
saveStmt.setString(1, null);
|
||||||
|
Reference in New Issue
Block a user