mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 11:15:19 +01:00
Add a way to convert SQLite to MySQL (/converter sqlitetosql)
This commit is contained in:
parent
8f09893337
commit
37eedfde62
@ -9,6 +9,7 @@ import fr.xephi.authme.converter.FlatToSqlite;
|
|||||||
import fr.xephi.authme.converter.RakamakConverter;
|
import fr.xephi.authme.converter.RakamakConverter;
|
||||||
import fr.xephi.authme.converter.RoyalAuthConverter;
|
import fr.xephi.authme.converter.RoyalAuthConverter;
|
||||||
import fr.xephi.authme.converter.SqlToFlat;
|
import fr.xephi.authme.converter.SqlToFlat;
|
||||||
|
import fr.xephi.authme.converter.SqliteToSql;
|
||||||
import fr.xephi.authme.converter.vAuthConverter;
|
import fr.xephi.authme.converter.vAuthConverter;
|
||||||
import fr.xephi.authme.converter.xAuthConverter;
|
import fr.xephi.authme.converter.xAuthConverter;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
@ -65,6 +66,9 @@ public class ConverterCommand extends ExecutableCommand {
|
|||||||
case SQLTOFLAT:
|
case SQLTOFLAT:
|
||||||
converter = new SqlToFlat(plugin, sender);
|
converter = new SqlToFlat(plugin, sender);
|
||||||
break;
|
break;
|
||||||
|
case SQLITETOSQL:
|
||||||
|
converter = new SqliteToSql(plugin, sender);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -84,7 +88,8 @@ public class ConverterCommand extends ExecutableCommand {
|
|||||||
RAKAMAK("rakamak"),
|
RAKAMAK("rakamak"),
|
||||||
ROYALAUTH("royalauth"),
|
ROYALAUTH("royalauth"),
|
||||||
VAUTH("vauth"),
|
VAUTH("vauth"),
|
||||||
SQLTOFLAT("sqltoflat");
|
SQLTOFLAT("sqltoflat"),
|
||||||
|
SQLITETOSQL("sqlitetosql");
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
|
46
src/main/java/fr/xephi/authme/converter/SqliteToSql.java
Normal file
46
src/main/java/fr/xephi/authme/converter/SqliteToSql.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
|
import fr.xephi.authme.datasource.DataSource.DataSourceType;
|
||||||
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
|
import fr.xephi.authme.output.MessageKey;
|
||||||
|
|
||||||
|
public class SqliteToSql implements Converter {
|
||||||
|
|
||||||
|
private AuthMe plugin;
|
||||||
|
private CommandSender sender;
|
||||||
|
|
||||||
|
public SqliteToSql(AuthMe plugin, CommandSender sender) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (plugin.database.getType() != DataSourceType.MYSQL)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Please config your mySQL connection and re-run this command");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
SQLite data = new SQLite();
|
||||||
|
for (PlayerAuth auth : data.getAllAuths())
|
||||||
|
{
|
||||||
|
plugin.database.saveAuth(auth);
|
||||||
|
}
|
||||||
|
sender.sendMessage("Convert command has finished !");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
sender.sendMessage(plugin.getMessages().retrieve(MessageKey.ERROR));
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
sender.sendMessage(plugin.getMessages().retrieve(MessageKey.ERROR));
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user