AuthMe 3.4
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
public interface Converter {
|
||||
|
||||
void convert() throws Exception;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import fr.xephi.authme.settings.Settings;
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class FlatToSql {
|
||||
public class FlatToSql implements Converter {
|
||||
|
||||
private static String tableName;
|
||||
private static String columnName;
|
||||
@@ -49,7 +49,7 @@ public class FlatToSql {
|
||||
columnID = Settings.getMySQLColumnId;
|
||||
}
|
||||
|
||||
public boolean convert() throws IOException {
|
||||
public void convert() throws IOException {
|
||||
try {
|
||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
||||
source.createNewFile();
|
||||
@@ -93,12 +93,10 @@ public class FlatToSql {
|
||||
sql.close();
|
||||
br.close();
|
||||
ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
|
||||
return true;
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,20 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class FlatToSqlite {
|
||||
public class FlatToSqlite implements Converter {
|
||||
|
||||
public CommandSender sender;
|
||||
|
||||
public FlatToSqlite(CommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
private static String tableName;
|
||||
private static String columnName;
|
||||
@@ -34,7 +42,7 @@ public class FlatToSqlite {
|
||||
private static String columnID;
|
||||
private static Connection con;
|
||||
|
||||
public static String convert() throws IOException {
|
||||
public void convert() throws Exception {
|
||||
database = Settings.getMySQLDatabase;
|
||||
tableName = Settings.getMySQLTablename;
|
||||
columnName = Settings.getMySQLColumnName;
|
||||
@@ -49,14 +57,16 @@ public class FlatToSqlite {
|
||||
columnID = Settings.getMySQLColumnId;
|
||||
ConsoleLogger.info("Converting FlatFile to SQLite ...");
|
||||
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + database + ".db").exists()) {
|
||||
return "The Database " + database + ".db can't be created cause the file already exist";
|
||||
sender.sendMessage("The Database " + database + ".db can't be created cause the file already exist");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
connect();
|
||||
setup();
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("Problem while trying to convert to sqlite !");
|
||||
return "Problem while trying to convert to sqlite !";
|
||||
sender.sendMessage("Problem while trying to convert to sqlite !");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
||||
@@ -84,13 +94,15 @@ public class FlatToSqlite {
|
||||
br.close();
|
||||
ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
|
||||
close();
|
||||
return ("The FlatFile has been converted to " + database + ".db file");
|
||||
sender.sendMessage("The FlatFile has been converted to " + database + ".db file");
|
||||
return;
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return "Errors appears while trying to convert to SQLite";
|
||||
sender.sendMessage("Errors appears while trying to convert to SQLite");
|
||||
return;
|
||||
}
|
||||
|
||||
private synchronized static void connect() throws ClassNotFoundException, SQLException {
|
||||
|
||||
@@ -1,50 +1,52 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
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.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class RakamakConverter {
|
||||
public class RakamakConverter implements Converter {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
|
||||
public RakamakConverter (AuthMe instance) {
|
||||
public RakamakConverter (AuthMe instance, DataSource database, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public RakamakConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static HashAlgorithm hash;
|
||||
private static Boolean useIP;
|
||||
private static String fileName;
|
||||
private static String ipFileName;
|
||||
private static File source;
|
||||
private static File output;
|
||||
private static File ipfiles;
|
||||
private static boolean alreadyExist = false;
|
||||
|
||||
public static void RakamakConvert() throws IOException {
|
||||
hash = Settings.rakamakHash;
|
||||
public void convert() throws Exception {
|
||||
HashAlgorithm hash = Settings.getPasswordHash;
|
||||
useIP = Settings.rakamakUseIp;
|
||||
fileName = Settings.rakamakUsers;
|
||||
ipFileName = Settings.rakamakUsersIp;
|
||||
@@ -53,19 +55,12 @@ public class RakamakConverter {
|
||||
try {
|
||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
||||
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
|
||||
output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
||||
source.createNewFile();
|
||||
ipfiles.createNewFile();
|
||||
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db").exists()) {
|
||||
alreadyExist = true;
|
||||
}
|
||||
output.createNewFile();
|
||||
BufferedReader users = null;
|
||||
BufferedWriter outputDB = null;
|
||||
BufferedReader ipFile = null;
|
||||
ipFile = new BufferedReader(new FileReader(ipfiles));
|
||||
String line;
|
||||
String newLine = null;
|
||||
if (useIP) {
|
||||
String tempLine;
|
||||
while ((tempLine = ipFile.readLine()) != null) {
|
||||
@@ -81,33 +76,28 @@ public class RakamakConverter {
|
||||
if (line.contains("=")) {
|
||||
String[] arguments = line.split("=");
|
||||
try {
|
||||
playerPSW.put(arguments[0],PasswordSecurity.getHash(hash, arguments[1], arguments[0].toLowerCase()));
|
||||
playerPSW.put(arguments[0],PasswordSecurity.getHash(hash, arguments[1], arguments[0]));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
users.close();
|
||||
outputDB = new BufferedWriter(new FileWriter(output));
|
||||
for (Entry<String, String> m : playerPSW.entrySet()) {
|
||||
String player = m.getKey();
|
||||
String psw = playerPSW.get(player);
|
||||
String ip;
|
||||
if (useIP) {
|
||||
String player = m.getKey();
|
||||
String psw = playerPSW.get(player);
|
||||
String ip = playerIP.get(player);
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
|
||||
ip = playerIP.get(player);
|
||||
} else {
|
||||
String player = m.getKey();
|
||||
String psw = playerPSW.get(player);
|
||||
String ip = "127.0.0.1";
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
if (alreadyExist) outputDB.newLine();
|
||||
outputDB.write(newLine);
|
||||
System.out.println("Write line");
|
||||
outputDB.newLine();
|
||||
PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis());
|
||||
if (PasswordSecurity.userSalt.containsKey(player))
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(player));
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
outputDB.close();
|
||||
ConsoleLogger.info("Rakamak database has been converted to auths.db");
|
||||
ConsoleLogger.info("Rakamak database has been imported correctly");
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
public class RoyalAuthConverter extends Thread {
|
||||
public class RoyalAuthConverter extends Thread implements Converter {
|
||||
|
||||
public AuthMe plugin;
|
||||
private DataSource data;
|
||||
@@ -21,23 +21,27 @@ public class RoyalAuthConverter extends Thread {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
|
||||
try {
|
||||
String name = o.getName().toLowerCase();
|
||||
String separator = File.separator;
|
||||
File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
|
||||
if (data.isAuthAvailable(name))
|
||||
continue;
|
||||
if (!file.exists())
|
||||
continue;
|
||||
RoyalAuthYamlReader ra = new RoyalAuthYamlReader(file);
|
||||
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
|
||||
data.saveAuth(auth);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("Error while trying to import "+ o.getName() + " RoyalAuth datas");
|
||||
}
|
||||
}
|
||||
this.interrupt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert() throws Exception {
|
||||
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
|
||||
try {
|
||||
String name = o.getName().toLowerCase();
|
||||
String separator = File.separator;
|
||||
File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
|
||||
if (data.isAuthAvailable(name))
|
||||
continue;
|
||||
if (!file.exists())
|
||||
continue;
|
||||
RoyalAuthYamlReader ra = new RoyalAuthYamlReader(file);
|
||||
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
|
||||
data.saveAuth(auth);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("Error while trying to import "+ o.getName() + " RoyalAuth datas");
|
||||
}
|
||||
}
|
||||
this.interrupt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
public class xAuthConverter implements Converter {
|
||||
|
||||
public AuthMe plugin;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
|
||||
public xAuthConverter(AuthMe plugin, DataSource database, CommandSender sender) {
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
this.sender = sender;
|
||||
}
|
||||
@Override
|
||||
public void convert() throws Exception {
|
||||
try {
|
||||
Class.forName("com.cypherx.xauth.xAuth");
|
||||
oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
|
||||
converter.run();
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
Class.forName("de.luricos.bukkit.xAuth.xAuth");
|
||||
newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender);
|
||||
converter.run();
|
||||
} catch (ClassNotFoundException ce) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user