mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 05:05:14 +01:00
commit
2209d49adc
5
pom.xml
5
pom.xml
@ -87,6 +87,7 @@
|
|||||||
<includes>
|
<includes>
|
||||||
<include>com.maxmind.geoip:*</include>
|
<include>com.maxmind.geoip:*</include>
|
||||||
<include>javax.mail:*</include>
|
<include>javax.mail:*</include>
|
||||||
|
<include>com.sun.mail:*</include>
|
||||||
<include>com.comphenix.attribute:*</include>
|
<include>com.comphenix.attribute:*</include>
|
||||||
<include>org.mcstats.*:*</include>
|
<include>org.mcstats.*:*</include>
|
||||||
</includes>
|
</includes>
|
||||||
@ -188,8 +189,8 @@
|
|||||||
|
|
||||||
<!-- Java Email API -->
|
<!-- Java Email API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.mail</groupId>
|
<groupId>com.sun.mail</groupId>
|
||||||
<artifactId>javax.mail-api</artifactId>
|
<artifactId>javax.mail</artifactId>
|
||||||
<version>1.5.4</version>
|
<version>1.5.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ import fr.xephi.authme.commands.LogoutCommand;
|
|||||||
import fr.xephi.authme.commands.PasspartuCommand;
|
import fr.xephi.authme.commands.PasspartuCommand;
|
||||||
import fr.xephi.authme.commands.RegisterCommand;
|
import fr.xephi.authme.commands.RegisterCommand;
|
||||||
import fr.xephi.authme.commands.UnregisterCommand;
|
import fr.xephi.authme.commands.UnregisterCommand;
|
||||||
|
import fr.xephi.authme.converter.Converter;
|
||||||
|
import fr.xephi.authme.converter.ForceFlatToSqlite;
|
||||||
import fr.xephi.authme.datasource.CacheDataSource;
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.DatabaseCalls;
|
import fr.xephi.authme.datasource.DatabaseCalls;
|
||||||
@ -742,6 +744,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
* @param Player
|
* @param Player
|
||||||
* player
|
* player
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getVeryGamesIP(Player player) {
|
public String getVeryGamesIP(Player player) {
|
||||||
String realIP = player.getAddress().getAddress().getHostAddress();
|
String realIP = player.getAddress().getAddress().getHostAddress();
|
||||||
String sUrl = vgUrl;
|
String sUrl = vgUrl;
|
||||||
@ -766,8 +769,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
switch (Settings.getDataSource) {
|
switch (Settings.getDataSource) {
|
||||||
case FILE:
|
case FILE:
|
||||||
database = new FlatFile();
|
database = new FlatFile();
|
||||||
final int a = database.getAccountsRegistered();
|
|
||||||
ConsoleLogger.showError("YOU'RE USING THE FILE BACKEND WITH " + a + "+ ACCOUNTS, YOU SHOULD NEVER USE THIS, PLEASE UPGRADE TO SQLITE!!!");
|
|
||||||
break;
|
break;
|
||||||
case MYSQL:
|
case MYSQL:
|
||||||
database = new MySQL();
|
database = new MySQL();
|
||||||
@ -785,5 +786,16 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
database = new DatabaseCalls(database);
|
database = new DatabaseCalls(database);
|
||||||
|
|
||||||
|
if (Settings.getDataSource == DataSource.DataSourceType.FILE) {
|
||||||
|
Converter converter = new ForceFlatToSqlite(database, this);
|
||||||
|
try {
|
||||||
|
Thread t = new Thread(converter);
|
||||||
|
t.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated, next time server starts up, it will be changed to SQLite... Conversion will be started Asynchronously, it will not drop down your performance !");
|
||||||
|
ConsoleLogger.showError("If you want to keep FlatFile, set file again into config at backend, but this message and this change will appear again at the next restart");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.converter.Converter;
|
import fr.xephi.authme.converter.Converter;
|
||||||
@ -30,10 +29,6 @@ public class ConverterCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmnd, String label,
|
public boolean onCommand(CommandSender sender, Command cmnd, String label,
|
||||||
final String[] args) {
|
final String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.authmePermissible(sender, "authme.admin.converter")) {
|
if (!plugin.authmePermissible(sender, "authme.admin.converter")) {
|
||||||
m.send(sender, "no_perm");
|
m.send(sender, "no_perm");
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,6 +39,8 @@ public class FlatToSqlite implements Converter {
|
|||||||
private static File source;
|
private static File source;
|
||||||
private static String database;
|
private static String database;
|
||||||
private static String columnID;
|
private static String columnID;
|
||||||
|
private static String columnSalt;
|
||||||
|
private static String columnGroup;
|
||||||
private static Connection con;
|
private static Connection con;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,23 +51,20 @@ public class FlatToSqlite implements Converter {
|
|||||||
columnPassword = Settings.getMySQLColumnPassword;
|
columnPassword = Settings.getMySQLColumnPassword;
|
||||||
columnIp = Settings.getMySQLColumnIp;
|
columnIp = Settings.getMySQLColumnIp;
|
||||||
columnLastLogin = Settings.getMySQLColumnLastLogin;
|
columnLastLogin = Settings.getMySQLColumnLastLogin;
|
||||||
|
columnSalt = Settings.getMySQLColumnSalt;
|
||||||
|
columnGroup = Settings.getMySQLColumnGroup;
|
||||||
lastlocX = Settings.getMySQLlastlocX;
|
lastlocX = Settings.getMySQLlastlocX;
|
||||||
lastlocY = Settings.getMySQLlastlocY;
|
lastlocY = Settings.getMySQLlastlocY;
|
||||||
lastlocZ = Settings.getMySQLlastlocZ;
|
lastlocZ = Settings.getMySQLlastlocZ;
|
||||||
lastlocWorld = Settings.getMySQLlastlocWorld;
|
lastlocWorld = Settings.getMySQLlastlocWorld;
|
||||||
columnEmail = Settings.getMySQLColumnEmail;
|
columnEmail = Settings.getMySQLColumnEmail;
|
||||||
columnID = Settings.getMySQLColumnId;
|
columnID = Settings.getMySQLColumnId;
|
||||||
ConsoleLogger.info("Converting FlatFile to SQLite ...");
|
|
||||||
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + database + ".db").exists()) {
|
|
||||||
sender.sendMessage("The Database " + database + ".db can't be created cause the file already exist");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
connect();
|
connect();
|
||||||
setup();
|
setup();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("Problem while trying to convert to sqlite !");
|
sender.sendMessage("Some error appeared while trying to setup and connect to sqlite database... Aborting");
|
||||||
sender.sendMessage("Problem while trying to convert to sqlite !");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -107,7 +106,6 @@ public class FlatToSqlite implements Converter {
|
|||||||
private synchronized static void connect()
|
private synchronized static void connect()
|
||||||
throws ClassNotFoundException, SQLException {
|
throws ClassNotFoundException, SQLException {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
ConsoleLogger.info("SQLite driver loaded");
|
|
||||||
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
|
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +114,7 @@ public class FlatToSqlite implements Converter {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
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," + columnLastLogin + " BIGINT," + lastlocX + " smallint(6) DEFAULT '0'," + lastlocY + " smallint(6) DEFAULT '0'," + lastlocZ + " smallint(6) DEFAULT '0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "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," + 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) NOT NULL DEFAULT '" + Settings.defaultWorld + "'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||||
if (!rs.next()) {
|
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;");
|
||||||
@ -134,12 +132,14 @@ public class FlatToSqlite implements Converter {
|
|||||||
rs.close();
|
rs.close();
|
||||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
||||||
if (!rs.next()) {
|
if (!rs.next()) {
|
||||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " smallint(6) NOT NULL DEFAULT '0'; " + "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " smallint(6) NOT NULL DEFAULT '0'; " + "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " smallint(6) NOT NULL DEFAULT '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.close();
|
||||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
|
rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
|
||||||
if (!rs.next()) {
|
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';");
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
|
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
|
||||||
@ -150,7 +150,6 @@ public class FlatToSqlite implements Converter {
|
|||||||
close(rs);
|
close(rs);
|
||||||
close(st);
|
close(st);
|
||||||
}
|
}
|
||||||
ConsoleLogger.info("SQLite Setup finished");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized boolean saveAuth(String s) {
|
private static synchronized boolean saveAuth(String s) {
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
|
|
||||||
|
public class ForceFlatToSqlite implements Converter {
|
||||||
|
|
||||||
|
private DataSource data;
|
||||||
|
private AuthMe plugin;
|
||||||
|
|
||||||
|
public ForceFlatToSqlite(DataSource data, AuthMe plugin) {
|
||||||
|
this.data = data;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
DataSource sqlite = null;
|
||||||
|
try {
|
||||||
|
sqlite = new SQLite();
|
||||||
|
for (PlayerAuth auth : data.getAllAuths())
|
||||||
|
sqlite.saveAuth(auth);
|
||||||
|
plugin.getSettings().setValue("DataSource.backend", "sqlite");
|
||||||
|
ConsoleLogger.info("Database successfully converted to sqlite !");
|
||||||
|
} catch (Exception e) {
|
||||||
|
ConsoleLogger.showError("An error appeared while trying to convert flatfile to sqlite ...");
|
||||||
|
} finally {
|
||||||
|
if (sqlite != null)
|
||||||
|
sqlite.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -407,7 +408,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isBanned())
|
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Settings.enablePasspartu && !Settings.countriesBlacklist.isEmpty()) {
|
if (Settings.enablePasspartu && !Settings.countriesBlacklist.isEmpty()) {
|
||||||
@ -460,7 +461,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
String regex = Settings.getNickRegex;
|
String regex = Settings.getNickRegex;
|
||||||
|
|
||||||
if (name.length() > max || name.length() < min) {
|
if (name.length() > max || name.length() < min) {
|
||||||
event.setKickMessage(m.send("name_len")[0]);
|
event.setKickMessage(Arrays.toString(m.send("name_len")));
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -602,6 +602,11 @@ public final class Settings extends YamlConfiguration {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setValue(String key, Object value) {
|
||||||
|
this.set(key, value);
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
private static HashAlgorithm getPasswordHash() {
|
private static HashAlgorithm getPasswordHash() {
|
||||||
String key = "settings.security.passwordHash";
|
String key = "settings.security.passwordHash";
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user