update realName

This commit is contained in:
Xephi59 2015-08-03 18:37:42 +02:00
parent 50b41effa6
commit c1ffe47468
3 changed files with 16 additions and 2 deletions

View File

@ -588,6 +588,18 @@ public class AdminCommand implements CommandExecutor {
} catch (Exception e) {
sender.sendMessage("An error occured while trying to get that player!");
}
} else if (args[0].equalsIgnoreCase("resetname")) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
List<PlayerAuth> auths = plugin.database.getAllAuths();
for (PlayerAuth auth : auths) {
auth.setRealName("Player");
plugin.database.updateSession(auth);
}
}
});
} else {
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
}

View File

@ -70,6 +70,7 @@ public class CacheDataSource implements DataSource {
if (cache.containsKey(auth.getNickname())) {
cache.get(auth.getNickname()).setIp(auth.getIp());
cache.get(auth.getNickname()).setLastLogin(auth.getLastLogin());
cache.get(auth.getNickname()).setRealName(auth.getRealName());
}
return true;
}

View File

@ -517,10 +517,11 @@ public class MySQL implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE LOWER(" + columnName + ")=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=?, " + columnRealName + "=? WHERE LOWER(" + columnName + ")=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
pst.setString(3, auth.getRealName());
pst.setString(4, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());