mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 01:27:35 +01:00
Minor - adjust PlayerAuth builder methods
- Rename hash() to password() - Add location(Location) builder method - Replace usages of password(new EncryptedPassword(hash, salt)) to the more terse password(String, String) builder method
This commit is contained in:
parent
a3402d573f
commit
8b60c66cc8
@ -140,7 +140,7 @@ public class API {
|
|||||||
}
|
}
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.hash(encryptedPassword)
|
.password(encryptedPassword)
|
||||||
.lastLogin(0)
|
.lastLogin(0)
|
||||||
.realName(playerName)
|
.realName(playerName)
|
||||||
.build();
|
.build();
|
||||||
|
@ -155,7 +155,7 @@ public class NewAPI {
|
|||||||
}
|
}
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.hash(result)
|
.password(result)
|
||||||
.realName(playerName)
|
.realName(playerName)
|
||||||
.build();
|
.build();
|
||||||
return plugin.getDataSource().saveAuth(auth);
|
return plugin.getDataSource().saveAuth(auth);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.xephi.authme.cache.auth;
|
package fr.xephi.authme.cache.auth;
|
||||||
|
|
||||||
import fr.xephi.authme.security.crypts.EncryptedPassword;
|
import fr.xephi.authme.security.crypts.EncryptedPassword;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.firstNonNull;
|
import static com.google.common.base.Objects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -317,7 +318,7 @@ public class PlayerAuth {
|
|||||||
+ " ! LastLogin : " + lastLogin
|
+ " ! LastLogin : " + lastLogin
|
||||||
+ " ! LastPosition : " + x + "," + y + "," + z + "," + world
|
+ " ! LastPosition : " + x + "," + y + "," + z + "," + world
|
||||||
+ " ! Email : " + email
|
+ " ! Email : " + email
|
||||||
+ " ! Hash : {" + password.getHash() + ", " + password.getSalt() + "}";
|
+ " ! Password : {" + password.getHash() + ", " + password.getSalt() + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -368,7 +369,7 @@ public class PlayerAuth {
|
|||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private String name;
|
private String name;
|
||||||
private String realName;
|
private String realName;
|
||||||
private EncryptedPassword hash;
|
private EncryptedPassword password;
|
||||||
private String ip;
|
private String ip;
|
||||||
private String world;
|
private String world;
|
||||||
private String email;
|
private String email;
|
||||||
@ -381,7 +382,7 @@ public class PlayerAuth {
|
|||||||
public PlayerAuth build() {
|
public PlayerAuth build() {
|
||||||
return new PlayerAuth(
|
return new PlayerAuth(
|
||||||
checkNotNull(name),
|
checkNotNull(name),
|
||||||
firstNonNull(hash, new EncryptedPassword("")),
|
firstNonNull(password, new EncryptedPassword("")),
|
||||||
groupId,
|
groupId,
|
||||||
firstNonNull(ip, "127.0.0.1"),
|
firstNonNull(ip, "127.0.0.1"),
|
||||||
lastLogin,
|
lastLogin,
|
||||||
@ -402,13 +403,13 @@ public class PlayerAuth {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder hash(EncryptedPassword hash) {
|
public Builder password(EncryptedPassword password) {
|
||||||
this.hash = hash;
|
this.password = password;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder hash(String hash, String salt) {
|
public Builder password(String hash, String salt) {
|
||||||
return hash(new EncryptedPassword(hash, salt));
|
return password(new EncryptedPassword(hash, salt));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder ip(String ip) {
|
public Builder ip(String ip) {
|
||||||
@ -416,6 +417,14 @@ public class PlayerAuth {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder location(Location location) {
|
||||||
|
this.x = location.getX();
|
||||||
|
this.y = location.getY();
|
||||||
|
this.z = location.getZ();
|
||||||
|
this.world = location.getWorld().getName();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder locWorld(String world) {
|
public Builder locWorld(String world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
return this;
|
return this;
|
||||||
|
@ -62,7 +62,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
|
|||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(playerNameLowerCase)
|
.name(playerNameLowerCase)
|
||||||
.realName(playerName)
|
.realName(playerName)
|
||||||
.hash(encryptedPassword)
|
.password(encryptedPassword)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (!commandService.getDataSource().saveAuth(auth)) {
|
if (!commandService.getDataSource().saveAuth(auth)) {
|
||||||
|
@ -78,7 +78,7 @@ public class RakamakConverter implements Converter {
|
|||||||
.name(playerName)
|
.name(playerName)
|
||||||
.realName(playerName)
|
.realName(playerName)
|
||||||
.ip(ip)
|
.ip(ip)
|
||||||
.hash(psw)
|
.password(psw)
|
||||||
.lastLogin(System.currentTimeMillis())
|
.lastLogin(System.currentTimeMillis())
|
||||||
.build();
|
.build();
|
||||||
database.saveAuth(auth);
|
database.saveAuth(auth);
|
||||||
|
@ -6,7 +6,6 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.crypts.EncryptedPassword;
|
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
|
|
||||||
@ -41,11 +40,6 @@ public class MySQL implements DataSource {
|
|||||||
private final List<String> columnOthers;
|
private final List<String> columnOthers;
|
||||||
private HikariDataSource ds;
|
private HikariDataSource ds;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for MySQL.
|
|
||||||
*
|
|
||||||
* @throws ClassNotFoundException * @throws SQLException * @throws PoolInitializationException
|
|
||||||
*/
|
|
||||||
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
||||||
this.host = Settings.getMySQLHost;
|
this.host = Settings.getMySQLHost;
|
||||||
this.port = Settings.getMySQLPort;
|
this.port = Settings.getMySQLPort;
|
||||||
@ -98,11 +92,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setConnectionArguments.
|
|
||||||
*
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
private synchronized void setConnectionArguments() throws RuntimeException {
|
private synchronized void setConnectionArguments() throws RuntimeException {
|
||||||
ds = new HikariDataSource();
|
ds = new HikariDataSource();
|
||||||
ds.setPoolName("AuthMeMYSQLPool");
|
ds.setPoolName("AuthMeMYSQLPool");
|
||||||
@ -118,11 +107,6 @@ public class MySQL implements DataSource {
|
|||||||
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method reloadArguments.
|
|
||||||
*
|
|
||||||
* @throws RuntimeException
|
|
||||||
*/
|
|
||||||
private synchronized void reloadArguments() throws RuntimeException {
|
private synchronized void reloadArguments() throws RuntimeException {
|
||||||
if (ds != null) {
|
if (ds != null) {
|
||||||
ds.close();
|
ds.close();
|
||||||
@ -131,20 +115,10 @@ public class MySQL implements DataSource {
|
|||||||
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
|
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getConnection.
|
|
||||||
*
|
|
||||||
* @return Connection * @throws SQLException
|
|
||||||
*/
|
|
||||||
private synchronized Connection getConnection() throws SQLException {
|
private synchronized Connection getConnection() throws SQLException {
|
||||||
return ds.getConnection();
|
return ds.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setupConnection.
|
|
||||||
*
|
|
||||||
* @throws SQLException
|
|
||||||
*/
|
|
||||||
private synchronized void setupConnection() throws SQLException {
|
private synchronized void setupConnection() throws SQLException {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
Statement st = con.createStatement();
|
Statement st = con.createStatement();
|
||||||
@ -246,13 +220,6 @@ public class MySQL implements DataSource {
|
|||||||
ConsoleLogger.info("MySQL Setup finished");
|
ConsoleLogger.info("MySQL Setup finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method isAuthAvailable.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isAuthAvailable(String user) {
|
public synchronized boolean isAuthAvailable(String user) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -268,13 +235,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAuth.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized PlayerAuth getAuth(String user) {
|
public synchronized PlayerAuth getAuth(String user) {
|
||||||
PlayerAuth pAuth;
|
PlayerAuth pAuth;
|
||||||
@ -287,13 +247,11 @@ public class MySQL implements DataSource {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String salt = !columnSalt.isEmpty() ? rs.getString(columnSalt) : null;
|
String salt = !columnSalt.isEmpty() ? rs.getString(columnSalt) : null;
|
||||||
String hash = rs.getString(columnPassword);
|
|
||||||
int group = !columnGroup.isEmpty() ? rs.getInt(columnGroup) : -1;
|
int group = !columnGroup.isEmpty() ? rs.getInt(columnGroup) : -1;
|
||||||
int id = rs.getInt(columnID);
|
|
||||||
pAuth = PlayerAuth.builder()
|
pAuth = PlayerAuth.builder()
|
||||||
.name(rs.getString(columnName))
|
.name(rs.getString(columnName))
|
||||||
.realName(rs.getString(columnRealName))
|
.realName(rs.getString(columnRealName))
|
||||||
.hash(new EncryptedPassword(hash, salt))
|
.password(rs.getString(columnPassword), salt)
|
||||||
.lastLogin(rs.getLong(columnLastLogin))
|
.lastLogin(rs.getLong(columnLastLogin))
|
||||||
.ip(rs.getString(columnIp))
|
.ip(rs.getString(columnIp))
|
||||||
.locWorld(rs.getString(lastlocWorld))
|
.locWorld(rs.getString(lastlocWorld))
|
||||||
@ -313,15 +271,6 @@ public class MySQL implements DataSource {
|
|||||||
return pAuth;
|
return pAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method saveAuth.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -503,15 +452,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updatePassword.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -541,15 +481,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateSession.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updateSession(PlayerAuth auth) {
|
public synchronized boolean updateSession(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -569,15 +500,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method purgeDatabase.
|
|
||||||
*
|
|
||||||
* @param until long
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int purgeDatabase(long until) {
|
public synchronized int purgeDatabase(long until) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -593,15 +515,6 @@ public class MySQL implements DataSource {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method autoPurgeDatabase.
|
|
||||||
*
|
|
||||||
* @param until long
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<String> autoPurgeDatabase(long until) {
|
public synchronized List<String> autoPurgeDatabase(long until) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
@ -623,15 +536,6 @@ public class MySQL implements DataSource {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method removeAuth.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean removeAuth(String user) {
|
public synchronized boolean removeAuth(String user) {
|
||||||
user = user.toLowerCase();
|
user = user.toLowerCase();
|
||||||
@ -647,15 +551,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateQuitLoc.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
|
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -678,15 +573,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getIps.
|
|
||||||
*
|
|
||||||
* @param ip String
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int getIps(String ip) {
|
public synchronized int getIps(String ip) {
|
||||||
int countIp = 0;
|
int countIp = 0;
|
||||||
@ -707,15 +593,6 @@ public class MySQL implements DataSource {
|
|||||||
return countIp;
|
return countIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateEmail.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updateEmail(PlayerAuth auth) {
|
public synchronized boolean updateEmail(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -733,11 +610,6 @@ public class MySQL implements DataSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method reload.
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
try {
|
try {
|
||||||
@ -750,11 +622,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method close.
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
if (ds != null && !ds.isClosed()) {
|
if (ds != null && !ds.isClosed()) {
|
||||||
@ -762,15 +629,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuthsByName.
|
|
||||||
*
|
|
||||||
* @param auth PlayerAuth
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
@ -791,15 +649,6 @@ public class MySQL implements DataSource {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuthsByIp.
|
|
||||||
*
|
|
||||||
* @param ip String
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<String> getAllAuthsByIp(String ip) {
|
public synchronized List<String> getAllAuthsByIp(String ip) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
@ -820,15 +669,6 @@ public class MySQL implements DataSource {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuthsByEmail.
|
|
||||||
*
|
|
||||||
* @param email String
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<String> getAllAuthsByEmail(String email){
|
public synchronized List<String> getAllAuthsByEmail(String email){
|
||||||
List<String> countEmail = new ArrayList<>();
|
List<String> countEmail = new ArrayList<>();
|
||||||
@ -849,13 +689,6 @@ public class MySQL implements DataSource {
|
|||||||
return countEmail;
|
return countEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method purgeBanned.
|
|
||||||
*
|
|
||||||
* @param banned List<String>
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void purgeBanned(List<String> banned) {
|
public synchronized void purgeBanned(List<String> banned) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -871,23 +704,11 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getType.
|
|
||||||
*
|
|
||||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceType getType() {
|
public DataSourceType getType() {
|
||||||
return DataSourceType.MYSQL;
|
return DataSourceType.MYSQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method isLogged.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLogged(String user) {
|
public boolean isLogged(String user) {
|
||||||
boolean isLogged = false;
|
boolean isLogged = false;
|
||||||
@ -904,13 +725,6 @@ public class MySQL implements DataSource {
|
|||||||
return isLogged;
|
return isLogged;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setLogged.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setLogged(String user) {
|
public void setLogged(String user) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -926,13 +740,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method setUnlogged.
|
|
||||||
*
|
|
||||||
* @param user String
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setUnlogged(String user) {
|
public void setUnlogged(String user) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -948,11 +755,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method purgeLogged.
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void purgeLogged() {
|
public void purgeLogged() {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -968,13 +770,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAccountsRegistered.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getAccountsRegistered() {
|
public int getAccountsRegistered() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -993,14 +788,6 @@ public class MySQL implements DataSource {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method updateName.
|
|
||||||
*
|
|
||||||
* @param oldOne String
|
|
||||||
* @param newOne String
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void updateName(String oldOne, String newOne) {
|
public void updateName(String oldOne, String newOne) {
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection()) {
|
||||||
@ -1015,13 +802,6 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getAllAuths.
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlayerAuth> getAllAuths() {
|
public List<PlayerAuth> getAllAuths() {
|
||||||
List<PlayerAuth> auths = new ArrayList<>();
|
List<PlayerAuth> auths = new ArrayList<>();
|
||||||
@ -1035,7 +815,7 @@ public class MySQL implements DataSource {
|
|||||||
PlayerAuth pAuth = PlayerAuth.builder()
|
PlayerAuth pAuth = PlayerAuth.builder()
|
||||||
.name(rs.getString(columnName))
|
.name(rs.getString(columnName))
|
||||||
.realName(rs.getString(columnRealName))
|
.realName(rs.getString(columnRealName))
|
||||||
.hash(new EncryptedPassword(rs.getString(columnPassword), salt))
|
.password(rs.getString(columnPassword), salt)
|
||||||
.lastLogin(rs.getLong(columnLastLogin))
|
.lastLogin(rs.getLong(columnLastLogin))
|
||||||
.ip(rs.getString(columnIp))
|
.ip(rs.getString(columnIp))
|
||||||
.locWorld(rs.getString(lastlocWorld))
|
.locWorld(rs.getString(lastlocWorld))
|
||||||
@ -1058,13 +838,6 @@ public class MySQL implements DataSource {
|
|||||||
return auths;
|
return auths;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getLoggedPlayers.
|
|
||||||
*
|
|
||||||
* @return List
|
|
||||||
*
|
|
||||||
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlayerAuth> getLoggedPlayers() {
|
public List<PlayerAuth> getLoggedPlayers() {
|
||||||
List<PlayerAuth> auths = new ArrayList<>();
|
List<PlayerAuth> auths = new ArrayList<>();
|
||||||
@ -1078,7 +851,7 @@ public class MySQL implements DataSource {
|
|||||||
PlayerAuth pAuth = PlayerAuth.builder()
|
PlayerAuth pAuth = PlayerAuth.builder()
|
||||||
.name(rs.getString(columnName))
|
.name(rs.getString(columnName))
|
||||||
.realName(rs.getString(columnRealName))
|
.realName(rs.getString(columnRealName))
|
||||||
.hash(new EncryptedPassword(rs.getString(columnPassword), salt))
|
.password(rs.getString(columnPassword), salt)
|
||||||
.lastLogin(rs.getLong(columnLastLogin))
|
.lastLogin(rs.getLong(columnLastLogin))
|
||||||
.ip(rs.getString(columnIp))
|
.ip(rs.getString(columnIp))
|
||||||
.locWorld(rs.getString(lastlocWorld))
|
.locWorld(rs.getString(lastlocWorld))
|
||||||
|
@ -816,7 +816,7 @@ public class SQLite implements DataSource {
|
|||||||
.name(row.getString(columnName))
|
.name(row.getString(columnName))
|
||||||
.email(row.getString(columnEmail))
|
.email(row.getString(columnEmail))
|
||||||
.realName(row.getString(columnRealName))
|
.realName(row.getString(columnRealName))
|
||||||
.hash(row.getString(columnPassword), salt)
|
.password(row.getString(columnPassword), salt)
|
||||||
.lastLogin(row.getLong(columnLastLogin))
|
.lastLogin(row.getLong(columnLastLogin))
|
||||||
.locX(row.getDouble(lastlocX))
|
.locX(row.getDouble(lastlocX))
|
||||||
.locY(row.getDouble(lastlocY))
|
.locY(row.getDouble(lastlocY))
|
||||||
|
@ -480,10 +480,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
.locX(spawn.getX())
|
.location(spawn)
|
||||||
.locY(spawn.getY())
|
|
||||||
.locZ(spawn.getZ())
|
|
||||||
.locWorld(spawn.getWorld().getName())
|
|
||||||
.build();
|
.build();
|
||||||
plugin.getDataSource().updateQuitLoc(auth);
|
plugin.getDataSource().updateQuitLoc(auth);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class AsynchronousLogin {
|
|||||||
.ip(getIP())
|
.ip(getIP())
|
||||||
.lastLogin(new Date().getTime())
|
.lastLogin(new Date().getTime())
|
||||||
.email(email)
|
.email(email)
|
||||||
.hash(pAuth.getPassword())
|
.password(pAuth.getPassword())
|
||||||
.build();
|
.build();
|
||||||
database.updateSession(auth);
|
database.updateSession(auth);
|
||||||
|
|
||||||
|
@ -101,12 +101,9 @@ public class AsyncRegister {
|
|||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
.hash(encryptedPassword)
|
.password(encryptedPassword)
|
||||||
.ip(ip)
|
.ip(ip)
|
||||||
.locWorld(player.getLocation().getWorld().getName())
|
.location(player.getLocation())
|
||||||
.locX(player.getLocation().getX())
|
|
||||||
.locY(player.getLocation().getY())
|
|
||||||
.locZ(player.getLocation().getZ())
|
|
||||||
.email(email)
|
.email(email)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -127,12 +124,9 @@ public class AsyncRegister {
|
|||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
.hash(encryptedPassword)
|
.password(encryptedPassword)
|
||||||
.ip(ip)
|
.ip(ip)
|
||||||
.locWorld(player.getLocation().getWorld().getName())
|
.location(player.getLocation())
|
||||||
.locX(player.getLocation().getX())
|
|
||||||
.locY(player.getLocation().getY())
|
|
||||||
.locZ(player.getLocation().getZ())
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (!database.saveAuth(auth)) {
|
if (!database.saveAuth(auth)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user