From 41e400e9dd9c6a5194bb739d022d81d004a4159d Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Sat, 26 Dec 2015 15:38:16 +0100 Subject: [PATCH] Deprecate flatile datasource, force flat to sqlite conversion #344 --- src/main/java/fr/xephi/authme/AuthMe.java | 68 +++--- .../authme/command/CommandInitializer.java | 19 +- .../converter/ConverterCommand.java | 24 +-- .../fr/xephi/authme/converter/FlatToSql.java | 84 -------- .../xephi/authme/converter/FlatToSqlite.java | 198 ------------------ .../authme/converter/ForceFlatToSqlite.java | 12 +- .../fr/xephi/authme/converter/SqlToFlat.java | 59 ------ .../fr/xephi/authme/datasource/FlatFile.java | 13 +- 8 files changed, 62 insertions(+), 415 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/converter/FlatToSql.java delete mode 100644 src/main/java/fr/xephi/authme/converter/FlatToSqlite.java delete mode 100644 src/main/java/fr/xephi/authme/converter/SqlToFlat.java diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 3ac4f9ce2..6471797fe 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -1,7 +1,34 @@ package fr.xephi.authme; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; + +import org.apache.logging.log4j.LogManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Server; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; +import org.mcstats.Metrics; +import org.mcstats.Metrics.Graph; + import com.earth2me.essentials.Essentials; import com.onarandombox.MultiverseCore.MultiverseCore; + import fr.xephi.authme.api.API; import fr.xephi.authme.api.NewAPI; import fr.xephi.authme.cache.auth.PlayerAuth; @@ -11,7 +38,6 @@ import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.command.CommandHandler; import fr.xephi.authme.command.CommandInitializer; -import fr.xephi.authme.converter.Converter; import fr.xephi.authme.converter.ForceFlatToSqlite; import fr.xephi.authme.datasource.CacheDataSource; import fr.xephi.authme.datasource.DataSource; @@ -45,31 +71,6 @@ import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Wrapper; import net.minelink.ctplus.CombatTagPlus; -import org.apache.logging.log4j.LogManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Server; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.plugin.PluginManager; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitTask; -import org.mcstats.Metrics; -import org.mcstats.Metrics.Graph; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Logger; /** * The AuthMe main class. @@ -563,16 +564,17 @@ public void run() { }); } + if (Settings.getDataSource == DataSource.DataSourceType.FILE) { + ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated, it will be changed to SQLite... Connection will be impossible until conversion is done!"); + ForceFlatToSqlite converter = new ForceFlatToSqlite(database, this); + DataSource source = converter.run(); + if (source != null) + database = source; + } + if (Settings.isCachingEnabled) { database = new CacheDataSource(database); } - - if (Settings.getDataSource == DataSource.DataSourceType.FILE) { - Converter converter = new ForceFlatToSqlite(database, this); - server.getScheduler().runTaskAsynchronously(this, converter); - 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"); - } } /** diff --git a/src/main/java/fr/xephi/authme/command/CommandInitializer.java b/src/main/java/fr/xephi/authme/command/CommandInitializer.java index 66d138038..c66b95232 100644 --- a/src/main/java/fr/xephi/authme/command/CommandInitializer.java +++ b/src/main/java/fr/xephi/authme/command/CommandInitializer.java @@ -1,6 +1,14 @@ package fr.xephi.authme.command; +import static fr.xephi.authme.permission.DefaultPermission.ALLOWED; +import static fr.xephi.authme.permission.DefaultPermission.OP_ONLY; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + import com.google.common.collect.ImmutableSet; + import fr.xephi.authme.command.executable.HelpCommand; import fr.xephi.authme.command.executable.authme.AccountsCommand; import fr.xephi.authme.command.executable.authme.AuthMeCommand; @@ -35,13 +43,6 @@ import fr.xephi.authme.permission.AdminPermission; import fr.xephi.authme.permission.PlayerPermission; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import static fr.xephi.authme.permission.DefaultPermission.ALLOWED; -import static fr.xephi.authme.permission.DefaultPermission.OP_ONLY; - /** * Initializes all available AuthMe commands. */ @@ -478,8 +479,8 @@ private static void initializeCommands() { .labels("converter", "convert", "conv") .description("Converter Command") .detailedDescription("Converter command for AuthMeReloaded.") - .withArgument("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / " + - "royalauth / vauth / sqltoflat / sqlitetosql", false) + .withArgument("job", "Conversion job: xauth / crazylogin / rakamak / " + + "royalauth / vauth / sqlitetosql", false) .permissions(OP_ONLY, AdminPermission.CONVERTER) .executableCommand(new ConverterCommand()) .build(); diff --git a/src/main/java/fr/xephi/authme/command/executable/converter/ConverterCommand.java b/src/main/java/fr/xephi/authme/command/executable/converter/ConverterCommand.java index 4d1b8f1d4..d9a9a53ac 100644 --- a/src/main/java/fr/xephi/authme/command/executable/converter/ConverterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/converter/ConverterCommand.java @@ -1,23 +1,21 @@ package fr.xephi.authme.command.executable.converter; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + import fr.xephi.authme.AuthMe; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.converter.Converter; import fr.xephi.authme.converter.CrazyLoginConverter; -import fr.xephi.authme.converter.FlatToSql; -import fr.xephi.authme.converter.FlatToSqlite; import fr.xephi.authme.converter.RakamakConverter; import fr.xephi.authme.converter.RoyalAuthConverter; -import fr.xephi.authme.converter.SqlToFlat; import fr.xephi.authme.converter.SqliteToSql; import fr.xephi.authme.converter.vAuthConverter; import fr.xephi.authme.converter.xAuthConverter; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - -import java.util.List; public class ConverterCommand extends ExecutableCommand { @@ -42,12 +40,6 @@ public void executeCommand(CommandSender sender, List arguments) { // Get the proper converter instance Converter converter = null; switch (jobType) { - case FTSQL: - converter = new FlatToSql(); - break; - case FTSQLITE: - converter = new FlatToSqlite(sender); - break; case XAUTH: converter = new xAuthConverter(plugin, sender); break; @@ -63,9 +55,6 @@ public void executeCommand(CommandSender sender, List arguments) { case VAUTH: converter = new vAuthConverter(plugin, sender); break; - case SQLTOFLAT: - converter = new SqlToFlat(plugin, sender); - break; case SQLITETOSQL: converter = new SqliteToSql(plugin, sender); break; @@ -81,14 +70,11 @@ public void executeCommand(CommandSender sender, List arguments) { } public enum ConvertType { - FTSQL("flattosql"), - FTSQLITE("flattosqlite"), XAUTH("xauth"), CRAZYLOGIN("crazylogin"), RAKAMAK("rakamak"), ROYALAUTH("royalauth"), VAUTH("vauth"), - SQLTOFLAT("sqltoflat"), SQLITETOSQL("sqlitetosql"); final String name; diff --git a/src/main/java/fr/xephi/authme/converter/FlatToSql.java b/src/main/java/fr/xephi/authme/converter/FlatToSql.java deleted file mode 100644 index deac1e85a..000000000 --- a/src/main/java/fr/xephi/authme/converter/FlatToSql.java +++ /dev/null @@ -1,84 +0,0 @@ -package fr.xephi.authme.converter; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.settings.Settings; - -import java.io.*; - -/** - * @author Xephi59 - * @version $Revision: 1.0 $ - */ -public class FlatToSql implements Converter { - - private static String tableName; - private static String columnName; - private static String columnPassword; - private static String columnIp; - private static String columnLastLogin; - private static String lastlocX; - private static String lastlocY; - private static String lastlocZ; - private static String lastlocWorld; - private static String columnEmail; - private static String columnLogged; - private static String columnID; - - public FlatToSql() { - tableName = Settings.getMySQLTablename; - columnName = Settings.getMySQLColumnName; - columnPassword = Settings.getMySQLColumnPassword; - columnIp = Settings.getMySQLColumnIp; - columnLastLogin = Settings.getMySQLColumnLastLogin; - lastlocX = Settings.getMySQLlastlocX; - lastlocY = Settings.getMySQLlastlocY; - lastlocZ = Settings.getMySQLlastlocZ; - lastlocWorld = Settings.getMySQLlastlocWorld; - columnEmail = Settings.getMySQLColumnEmail; - columnLogged = Settings.getMySQLColumnLogged; - columnID = Settings.getMySQLColumnId; - } - - /** - * Method run. - * - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - try { - File source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db"); - source.createNewFile(); - File output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "authme.sql"); - output.createNewFile(); - BufferedReader br = new BufferedReader(new FileReader(source)); - BufferedWriter sql = new BufferedWriter(new FileWriter(output)); - String createDB = "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 + "));"; - sql.write(createDB); - String line; - String newline; - while ((line = br.readLine()) != null) { - sql.newLine(); - String[] args = line.split(":"); - if (args.length == 4) - newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0.0, 0.0, 0.0, 'world', 'your@email.com', 0);"; - else if (args.length == 7) - newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com', 0);"; - else if (args.length == 8) - newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com', 0);"; - else if (args.length == 9) - newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "', 0);"; - else newline = ""; - if (!newline.equals("")) - sql.write(newline); - } - sql.close(); - br.close(); - ConsoleLogger.info("The FlatFile has been converted to authme.sql file"); - } catch (IOException ex) { - ConsoleLogger.showError(ex.getMessage()); - ConsoleLogger.showError("Can't open the flat database file! Does it exist?"); - } - } -} diff --git a/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java b/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java deleted file mode 100644 index 3a67cf06a..000000000 --- a/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java +++ /dev/null @@ -1,198 +0,0 @@ -package fr.xephi.authme.converter; - -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.settings.Settings; -import org.bukkit.command.CommandSender; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.sql.*; - -/** - */ -public class FlatToSqlite implements Converter { - - public final CommandSender sender; - private String tableName; - private String columnName; - private String columnPassword; - private String columnIp; - private String columnLastLogin; - private String lastlocX; - private String lastlocY; - private String lastlocZ; - private String lastlocWorld; - private String columnEmail; - private String database; - private String columnID; - private Connection con; - - /** - * Constructor for FlatToSqlite. - * - * @param sender CommandSender - */ - public FlatToSqlite(CommandSender sender) { - this.sender = sender; - } - - /** - * Method close. - * - * @param o AutoCloseable - */ - private static void close(AutoCloseable o) { - if (o != null) { - try { - o.close(); - } catch (Exception ex) { - ConsoleLogger.showError(ex.getMessage()); - } - } - } - - /** - * Method run. - * - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - database = Settings.getMySQLDatabase; - tableName = Settings.getMySQLTablename; - columnName = Settings.getMySQLColumnName; - columnPassword = Settings.getMySQLColumnPassword; - columnIp = Settings.getMySQLColumnIp; - columnLastLogin = Settings.getMySQLColumnLastLogin; - lastlocX = Settings.getMySQLlastlocX; - lastlocY = Settings.getMySQLlastlocY; - lastlocZ = Settings.getMySQLlastlocZ; - lastlocWorld = Settings.getMySQLlastlocWorld; - columnEmail = Settings.getMySQLColumnEmail; - columnID = Settings.getMySQLColumnId; - - File source = new File(Settings.PLUGIN_FOLDER, "auths.db"); - if (!source.exists()) { - sender.sendMessage("Source file for FlatFile database not found... Aborting"); - return; - } - - try { - connect(); - setup(); - } catch (Exception e) { - sender.sendMessage("Some error appeared while trying to setup and connect to sqlite database... Aborting"); - return; - } - - try (BufferedReader reader = new BufferedReader(new FileReader(source))) { - String line; - int i = 1; - String newline; - while ((line = reader.readLine()) != null) { - String[] args = line.split(":"); - if (args.length == 4) - newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, 'world', 'your@email.com');"; - else if (args.length == 7) - newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com');"; - else if (args.length == 8) - newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com');"; - else if (args.length == 9) - newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "');"; - else newline = ""; - if (!newline.equals("")) - saveAuth(newline); - i = i + 1; - } - String resp = "The FlatFile has been converted to " + database + ".db file"; - ConsoleLogger.info(resp); - sender.sendMessage(resp); - } catch (IOException ex) { - ConsoleLogger.showError(ex.getMessage()); - sender.sendMessage("Can't open the flat database file!"); - } finally { - close(con); - } - } - - /** - * Method connect. - * - * @throws ClassNotFoundException * @throws SQLException - */ - private synchronized void connect() throws ClassNotFoundException, SQLException { - Class.forName("org.sqlite.JDBC"); - con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db"); - } - - /** - * Method setup. - * - * @throws SQLException - */ - private synchronized void setup() throws SQLException { - Statement st = null; - 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) 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); - if (!rs.next()) { - 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;"); - } - rs.close(); - rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin); - if (!rs.next()) { - 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';"); - } - rs.close(); - 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';"); - } - 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';"); - } - } finally { - close(rs); - close(st); - } - } - - /** - * Method saveAuth. - * - * @param s String - * - * @return boolean - */ - private synchronized boolean saveAuth(String s) { - PreparedStatement pst = null; - try { - pst = con.prepareStatement(s); - pst.executeUpdate(); - } catch (SQLException e) { - ConsoleLogger.showError(e.getMessage()); - return false; - } finally { - close(pst); - } - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/converter/ForceFlatToSqlite.java b/src/main/java/fr/xephi/authme/converter/ForceFlatToSqlite.java index 8e2872119..02d3afa7a 100644 --- a/src/main/java/fr/xephi/authme/converter/ForceFlatToSqlite.java +++ b/src/main/java/fr/xephi/authme/converter/ForceFlatToSqlite.java @@ -9,7 +9,7 @@ /** */ -public class ForceFlatToSqlite implements Converter { +public class ForceFlatToSqlite { private final DataSource data; @@ -28,8 +28,7 @@ public ForceFlatToSqlite(DataSource data, AuthMe plugin) { * * @see java.lang.Runnable#run() */ - @Override - public void run() { + public DataSource run() { DataSource sqlite = null; try { sqlite = new SQLite(); @@ -40,10 +39,9 @@ public void run() { Settings.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(); + ConsoleLogger.showError("An error occured while trying to convert flatfile to sqlite ..."); + return null; } + return sqlite; } } diff --git a/src/main/java/fr/xephi/authme/converter/SqlToFlat.java b/src/main/java/fr/xephi/authme/converter/SqlToFlat.java deleted file mode 100644 index 1af5594cf..000000000 --- a/src/main/java/fr/xephi/authme/converter/SqlToFlat.java +++ /dev/null @@ -1,59 +0,0 @@ -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.FlatFile; -import fr.xephi.authme.output.MessageKey; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - */ -public class SqlToFlat implements Converter { - - public final AuthMe plugin; - public final DataSource database; - public final CommandSender sender; - - /** - * Constructor for SqlToFlat. - * - * @param plugin AuthMe - * @param sender CommandSender - */ - public SqlToFlat(AuthMe plugin, CommandSender sender) { - this.plugin = plugin; - this.database = plugin.database; - this.sender = sender; - } - - /** - * Method run. - * - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - try { - FlatFile flat = new FlatFile(); - List auths = database.getAllAuths(); - int i = 0; - final int size = auths.size(); - for (PlayerAuth auth : auths) { - flat.saveAuth(auth); - i++; - if ((i % 100) == 0) { - sender.sendMessage("Conversion Status : " + i + " / " + size); - } - } - sender.sendMessage("Successfully convert from SQL table to file auths.db"); - } catch (Exception ex) { - ConsoleLogger.showError(ex.getMessage()); - plugin.getMessages().send(sender, MessageKey.ERROR); - } - } - -} diff --git a/src/main/java/fr/xephi/authme/datasource/FlatFile.java b/src/main/java/fr/xephi/authme/datasource/FlatFile.java index 40047979d..b7fb55171 100644 --- a/src/main/java/fr/xephi/authme/datasource/FlatFile.java +++ b/src/main/java/fr/xephi/authme/datasource/FlatFile.java @@ -1,11 +1,5 @@ package fr.xephi.authme.datasource; -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.settings.Settings; - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -16,8 +10,15 @@ import java.util.ArrayList; import java.util.List; +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.cache.auth.PlayerAuth; +import fr.xephi.authme.cache.auth.PlayerCache; +import fr.xephi.authme.settings.Settings; + /** */ +@Deprecated public class FlatFile implements DataSource { /*