Replace all '/' in path to File.separator - Code Refactor

This commit is contained in:
Xephi
2014-08-25 03:12:28 +02:00
parent 12795436a0
commit d7cb60c1fe
104 changed files with 2470 additions and 3690 deletions
@@ -22,7 +22,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean isAuthAvailable(String user) {
if (cache.containsKey(user.toLowerCase())) return true;
if (cache.containsKey(user.toLowerCase()))
return true;
return source.isAuthAvailable(user.toLowerCase());
}
@@ -32,7 +33,8 @@ public class CacheDataSource implements DataSource {
return cache.get(user.toLowerCase());
} else {
PlayerAuth auth = source.getAuth(user.toLowerCase());
if (auth != null) cache.put(user.toLowerCase(), auth);
if (auth != null)
cache.put(user.toLowerCase(), auth);
return auth;
}
}
@@ -49,8 +51,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
if (source.updatePassword(auth)) {
if (cache.containsKey(auth.getNickname().toLowerCase())) cache.get(
auth.getNickname()).setHash(auth.getHash());
if (cache.containsKey(auth.getNickname().toLowerCase()))
cache.get(auth.getNickname()).setHash(auth.getHash());
return true;
}
return false;
@@ -147,8 +149,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updateEmail(PlayerAuth auth) {
if (source.updateEmail(auth)) {
if (cache.containsKey(auth.getNickname().toLowerCase())) cache.get(
auth.getNickname()).setEmail(auth.getEmail());
if (cache.containsKey(auth.getNickname().toLowerCase()))
cache.get(auth.getNickname()).setEmail(auth.getEmail());
return true;
}
return false;
@@ -157,8 +159,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updateSalt(PlayerAuth auth) {
if (source.updateSalt(auth)) {
if (cache.containsKey(auth.getNickname().toLowerCase())) cache.get(
auth.getNickname()).setSalt(auth.getSalt());
if (cache.containsKey(auth.getNickname().toLowerCase()))
cache.get(auth.getNickname()).setSalt(auth.getSalt());
return true;
}
return false;
@@ -8,7 +8,9 @@ public interface DataSource {
public enum DataSourceType {
MYSQL, FILE, SQLITE
MYSQL,
FILE,
SQLITE
}
boolean isAuthAvailable(String user);
@@ -42,8 +42,8 @@ public class FlatFileThread extends Thread implements DataSource {
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@@ -85,11 +85,7 @@ public class FlatFileThread extends Thread implements DataSource {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(source, true));
bw.write(auth.getNickname() + ":" + auth.getHash() + ":"
+ auth.getIp() + ":" + auth.getLastLogin() + ":"
+ auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":"
+ auth.getQuitLocZ() + ":" + auth.getWorld() + ":"
+ auth.getEmail() + "\n");
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n");
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
@@ -119,46 +115,23 @@ public class FlatFileThread extends Thread implements DataSource {
if (args[0].equals(auth.getNickname())) {
switch (args.length) {
case 4: {
newAuth = new PlayerAuth(args[0], auth.getHash(),
args[2], Long.parseLong(args[3]), 0, 0, 0,
"world", "your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 7: {
newAuth = new PlayerAuth(args[0], auth.getHash(),
args[2], Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), "world",
"your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 8: {
newAuth = new PlayerAuth(args[0], auth.getHash(),
args[2], Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
"your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 9: {
newAuth = new PlayerAuth(args[0], auth.getHash(),
args[2], Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
args[8], API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
break;
}
default: {
newAuth = new PlayerAuth(args[0], auth.getHash(),
args[2], 0, 0, 0, 0, "world",
"your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
}
@@ -199,46 +172,23 @@ public class FlatFileThread extends Thread implements DataSource {
if (args[0].equals(auth.getNickname())) {
switch (args.length) {
case 4: {
newAuth = new PlayerAuth(args[0], args[1],
auth.getIp(), auth.getLastLogin(), 0, 0, 0,
"world", "your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 7: {
newAuth = new PlayerAuth(args[0], args[1],
auth.getIp(), auth.getLastLogin(),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), "world",
"your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 8: {
newAuth = new PlayerAuth(args[0], args[1],
auth.getIp(), auth.getLastLogin(),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
"your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 9: {
newAuth = new PlayerAuth(args[0], args[1],
auth.getIp(), auth.getLastLogin(),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
args[8], API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
break;
}
default: {
newAuth = new PlayerAuth(args[0], args[1],
auth.getIp(), auth.getLastLogin(), 0, 0, 0,
"world", "your@email.com",
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
}
@@ -277,11 +227,7 @@ public class FlatFileThread extends Thread implements DataSource {
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
newAuth = new PlayerAuth(args[0], args[1], args[2],
Long.parseLong(args[3]), auth.getQuitLocX(),
auth.getQuitLocY(), auth.getQuitLocZ(),
auth.getWorld(), auth.getEmail(),
API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), auth.getEmail(), API.getPlayerRealName(args[0]));
break;
}
}
@@ -481,40 +427,17 @@ public class FlatFileThread extends Thread implements DataSource {
if (args[0].equals(user)) {
switch (args.length) {
case 2:
return new PlayerAuth(args[0], args[1],
"198.18.0.1", 0, "your@email.com",
API.getPlayerRealName(args[0]));
return new PlayerAuth(args[0], args[1], "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(args[0]));
case 3:
return new PlayerAuth(args[0], args[1], args[2], 0,
"your@email.com",
API.getPlayerRealName(args[0]));
return new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com", API.getPlayerRealName(args[0]));
case 4:
return new PlayerAuth(args[0], args[1], args[2],
Long.parseLong(args[3]), "your@email.com",
API.getPlayerRealName(args[0]));
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com", API.getPlayerRealName(args[0]));
case 7:
return new PlayerAuth(args[0], args[1], args[2],
Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]),
"unavailableworld", "your@email.com",
API.getPlayerRealName(args[0]));
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "unavailableworld", "your@email.com", API.getPlayerRealName(args[0]));
case 8:
return new PlayerAuth(args[0], args[1], args[2],
Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
"your@email.com",
API.getPlayerRealName(args[0]));
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
case 9:
return new PlayerAuth(args[0], args[1], args[2],
Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
args[8], API.getPlayerRealName(args[0]));
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
}
}
}
@@ -556,12 +479,7 @@ public class FlatFileThread extends Thread implements DataSource {
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
newAuth = new PlayerAuth(args[0], args[1], args[2],
Long.parseLong(args[3]),
Double.parseDouble(args[4]),
Double.parseDouble(args[5]),
Double.parseDouble(args[6]), args[7],
auth.getEmail(), API.getPlayerRealName(args[0]));
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], auth.getEmail(), API.getPlayerRealName(args[0]));
break;
}
}
@@ -69,6 +69,7 @@ public class MiniConnectionPoolManager {
* no free connection becomes available within <code>timeout</code> seconds.
*/
public static class TimeoutException extends RuntimeException {
private static final long serialVersionUID = 1;
public TimeoutException() {
@@ -168,8 +169,7 @@ public class MiniConnectionPoolManager {
// block.
synchronized (this) {
if (isDisposed) {
throw new IllegalStateException(
"Connection pool has been disposed.");
throw new IllegalStateException("Connection pool has been disposed.");
}
}
try {
@@ -177,8 +177,7 @@ public class MiniConnectionPoolManager {
throw new TimeoutException();
}
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupted while waiting for a database connection.", e);
throw new RuntimeException("Interrupted while waiting for a database connection.", e);
}
boolean ok = false;
try {
@@ -194,8 +193,7 @@ public class MiniConnectionPoolManager {
private synchronized Connection getConnection3() throws SQLException {
if (isDisposed) {
throw new IllegalStateException(
"Connection pool has been disposed.");
throw new IllegalStateException("Connection pool has been disposed.");
}
PooledConnection pconn;
if (!recycledConnections.isEmpty()) {
@@ -260,15 +258,12 @@ public class MiniConnectionPoolManager {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupted while waiting for a valid database connection.",
e);
throw new RuntimeException("Interrupted while waiting for a valid database connection.", e);
}
}
time = System.currentTimeMillis();
if (time >= timeoutTime) {
throw new TimeoutException(
"Timeout while waiting for a valid database connection.");
throw new TimeoutException("Timeout while waiting for a valid database connection.");
}
}
}
@@ -340,8 +335,7 @@ public class MiniConnectionPoolManager {
private synchronized void disposeConnection(PooledConnection pconn) {
pconn.removeConnectionEventListener(poolConnectionEventListener);
if (!recycledConnections.remove(pconn)
&& pconn != connectionInTransition) {
if (!recycledConnections.remove(pconn) && pconn != connectionInTransition) {
// If the PooledConnection is not in the recycledConnections list
// and is not currently within a PooledConnection.getConnection()
// call,
@@ -390,6 +384,7 @@ public class MiniConnectionPoolManager {
private class PoolConnectionEventListener implements
ConnectionEventListener {
public void connectionClosed(ConnectionEvent event) {
PooledConnection pconn = (PooledConnection) event.getSource();
recycleConnection(pconn);
@@ -70,32 +70,29 @@ public class MySQLThread extends Thread implements DataSource {
} catch (ClassNotFoundException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger
.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger
.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (TimeoutException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger
.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@@ -121,85 +118,45 @@ public class MySQLThread extends Thread implements DataSource {
try {
con = makeSureConnectionIsReady();
st = con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ columnID + " INTEGER AUTO_INCREMENT," + columnName
+ " VARCHAR(255) NOT NULL UNIQUE," + columnPassword
+ " VARCHAR(255) NOT NULL," + columnIp
+ " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
+ columnLastLogin + " BIGINT NOT NULL DEFAULT '"
+ System.currentTimeMillis() + "'," + lastlocX
+ " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY
+ " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ
+ " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld
+ " VARCHAR(255) DEFAULT 'world'," + columnEmail
+ " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged
+ " SMALLINT NOT NULL DEFAULT '0',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID
+ "));");
rs = con.getMetaData().getColumns(null, null, tableName,
columnPassword);
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'," + columnLastLogin + " BIGINT NOT NULL DEFAULT '" + System.currentTimeMillis() + "'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnPassword + " VARCHAR(255) NOT NULL;");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnIp + " VARCHAR(40) NOT NULL;");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
columnLastLogin);
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnLastLogin + " BIGINT;");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0' AFTER "
+ columnLastLogin + " , ADD " + lastlocY
+ " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocX
+ " , ADD " + lastlocZ
+ " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocY
+ ";");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + columnLastLogin + " , ADD " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocX + " , ADD " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocY + ";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
lastlocWorld);
rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ lastlocWorld
+ " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER "
+ lastlocZ + ";");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + lastlocZ + ";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
columnEmail);
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnEmail
+ " VARCHAR(255) DEFAULT 'your@email.com' AFTER "
+ lastlocWorld + ";");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocWorld + ";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
columnLogged);
rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnLogged
+ " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail
+ ";");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail + ";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " MODIFY "
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY "
+ lastlocY + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY "
+ lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
st.executeUpdate("ALTER TABLE " + tableName + " MODIFY " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
}
} finally {
close(rs);
@@ -215,8 +172,7 @@ public class MySQLThread extends Thread implements DataSource {
ResultSet rs = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
@@ -243,61 +199,25 @@ public class MySQLThread extends Thread implements DataSource {
int id = -1;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
if (rs.getString(columnIp).isEmpty()
&& rs.getString(columnIp) != null) {
pAuth = new PlayerAuth(rs.getString(columnName),
rs.getString(columnPassword), "198.18.0.1",
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ), rs.getString(lastlocWorld),
rs.getString(columnEmail), API.getPlayerRealName(rs
.getString(columnName)));
if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
if (!columnSalt.isEmpty()) {
if (!columnGroup.isEmpty()) pAuth = new PlayerAuth(
rs.getString(columnName),
rs.getString(columnPassword),
rs.getString(columnSalt),
rs.getInt(columnGroup), rs.getString(columnIp),
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ),
rs.getString(lastlocWorld),
rs.getString(columnEmail),
API.getPlayerRealName(rs.getString(columnName)));
else pAuth = new PlayerAuth(rs.getString(columnName),
rs.getString(columnPassword),
rs.getString(columnSalt),
rs.getString(columnIp),
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ),
rs.getString(lastlocWorld),
rs.getString(columnEmail),
API.getPlayerRealName(rs.getString(columnName)));
if (!columnGroup.isEmpty())
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
pAuth = new PlayerAuth(rs.getString(columnName),
rs.getString(columnPassword),
rs.getString(columnIp),
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ),
rs.getString(lastlocWorld),
rs.getString(columnEmail),
API.getPlayerRealName(rs.getString(columnName)));
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
}
}
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
rs.close();
pst = con
.prepareStatement("SELECT * FROM xf_user_authenticate WHERE "
+ columnID + "=?;");
pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
rs = pst.executeQuery();
if (rs.next()) {
@@ -329,21 +249,15 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
if ((columnSalt == null || columnSalt.isEmpty())
|| (auth.getSalt() == null || auth.getSalt().isEmpty())) {
pst = con.prepareStatement("INSERT INTO " + tableName + "("
+ columnName + "," + columnPassword + "," + columnIp
+ "," + columnLastLogin + ") VALUES (?,?,?,?);");
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.executeUpdate();
} else {
pst = con.prepareStatement("INSERT INTO " + tableName + "("
+ columnName + "," + columnPassword + "," + columnIp
+ "," + columnLastLogin + "," + columnSalt
+ ") VALUES (?,?,?,?,?);");
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
@@ -353,8 +267,7 @@ public class MySQLThread extends Thread implements DataSource {
}
if (!columnOthers.isEmpty()) {
for (String column : columnOthers) {
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ column + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + column + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getRealname());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -363,42 +276,32 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.PHPBB) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert player in phpbb_user_group
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getPhpbbPrefix
+ "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getPhpbbPrefix + "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
pst.setInt(1, Settings.getPhpbbGroup);
pst.setInt(2, id);
pst.setInt(3, 0);
pst.setInt(4, 0);
pst.executeUpdate();
// Update player group in phpbb_users
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ tableName + ".group_id=? WHERE " + columnName
+ "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".group_id=? WHERE " + columnName + "=?;");
pst.setInt(1, Settings.getPhpbbGroup);
pst.setString(2, auth.getNickname());
pst.executeUpdate();
// Get current time without ms
long time = System.currentTimeMillis() / 1000;
// Update user_regdate
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ tableName + ".user_regdate=? WHERE " + columnName
+ "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_regdate=? WHERE " + columnName + "=?;");
pst.setLong(1, time);
pst.setString(2, auth.getNickname());
pst.executeUpdate();
// Update user_lastvisit
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ tableName + ".user_lastvisit=? WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_lastvisit=? WHERE " + columnName + "=?;");
pst.setLong(1, time);
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -407,116 +310,79 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.WORDPRESS) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// First Name
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "first_name");
pst.setString(3, "");
pst.executeUpdate();
// Last Name
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "last_name");
pst.setString(3, "");
pst.executeUpdate();
// Nick Name
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "nickname");
pst.setString(3, auth.getNickname());
pst.executeUpdate();
// Description
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "description");
pst.setString(3, "");
pst.executeUpdate();
// Rich_Editing
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "rich_editing");
pst.setString(3, "true");
pst.executeUpdate();
// Comments_Shortcuts
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "comment_shortcuts");
pst.setString(3, "false");
pst.executeUpdate();
// admin_color
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "admin_color");
pst.setString(3, "fresh");
pst.executeUpdate();
// use_ssl
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "use_ssl");
pst.setString(3, "0");
pst.executeUpdate();
// show_admin_bar_front
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "show_admin_bar_front");
pst.setString(3, "true");
pst.executeUpdate();
// wp_capabilities
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "wp_capabilities");
pst.setString(3, "a:1:{s:10:\"subscriber\";b:1;}");
pst.executeUpdate();
// wp_user_level
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "wp_user_level");
pst.setString(3, "0");
pst.executeUpdate();
// default_password_nag
pst = con
.prepareStatement("INSERT INTO "
+ Settings.getWordPressPrefix
+ "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "default_password_nag");
pst.setString(3, "");
@@ -526,15 +392,13 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
pst = con
.prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);");
pst = con.prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "XenForo_Authentication_Core12");
byte[] bytes = auth.getHash().getBytes();
@@ -563,33 +427,27 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnPassword + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
pst = con
.prepareStatement("UPDATE xf_user_authenticate SET data=? WHERE "
+ columnID + "=?;");
pst = con.prepareStatement("UPDATE xf_user_authenticate SET data=? WHERE " + columnID + "=?;");
byte[] bytes = auth.getHash().getBytes();
Blob blob = con.createBlob();
blob.setBytes(1, bytes);
pst.setBlob(1, blob);
pst.setInt(2, id);
pst.executeUpdate();
pst = con
.prepareStatement("UPDATE xf_user_authenticate SET scheme_class=? WHERE "
+ columnID + "=?;");
pst = con.prepareStatement("UPDATE xf_user_authenticate SET scheme_class=? WHERE " + columnID + "=?;");
pst.setString(1, "XenForo_Authentication_Core12");
pst.setInt(2, id);
pst.executeUpdate();
@@ -614,9 +472,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnIp + "=?, " + columnLastLogin + "=? WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
@@ -640,8 +496,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
+ columnLastLogin + "<?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
return pst.executeUpdate();
} catch (SQLException ex) {
@@ -664,15 +519,13 @@ public class MySQLThread extends Thread implements DataSource {
List<String> list = new ArrayList<String>();
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnLastLogin + "<?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
rs = pst.executeQuery();
while (rs.next()) {
list.add(rs.getString(columnName));
}
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
+ columnLastLogin + "<?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
pst.executeUpdate();
return list;
@@ -698,21 +551,17 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Remove data
pst = con
.prepareStatement("DELETE FROM xf_user_authenticate WHERE "
+ columnID + "=?;");
pst = con.prepareStatement("DELETE FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
}
}
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
pst.executeUpdate();
} catch (SQLException ex) {
@@ -734,9 +583,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ
+ "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst.setDouble(1, auth.getQuitLocX());
pst.setDouble(2, auth.getQuitLocY());
pst.setDouble(3, auth.getQuitLocZ());
@@ -764,8 +611,7 @@ public class MySQLThread extends Thread implements DataSource {
int countIp = 0;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -791,8 +637,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnEmail + " =? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + " =? WHERE " + columnName + "=?;");
pst.setString(1, auth.getEmail());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -818,8 +663,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnSalt + " =? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + " =? WHERE " + columnName + "=?;");
pst.setString(1, auth.getSalt());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -852,12 +696,11 @@ public class MySQLThread extends Thread implements DataSource {
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger
.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
@@ -899,8 +742,7 @@ public class MySQLThread extends Thread implements DataSource {
List<String> countIp = new ArrayList<String>();
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, auth.getIp());
rs = pst.executeQuery();
while (rs.next()) {
@@ -928,8 +770,7 @@ public class MySQLThread extends Thread implements DataSource {
List<String> countIp = new ArrayList<String>();
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -957,8 +798,7 @@ public class MySQLThread extends Thread implements DataSource {
List<String> countEmail = new ArrayList<String>();
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnEmail + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
pst.setString(1, email);
rs = pst.executeQuery();
while (rs.next()) {
@@ -985,8 +825,7 @@ public class MySQLThread extends Thread implements DataSource {
try {
for (String name : banned) {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("DELETE FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, name);
pst.executeUpdate();
}
@@ -1009,33 +848,32 @@ public class MySQLThread extends Thread implements DataSource {
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger
.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
} catch (AssertionError ae) {
// Make sure assertionerror is caused by the connectionpoolmanager,
// else re-throw it
if (!ae.getMessage().equalsIgnoreCase("AuthMeDatabaseError")) throw new AssertionError(
ae.getMessage());
if (!ae.getMessage().equalsIgnoreCase("AuthMeDatabaseError"))
throw new AssertionError(ae.getMessage());
try {
con = null;
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger
.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
if (con == null) con = conPool.getValidConnection();
if (con == null)
con = conPool.getValidConnection();
return con;
}
@@ -1050,8 +888,8 @@ public class MySQLThread extends Thread implements DataSource {
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
if (!reload) ConsoleLogger
.info("ConnectionPool was unavailable... Reconnected!");
if (!reload)
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
@Override
@@ -1066,11 +904,11 @@ public class MySQLThread extends Thread implements DataSource {
ResultSet rs = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) return (rs.getInt(columnLogged) == 1);
if (rs.next())
return (rs.getInt(columnLogged) == 1);
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
@@ -1091,8 +929,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnLogged + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
pst.setInt(1, 1);
pst.setString(2, user);
pst.executeUpdate();
@@ -1115,8 +952,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnLogged + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
pst.setInt(1, 0);
pst.setString(2, user);
pst.executeUpdate();
@@ -1139,8 +975,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnLogged + "=? WHERE " + columnLogged + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
pst.setInt(1, 0);
pst.setInt(2, 1);
pst.executeUpdate();
@@ -60,8 +60,8 @@ public class SQLiteThread extends Thread implements DataSource {
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
@@ -69,8 +69,8 @@ public class SQLiteThread extends Thread implements DataSource {
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
.getPluginManager().disablePlugin(AuthMe.getInstance());
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@@ -79,8 +79,7 @@ public class SQLiteThread extends Thread implements DataSource {
SQLException {
Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded");
this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/"
+ database + ".db");
this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
}
@@ -89,62 +88,37 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
try {
st = con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ columnID + " INTEGER AUTO_INCREMENT," + columnName
+ " VARCHAR(255) NOT NULL UNIQUE," + columnPassword
+ " VARCHAR(255) NOT NULL," + columnIp
+ " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT,"
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY
+ " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ
+ " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld
+ " VARCHAR(255) DEFAULT 'world'," + columnEmail
+ " VARCHAR(255) DEFAULT 'your@email.com',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID
+ "));");
rs = con.getMetaData().getColumns(null, null, tableName,
columnPassword);
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnPassword + " VARCHAR(255) NOT NULL;");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnIp + " VARCHAR(40) NOT NULL;");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
columnLastLogin);
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnLastLogin + " BIGINT;");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ lastlocY + " DOUBLE NOT NULL DEFAULT '0.0';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
lastlocWorld);
rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ lastlocWorld
+ " VARCHAR(255) NOT NULL DEFAULT 'world';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world';");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName,
columnEmail);
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnEmail
+ " VARCHAR(255) DEFAULT 'your@email.com';");
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com';");
}
} finally {
close(rs);
@@ -158,8 +132,7 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?");
pst.setString(1, user);
rs = pst.executeQuery();
return rs.next();
@@ -177,41 +150,17 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
if (rs.getString(columnIp).isEmpty()) {
return new PlayerAuth(rs.getString(columnName),
rs.getString(columnPassword), "198.18.0.1",
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ), rs.getString(lastlocWorld),
rs.getString(columnEmail), API.getPlayerRealName(rs
.getString(columnName)));
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
if (!columnSalt.isEmpty()) {
return new PlayerAuth(rs.getString(columnName),
rs.getString(columnPassword),
rs.getString(columnSalt),
rs.getInt(columnGroup), rs.getString(columnIp),
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ),
rs.getString(lastlocWorld),
rs.getString(columnEmail),
API.getPlayerRealName(rs.getString(columnName)));
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
return new PlayerAuth(rs.getString(columnName),
rs.getString(columnPassword),
rs.getString(columnIp),
rs.getLong(columnLastLogin),
rs.getDouble(lastlocX), rs.getDouble(lastlocY),
rs.getDouble(lastlocZ),
rs.getString(lastlocWorld),
rs.getString(columnEmail),
API.getPlayerRealName(rs.getString(columnName)));
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
}
}
} else {
@@ -231,19 +180,14 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
pst = con.prepareStatement("INSERT INTO " + tableName + "("
+ columnName + "," + columnPassword + "," + columnIp
+ "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.executeUpdate();
} else {
pst = con.prepareStatement("INSERT INTO " + tableName + "("
+ columnName + "," + columnPassword + "," + columnIp
+ "," + columnLastLogin + "," + columnSalt
+ ") VALUES (?,?,?,?,?);");
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
@@ -264,8 +208,7 @@ public class SQLiteThread extends Thread implements DataSource {
public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnPassword + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -282,9 +225,7 @@ public class SQLiteThread extends Thread implements DataSource {
public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnIp + "=?, " + columnLastLogin + "=? WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
@@ -303,8 +244,7 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
+ columnLastLogin + "<?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
return pst.executeUpdate();
} catch (SQLException ex) {
@@ -321,8 +261,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List<String> list = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnLastLogin + "<?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
rs = pst.executeQuery();
while (rs.next()) {
@@ -342,8 +281,7 @@ public class SQLiteThread extends Thread implements DataSource {
public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
pst.executeUpdate();
} catch (SQLException ex) {
@@ -359,9 +297,7 @@ public class SQLiteThread extends Thread implements DataSource {
public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ lastlocX + "=?, " + lastlocY + "=?, " + lastlocZ + "=?, "
+ lastlocWorld + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst.setDouble(1, auth.getQuitLocX());
pst.setDouble(2, auth.getQuitLocY());
pst.setDouble(3, auth.getQuitLocZ());
@@ -383,8 +319,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
int countIp = 0;
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -404,8 +339,7 @@ public class SQLiteThread extends Thread implements DataSource {
public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnEmail + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getEmail());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -425,8 +359,7 @@ public class SQLiteThread extends Thread implements DataSource {
}
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET "
+ columnSalt + "=? WHERE " + columnName + "=?;");
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getSalt());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -478,8 +411,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List<String> countIp = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, auth.getIp());
rs = pst.executeQuery();
while (rs.next()) {
@@ -506,8 +438,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List<String> countIp = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -534,8 +465,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List<String> countEmail = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnEmail + "=?;");
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
pst.setString(1, email);
rs = pst.executeQuery();
while (rs.next()) {
@@ -561,8 +491,7 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
for (String name : banned) {
pst = con.prepareStatement("DELETE FROM " + tableName
+ " WHERE " + columnName + "=?;");
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, name);
pst.executeUpdate();
}