Update 3.3.4
//Changes 3.3.4:// * Add an isLogged column in mySQL * Add a maxLoginPerIp * Add a maxJoinPerIp * Add a way to force kick after register * Add a way to force login after register * Update session correctly * Fix Change Email command * Fix some perm problems * Fix some problems with email sending * Remove some dead code * Add a way to control spawn priority, by default , in order, it is : authme,essentials,multiverse,default
This commit is contained in:
@@ -191,4 +191,28 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return source.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return source.isLogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
source.setLogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
source.setUnlogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
source.purgeLogged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +47,15 @@ public interface DataSource {
|
||||
void reload();
|
||||
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
DataSourceType getType();
|
||||
|
||||
boolean isLogged(String user);
|
||||
|
||||
void setLogged(String user);
|
||||
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
@@ -629,4 +630,29 @@ public class FileDataSource implements DataSource {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayersLogs.getInstance().players.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().addPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().removePlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public class MySQLDataSource implements DataSource {
|
||||
private String lastlocWorld;
|
||||
private String columnEmail;
|
||||
private String columnID;
|
||||
private String columnLogged;
|
||||
private List<String> columnOthers;
|
||||
private MiniConnectionPoolManager conPool;
|
||||
|
||||
@@ -62,6 +63,7 @@ public class MySQLDataSource implements DataSource {
|
||||
this.columnEmail = Settings.getMySQLColumnEmail;
|
||||
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
|
||||
connect();
|
||||
setup();
|
||||
@@ -91,13 +93,14 @@ public class MySQLDataSource implements DataSource {
|
||||
+ columnID + " INTEGER AUTO_INCREMENT,"
|
||||
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
|
||||
+ columnPassword + " VARCHAR(255) NOT NULL,"
|
||||
+ columnIp + " VARCHAR(40) NOT NULL,"
|
||||
+ columnLastLogin + " BIGINT,"
|
||||
+ columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
|
||||
+ columnLastLogin + " BIGINT DEFAULT '0',"
|
||||
+ 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()) {
|
||||
@@ -108,13 +111,13 @@ public class MySQLDataSource implements DataSource {
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
+ columnIp + " VARCHAR(40) NOT NULL;");
|
||||
+ columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
+ columnLastLogin + " BIGINT;");
|
||||
+ columnLastLogin + " BIGINT DEFAULT '0';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
||||
@@ -130,7 +133,12 @@ public class MySQLDataSource implements DataSource {
|
||||
rs.close();
|
||||
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 " + lastlocZ +";");
|
||||
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);
|
||||
if (!rs.next()) {
|
||||
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);
|
||||
@@ -731,7 +739,7 @@ public class MySQLDataSource implements DataSource {
|
||||
close(rs);
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -806,4 +814,105 @@ public class MySQLDataSource implements DataSource {
|
||||
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.MYSQL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
|
||||
+ columnName + "=?;");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next())
|
||||
return (rs.getInt(columnLogged) == 1);
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
@@ -509,4 +510,28 @@ public class SqliteDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayersLogs.getInstance().players.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().addPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().removePlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user