mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-04 22:11:55 +01:00
Merge branch 'Xephi-master'
This commit is contained in:
commit
9e6db7b9f8
@ -283,12 +283,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reload support hook
|
// Reload support hook
|
||||||
if (Settings.reloadSupport) {
|
|
||||||
if (database != null) {
|
if (database != null) {
|
||||||
int playersOnline = Utils.getOnlinePlayers().size();
|
int playersOnline = Utils.getOnlinePlayers().size();
|
||||||
if (playersOnline < 1) {
|
if (playersOnline < 1) {
|
||||||
database.purgeLogged();
|
database.purgeLogged();
|
||||||
} else {
|
} else if (Settings.reloadSupport) {
|
||||||
for (PlayerAuth auth : database.getLoggedPlayers()) {
|
for (PlayerAuth auth : database.getLoggedPlayers()) {
|
||||||
if (auth == null)
|
if (auth == null)
|
||||||
continue;
|
continue;
|
||||||
@ -298,7 +297,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
pm.registerEvents(new AuthMePlayerListener(this), this);
|
pm.registerEvents(new AuthMePlayerListener(this), this);
|
||||||
@ -362,11 +360,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the database
|
|
||||||
if (database != null) {
|
|
||||||
database.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do backup on stop if enabled
|
// Do backup on stop if enabled
|
||||||
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
|
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
|
||||||
boolean Backup = new PerformBackup(this).doBackup();
|
boolean Backup = new PerformBackup(this).doBackup();
|
||||||
@ -378,6 +371,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Unload modules
|
// Unload modules
|
||||||
moduleManager.unloadModules();
|
moduleManager.unloadModules();
|
||||||
|
|
||||||
|
// Close the database
|
||||||
|
if (database != null) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Disabled correctly
|
// Disabled correctly
|
||||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
||||||
}
|
}
|
||||||
@ -584,7 +582,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
database.setUnlogged(name);
|
|
||||||
player.saveData();
|
player.saveData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final String name = args[1].toLowerCase();
|
final String name = args[1].toLowerCase();
|
||||||
|
final String realName = args[1];
|
||||||
final String lowpass = args[2].toLowerCase();
|
final String lowpass = args[2].toLowerCase();
|
||||||
if (lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null") || !lowpass.matches(Settings.getPassRegex)) {
|
if (lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null") || !lowpass.matches(Settings.getPassRegex)) {
|
||||||
m.send(sender, "password_error");
|
m.send(sender, "password_error");
|
||||||
@ -262,7 +263,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, lowpass, name);
|
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, lowpass, name);
|
||||||
PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0L, "your@email.com", name);
|
PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0L, "your@email.com", realName);
|
||||||
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
||||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||||
else auth.setSalt("");
|
else auth.setSalt("");
|
||||||
@ -270,6 +271,9 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
m.send(sender, "error");
|
m.send(sender, "error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
plugin.database.setUnlogged(name);
|
||||||
|
if (Bukkit.getPlayerExact(realName) != null)
|
||||||
|
Bukkit.getPlayerExact(realName).kickPlayer("An admin just registered you, please log again");
|
||||||
m.send(sender, "registered");
|
m.send(sender, "registered");
|
||||||
ConsoleLogger.info(name + " registered");
|
ConsoleLogger.info(name + " registered");
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
|
@ -19,6 +19,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class MySQL implements DataSource {
|
public class MySQL implements DataSource {
|
||||||
|
|
||||||
private String host;
|
private String host;
|
||||||
@ -106,9 +108,15 @@ public class MySQL implements DataSource {
|
|||||||
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
||||||
config.setUsername(this.username);
|
config.setUsername(this.username);
|
||||||
config.setPassword(this.password);
|
config.setPassword(this.password);
|
||||||
|
if (Settings.isMySQLWebsite)
|
||||||
|
{
|
||||||
|
config.addDataSourceProperty("cachePrepStmts", "false");
|
||||||
|
}
|
||||||
|
else {
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
|
}
|
||||||
config.addDataSourceProperty("autoReconnect", false);
|
config.addDataSourceProperty("autoReconnect", false);
|
||||||
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
|
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
|
||||||
config.setMaxLifetime(180000); // 3 Min
|
config.setMaxLifetime(180000); // 3 Min
|
||||||
@ -128,17 +136,33 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized Connection getConnection() throws SQLException {
|
private synchronized Connection getConnection() throws SQLException {
|
||||||
|
if (!ds.isClosed())
|
||||||
|
{
|
||||||
Connection con;
|
Connection con;
|
||||||
con = ds.getConnection();
|
con = ds.getConnection();
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
ConsoleLogger.showError("Can't open a database connection!");
|
||||||
|
if (Settings.isStopEnabled)
|
||||||
|
{
|
||||||
|
ConsoleLogger.showError("Server will ShuttingDown for Security reason");
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AuthMe.getInstance().getServer().shutdown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void setupConnection() throws SQLException {
|
private synchronized void setupConnection() throws SQLException {
|
||||||
Connection con = null;
|
Connection con = null;
|
||||||
Statement st = null;
|
Statement st = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return;
|
||||||
st = con.createStatement();
|
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) NOT NULL DEFAULT '" + Settings.defaultWorld + "'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
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) NOT NULL DEFAULT '" + Settings.defaultWorld + "'," + 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);
|
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||||
@ -185,6 +209,8 @@ public class MySQL implements DataSource {
|
|||||||
if (!rs.next()) {
|
if (!rs.next()) {
|
||||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnRealName + " VARCHAR(255) NOT NULL DEFAULT 'Player' AFTER " + columnLogged + ";");
|
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnRealName + " VARCHAR(255) NOT NULL DEFAULT 'Player' AFTER " + columnLogged + ";");
|
||||||
}
|
}
|
||||||
|
if (Settings.isMySQLWebsite)
|
||||||
|
st.execute("SET GLOBAL query_cache_size = 0; SET GLOBAL query_cache_type = 0;");
|
||||||
} finally {
|
} finally {
|
||||||
close(rs);
|
close(rs);
|
||||||
close(st);
|
close(st);
|
||||||
@ -199,7 +225,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return true;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
|
||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -222,7 +249,8 @@ public class MySQL implements DataSource {
|
|||||||
PlayerAuth pAuth = null;
|
PlayerAuth pAuth = null;
|
||||||
int id;
|
int id;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return null;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
|
||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -272,7 +300,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
|
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
|
||||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
|
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
|
||||||
pst.setString(1, auth.getNickname());
|
pst.setString(1, auth.getNickname());
|
||||||
@ -478,7 +507,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, auth.getHash());
|
pst.setString(1, auth.getHash());
|
||||||
pst.setString(2, auth.getNickname());
|
pst.setString(2, auth.getNickname());
|
||||||
@ -521,7 +551,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=?, " + columnRealName + "=? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=?, " + columnRealName + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, auth.getIp());
|
pst.setString(1, auth.getIp());
|
||||||
pst.setLong(2, auth.getLastLogin());
|
pst.setLong(2, auth.getLastLogin());
|
||||||
@ -543,7 +574,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return 0;
|
||||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||||
pst.setLong(1, until);
|
pst.setLong(1, until);
|
||||||
return pst.executeUpdate();
|
return pst.executeUpdate();
|
||||||
@ -563,7 +595,8 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return list;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||||
pst.setLong(1, until);
|
pst.setLong(1, until);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -590,7 +623,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||||
int id;
|
int id;
|
||||||
ResultSet rs;
|
ResultSet rs;
|
||||||
@ -626,7 +660,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setDouble(1, auth.getQuitLocX());
|
pst.setDouble(1, auth.getQuitLocX());
|
||||||
pst.setDouble(2, auth.getQuitLocY());
|
pst.setDouble(2, auth.getQuitLocY());
|
||||||
@ -651,7 +686,8 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
int countIp = 0;
|
int countIp = 0;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return 0;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
||||||
pst.setString(1, ip);
|
pst.setString(1, ip);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -674,7 +710,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + " =? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + " =? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, auth.getEmail());
|
pst.setString(1, auth.getEmail());
|
||||||
pst.setString(2, auth.getNickname());
|
pst.setString(2, auth.getNickname());
|
||||||
@ -697,7 +734,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + " =? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + " =? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, auth.getSalt());
|
pst.setString(1, auth.getSalt());
|
||||||
pst.setString(2, auth.getNickname());
|
pst.setString(2, auth.getNickname());
|
||||||
@ -729,7 +767,7 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
if (ds != null)
|
if (ds != null && !ds.isClosed())
|
||||||
ds.close();
|
ds.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +788,8 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
List<String> countIp = new ArrayList<>();
|
List<String> countIp = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return countIp;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
||||||
pst.setString(1, auth.getIp());
|
pst.setString(1, auth.getIp());
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -775,7 +814,8 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
List<String> countIp = new ArrayList<>();
|
List<String> countIp = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return countIp;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
||||||
pst.setString(1, ip);
|
pst.setString(1, ip);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -800,7 +840,8 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
List<String> countEmail = new ArrayList<>();
|
List<String> countEmail = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return countEmail;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
|
||||||
pst.setString(1, email);
|
pst.setString(1, email);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -823,8 +864,9 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
|
if ((con = getConnection()) == null)
|
||||||
|
return;
|
||||||
for (String name : banned) {
|
for (String name : banned) {
|
||||||
con = getConnection();
|
|
||||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, name);
|
pst.setString(1, name);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
@ -848,7 +890,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return false;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -870,7 +913,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setInt(1, 1);
|
pst.setInt(1, 1);
|
||||||
pst.setString(2, user);
|
pst.setString(2, user);
|
||||||
@ -889,7 +933,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
if (user != null)
|
if (user != null)
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setInt(1, 0);
|
pst.setInt(1, 0);
|
||||||
pst.setString(2, user);
|
pst.setString(2, user);
|
||||||
@ -907,7 +952,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||||
pst.setInt(1, 0);
|
pst.setInt(1, 0);
|
||||||
pst.setInt(2, 1);
|
pst.setInt(2, 1);
|
||||||
@ -927,7 +973,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs;
|
ResultSet rs;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return result;
|
||||||
pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
|
pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
if (rs != null && rs.next()) {
|
if (rs != null && rs.next()) {
|
||||||
@ -948,7 +995,8 @@ public class MySQL implements DataSource {
|
|||||||
Connection con = null;
|
Connection con = null;
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return;
|
||||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnName + "=? WHERE LOWER(" + columnName + ")=?;");
|
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnName + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||||
pst.setString(1, newone);
|
pst.setString(1, newone);
|
||||||
pst.setString(2, oldone);
|
pst.setString(2, oldone);
|
||||||
@ -968,7 +1016,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return auths;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + ";");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + ";");
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -1018,7 +1067,8 @@ public class MySQL implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
con = getConnection();
|
if ((con = getConnection()) == null)
|
||||||
|
return auths;
|
||||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
|
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
@ -69,12 +69,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
protected void teleportBackFromSpawn() {
|
protected void teleportBackFromSpawn() {
|
||||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||||
pm.callEvent(tpEvent);
|
pm.callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled()) {
|
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
|
||||||
Location fLoc = tpEvent.getTo();
|
player.teleport(tpEvent.getTo());
|
||||||
if (!fLoc.getChunk().isLoaded()) {
|
|
||||||
fLoc.getChunk().load();
|
|
||||||
}
|
|
||||||
player.teleport(fLoc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +78,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
Location spawnL = plugin.getSpawnLocation(player);
|
Location spawnL = plugin.getSpawnLocation(player);
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
||||||
pm.callEvent(tpEvent);
|
pm.callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled()) {
|
if (!tpEvent.isCancelled() && tpEvent.getTo() != null) {
|
||||||
Location fLoc = tpEvent.getTo();
|
player.teleport(tpEvent.getTo());
|
||||||
if (!fLoc.getChunk().isLoaded()) {
|
|
||||||
fLoc.getChunk().load();
|
|
||||||
}
|
|
||||||
player.teleport(fLoc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||||
checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
|
checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
|
||||||
customAttributes, generateImage, isRemoveSpeedEnabled;
|
customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
|
||||||
|
|
||||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||||
@ -281,6 +281,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
|
||||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||||
generateImage = configFile.getBoolean("Email.generateImage", true);
|
generateImage = configFile.getBoolean("Email.generateImage", true);
|
||||||
|
isMySQLWebsite = configFile.getBoolean("DataSource.mySQLWebsite", false);
|
||||||
|
|
||||||
// Load the welcome message
|
// Load the welcome message
|
||||||
getWelcomeMessage();
|
getWelcomeMessage();
|
||||||
@ -482,6 +483,10 @@ public final class Settings extends YamlConfiguration {
|
|||||||
set("DataSource.mySQLRealName", "realname");
|
set("DataSource.mySQLRealName", "realname");
|
||||||
changes = true;
|
changes = true;
|
||||||
}
|
}
|
||||||
|
if (!contains("DataSource.mySQLQueryCache")) {
|
||||||
|
set("DataSource.mySQLWebsite", false);
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (changes) {
|
if (changes) {
|
||||||
plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me");
|
plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me");
|
||||||
|
@ -43,6 +43,8 @@ DataSource:
|
|||||||
mySQLlastlocWorld: world
|
mySQLlastlocWorld: world
|
||||||
# Column for RealName
|
# Column for RealName
|
||||||
mySQLRealName: realname
|
mySQLRealName: realname
|
||||||
|
# Enable this when you allow registration through a website
|
||||||
|
mySQLWebsite: false
|
||||||
settings:
|
settings:
|
||||||
sessions:
|
sessions:
|
||||||
# Do you want to enable the session feature?
|
# Do you want to enable the session feature?
|
||||||
|
Loading…
Reference in New Issue
Block a user