cleanup converters
This commit is contained in:
parent
fec4fb2913
commit
10580e3447
@ -109,7 +109,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||||
try {
|
try {
|
||||||
plugin.getSettings().reload();
|
Settings.reload();
|
||||||
m.reloadMessages();
|
m.reloadMessages();
|
||||||
plugin.database.close();
|
plugin.database.close();
|
||||||
plugin.setupDatabase();
|
plugin.setupDatabase();
|
||||||
|
|||||||
@ -1,20 +1,18 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.settings.Settings;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Xephi59
|
* @author Xephi59
|
||||||
*/
|
*/
|
||||||
public class CrazyLoginConverter implements Converter {
|
public class CrazyLoginConverter implements Converter {
|
||||||
@ -33,22 +31,17 @@ public class CrazyLoginConverter implements Converter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String fileName;
|
|
||||||
private static File source;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fileName = Settings.crazyloginFileName;
|
String fileName = Settings.crazyloginFileName;
|
||||||
try {
|
try {
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
File source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
||||||
if (!source.exists()) {
|
if (!source.exists()) {
|
||||||
sender.sendMessage("Error while trying to import datas, please put " + fileName + " in AuthMe folder!");
|
sender.sendMessage("Error while trying to import datas, please put " + fileName + " in AuthMe folder!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
source.createNewFile();
|
|
||||||
BufferedReader users = null;
|
|
||||||
String line;
|
String line;
|
||||||
users = new BufferedReader(new FileReader(source));
|
BufferedReader users = new BufferedReader(new FileReader(source));
|
||||||
while ((line = users.readLine()) != null) {
|
while ((line = users.readLine()) != null) {
|
||||||
if (line.contains("|")) {
|
if (line.contains("|")) {
|
||||||
String[] args = line.split("\\|");
|
String[] args = line.split("\\|");
|
||||||
@ -58,12 +51,9 @@ public class CrazyLoginConverter implements Converter {
|
|||||||
continue;
|
continue;
|
||||||
String player = args[0].toLowerCase();
|
String player = args[0].toLowerCase();
|
||||||
String psw = args[1];
|
String psw = args[1];
|
||||||
try {
|
if (psw != null) {
|
||||||
if (player != null && psw != null) {
|
PlayerAuth auth = new PlayerAuth(player, psw, "127.0.0.1", System.currentTimeMillis(), player);
|
||||||
PlayerAuth auth = new PlayerAuth(player, psw, "127.0.0.1", System.currentTimeMillis(), player);
|
database.saveAuth(auth);
|
||||||
database.saveAuth(auth);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,12 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Xephi59
|
* @author Xephi59
|
||||||
*/
|
*/
|
||||||
public class FlatToSql implements Converter {
|
public class FlatToSql implements Converter {
|
||||||
@ -29,8 +23,6 @@ public class FlatToSql implements Converter {
|
|||||||
private static String columnEmail;
|
private static String columnEmail;
|
||||||
private static String columnLogged;
|
private static String columnLogged;
|
||||||
private static String columnID;
|
private static String columnID;
|
||||||
private static File source;
|
|
||||||
private static File output;
|
|
||||||
|
|
||||||
public FlatToSql() {
|
public FlatToSql() {
|
||||||
tableName = Settings.getMySQLTablename;
|
tableName = Settings.getMySQLTablename;
|
||||||
@ -50,9 +42,9 @@ public class FlatToSql implements Converter {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
File source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
||||||
source.createNewFile();
|
source.createNewFile();
|
||||||
output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "authme.sql");
|
File output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "authme.sql");
|
||||||
output.createNewFile();
|
output.createNewFile();
|
||||||
BufferedReader br = new BufferedReader(new FileReader(source));
|
BufferedReader br = new BufferedReader(new FileReader(source));
|
||||||
BufferedWriter sql = new BufferedWriter(new FileWriter(output));
|
BufferedWriter sql = new BufferedWriter(new FileWriter(output));
|
||||||
|
|||||||
@ -1,44 +1,44 @@
|
|||||||
package fr.xephi.authme.converter;
|
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.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
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 implements Converter {
|
public class FlatToSqlite implements Converter {
|
||||||
|
|
||||||
public CommandSender sender;
|
public 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;
|
||||||
public FlatToSqlite(CommandSender sender) {
|
public FlatToSqlite(CommandSender sender) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String tableName;
|
private static void close(AutoCloseable o) {
|
||||||
private static String columnName;
|
if (o != null) {
|
||||||
private static String columnPassword;
|
try {
|
||||||
private static String columnIp;
|
o.close();
|
||||||
private static String columnLastLogin;
|
} catch (Exception ex) {
|
||||||
private static String lastlocX;
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
private static String lastlocY;
|
}
|
||||||
private static String lastlocZ;
|
}
|
||||||
private static String lastlocWorld;
|
}
|
||||||
private static String columnEmail;
|
|
||||||
private static File source;
|
|
||||||
private static String database;
|
|
||||||
private static String columnID;
|
|
||||||
private static Connection con;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -55,6 +55,12 @@ public class FlatToSqlite implements Converter {
|
|||||||
columnEmail = Settings.getMySQLColumnEmail;
|
columnEmail = Settings.getMySQLColumnEmail;
|
||||||
columnID = Settings.getMySQLColumnId;
|
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 {
|
try {
|
||||||
connect();
|
connect();
|
||||||
setup();
|
setup();
|
||||||
@ -62,14 +68,12 @@ public class FlatToSqlite implements Converter {
|
|||||||
sender.sendMessage("Some error appeared while trying to setup and connect to sqlite database... Aborting");
|
sender.sendMessage("Some error appeared while trying to setup and connect to sqlite database... Aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
try (BufferedReader reader = new BufferedReader(new FileReader(source))) {
|
||||||
source.createNewFile();
|
|
||||||
BufferedReader br = new BufferedReader(new FileReader(source));
|
|
||||||
String line;
|
String line;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
String newline;
|
String newline;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
String[] args = line.split(":");
|
String[] args = line.split(":");
|
||||||
if (args.length == 4)
|
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');";
|
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, 'world', 'your@email.com');";
|
||||||
@ -84,25 +88,23 @@ public class FlatToSqlite implements Converter {
|
|||||||
saveAuth(newline);
|
saveAuth(newline);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
br.close();
|
String resp = "The FlatFile has been converted to " + database + ".db file";
|
||||||
ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
|
ConsoleLogger.info(resp);
|
||||||
close();
|
sender.sendMessage(resp);
|
||||||
sender.sendMessage("The FlatFile has been converted to " + database + ".db file");
|
|
||||||
return;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
sender.sendMessage("Can't open the flat database file! Does it exist?");
|
sender.sendMessage("Can't open the flat database file!");
|
||||||
|
} finally {
|
||||||
|
close(con);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized static void connect()
|
private synchronized void connect() throws ClassNotFoundException, SQLException {
|
||||||
throws ClassNotFoundException, SQLException {
|
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
|
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized static void setup() throws SQLException {
|
private synchronized void setup() throws SQLException {
|
||||||
Statement st = null;
|
Statement st = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
@ -145,7 +147,7 @@ public class FlatToSqlite implements Converter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized boolean saveAuth(String s) {
|
private synchronized boolean saveAuth(String s) {
|
||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
pst = con.prepareStatement(s);
|
pst = con.prepareStatement(s);
|
||||||
@ -158,32 +160,4 @@ public class FlatToSqlite implements Converter {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void close(Statement st) {
|
|
||||||
if (st != null) {
|
|
||||||
try {
|
|
||||||
st.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void close(ResultSet rs) {
|
|
||||||
if (rs != null) {
|
|
||||||
try {
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized static void close() {
|
|
||||||
try {
|
|
||||||
con.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.SQLite;
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class ForceFlatToSqlite implements Converter {
|
public class ForceFlatToSqlite implements Converter {
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ public class ForceFlatToSqlite implements Converter {
|
|||||||
auth.setRealName("Player");
|
auth.setRealName("Player");
|
||||||
sqlite.saveAuth(auth);
|
sqlite.saveAuth(auth);
|
||||||
}
|
}
|
||||||
plugin.getSettings().setValue("DataSource.backend", "sqlite");
|
Settings.setValue("DataSource.backend", "sqlite");
|
||||||
ConsoleLogger.info("Database successfully converted to sqlite !");
|
ConsoleLogger.info("Database successfully converted to sqlite !");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("An error appeared while trying to convert flatfile to sqlite ...");
|
ConsoleLogger.showError("An error appeared while trying to convert flatfile to sqlite ...");
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
package fr.xephi.authme.converter;
|
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.security.HashAlgorithm;
|
||||||
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@ -8,18 +17,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
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
|
* @author Xephi59
|
||||||
*/
|
*/
|
||||||
public class RakamakConverter implements Converter {
|
public class RakamakConverter implements Converter {
|
||||||
@ -38,27 +36,19 @@ public class RakamakConverter implements Converter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean useIP;
|
|
||||||
private static String fileName;
|
|
||||||
private static String ipFileName;
|
|
||||||
private static File source;
|
|
||||||
private static File ipfiles;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HashAlgorithm hash = Settings.getPasswordHash;
|
HashAlgorithm hash = Settings.getPasswordHash;
|
||||||
useIP = Settings.rakamakUseIp;
|
boolean useIP = Settings.rakamakUseIp;
|
||||||
fileName = Settings.rakamakUsers;
|
String fileName = Settings.rakamakUsers;
|
||||||
ipFileName = Settings.rakamakUsersIp;
|
String ipFileName = Settings.rakamakUsersIp;
|
||||||
HashMap<String, String> playerIP = new HashMap<String, String>();
|
File source = new File(Settings.PLUGIN_FOLDER, fileName);
|
||||||
HashMap<String, String> playerPSW = new HashMap<String, String>();
|
File ipfiles = new File(Settings.PLUGIN_FOLDER, ipFileName);
|
||||||
|
HashMap<String, String> playerIP = new HashMap<>();
|
||||||
|
HashMap<String, String> playerPSW = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
BufferedReader users;
|
||||||
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
|
BufferedReader ipFile;
|
||||||
source.createNewFile();
|
|
||||||
ipfiles.createNewFile();
|
|
||||||
BufferedReader users = null;
|
|
||||||
BufferedReader ipFile = null;
|
|
||||||
ipFile = new BufferedReader(new FileReader(ipfiles));
|
ipFile = new BufferedReader(new FileReader(ipfiles));
|
||||||
String line;
|
String line;
|
||||||
if (useIP) {
|
if (useIP) {
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class RoyalAuthConverter implements Converter {
|
public class RoyalAuthConverter implements Converter {
|
||||||
|
|
||||||
@ -24,8 +23,8 @@ public class RoyalAuthConverter implements Converter {
|
|||||||
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
|
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
|
||||||
try {
|
try {
|
||||||
String name = o.getName().toLowerCase();
|
String name = o.getName().toLowerCase();
|
||||||
String separator = File.separator;
|
String sp = File.separator;
|
||||||
File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
|
File file = new File("." + sp + "plugins" + sp + "RoyalAuth" + sp + "userdata" + sp + name + ".yml");
|
||||||
if (data.isAuthAvailable(name))
|
if (data.isAuthAvailable(name))
|
||||||
continue;
|
continue;
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
@ -34,6 +33,7 @@ public class RoyalAuthConverter implements Converter {
|
|||||||
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com");
|
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com");
|
||||||
data.saveAuth(auth);
|
data.saveAuth(auth);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
ConsoleLogger.writeStackTrace(e);
|
||||||
ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
|
ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import fr.xephi.authme.settings.CustomConfiguration;
|
import fr.xephi.authme.settings.CustomConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class RoyalAuthYamlReader extends CustomConfiguration {
|
public class RoyalAuthYamlReader extends CustomConfiguration {
|
||||||
|
|
||||||
public RoyalAuthYamlReader(File file) {
|
public RoyalAuthYamlReader(File file) {
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.FlatFile;
|
import fr.xephi.authme.datasource.FlatFile;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SqlToFlat implements Converter {
|
public class SqlToFlat implements Converter {
|
||||||
|
|
||||||
@ -38,11 +37,9 @@ public class SqlToFlat implements Converter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage("Successfully convert from SQL table to file auths.db");
|
sender.sendMessage("Successfully convert from SQL table to file auths.db");
|
||||||
return;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
Messages.getInstance().send(sender, "error");
|
Messages.getInstance().send(sender, "error");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class vAuthConverter implements Converter {
|
public class vAuthConverter implements Converter {
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
package fr.xephi.authme.converter;
|
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 org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
|
||||||
|
|
||||||
public class vAuthFileReader {
|
public class vAuthFileReader {
|
||||||
|
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
@ -27,21 +27,19 @@ public class vAuthFileReader {
|
|||||||
|
|
||||||
public void convert() throws IOException {
|
public void convert() throws IOException {
|
||||||
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
|
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
|
||||||
Scanner scanner = null;
|
Scanner scanner;
|
||||||
try {
|
try {
|
||||||
scanner = new Scanner(file);
|
scanner = new Scanner(file);
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
String line = scanner.nextLine();
|
String line = scanner.nextLine();
|
||||||
String name = line.split(": ")[0];
|
String name = line.split(": ")[0];
|
||||||
String password = line.split(": ")[1];
|
String password = line.split(": ")[1];
|
||||||
PlayerAuth auth = null;
|
PlayerAuth auth;
|
||||||
if (isUUIDinstance(password)) {
|
if (isUUIDinstance(password)) {
|
||||||
String pname = null;
|
String pname;
|
||||||
try {
|
try {
|
||||||
pname = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
|
pname = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
|
||||||
} catch (Exception e) {
|
} catch (Exception | NoSuchMethodError e) {
|
||||||
pname = getName(UUID.fromString(name));
|
|
||||||
} catch (NoSuchMethodError e) {
|
|
||||||
pname = getName(UUID.fromString(name));
|
pname = getName(UUID.fromString(name));
|
||||||
}
|
}
|
||||||
if (pname == null)
|
if (pname == null)
|
||||||
@ -50,10 +48,10 @@ public class vAuthFileReader {
|
|||||||
} else {
|
} else {
|
||||||
auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com");
|
auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com");
|
||||||
}
|
}
|
||||||
if (auth != null)
|
database.saveAuth(auth);
|
||||||
database.saveAuth(auth);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
ConsoleLogger.writeStackTrace(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -70,7 +68,7 @@ public class vAuthFileReader {
|
|||||||
if (op.getUniqueId().compareTo(uuid) == 0)
|
if (op.getUniqueId().compareTo(uuid) == 0)
|
||||||
return op.getName();
|
return op.getName();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class xAuthConverter implements Converter {
|
public class xAuthConverter implements Converter {
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,13 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
|
import de.luricos.bukkit.xAuth.database.DatabaseTables;
|
||||||
|
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
||||||
|
import de.luricos.bukkit.xAuth.xAuth;
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -8,15 +16,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import de.luricos.bukkit.xAuth.xAuth;
|
|
||||||
import de.luricos.bukkit.xAuth.database.DatabaseTables;
|
|
||||||
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
|
||||||
|
|
||||||
public class xAuthToFlat {
|
public class xAuthToFlat {
|
||||||
|
|
||||||
public AuthMe instance;
|
public AuthMe instance;
|
||||||
@ -82,7 +81,7 @@ public class xAuthToFlat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getXAuthPlayers() {
|
public List<Integer> getXAuthPlayers() {
|
||||||
List<Integer> xP = new ArrayList<Integer>();
|
List<Integer> xP = new ArrayList<>();
|
||||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -95,7 +94,7 @@ public class xAuthToFlat {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
xAuthLog.severe("Cannot import xAuthPlayers", e);
|
xAuthLog.severe("Cannot import xAuthPlayers", e);
|
||||||
return new ArrayList<Integer>();
|
return new ArrayList<>();
|
||||||
} finally {
|
} finally {
|
||||||
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
|
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class Settings extends YamlConfiguration {
|
public final class Settings extends YamlConfiguration {
|
||||||
|
|
||||||
private AuthMe plugin;
|
private static AuthMe plugin;
|
||||||
|
private static Settings instance;
|
||||||
|
|
||||||
// This is not an option!
|
// This is not an option!
|
||||||
public static Boolean antiBotInAction = false;
|
public static Boolean antiBotInAction = false;
|
||||||
@ -94,24 +95,25 @@ public final class Settings extends YamlConfiguration {
|
|||||||
|
|
||||||
protected static YamlConfiguration configFile;
|
protected static YamlConfiguration configFile;
|
||||||
|
|
||||||
public Settings(AuthMe plugin) {
|
public Settings(AuthMe pl) {
|
||||||
configFile = (YamlConfiguration) plugin.getConfig();
|
configFile = (YamlConfiguration) plugin.getConfig();
|
||||||
this.plugin = plugin;
|
plugin = pl;
|
||||||
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void reload() throws Exception {
|
public static void reload() throws Exception {
|
||||||
plugin.getLogger().info("Loading Configuration File...");
|
plugin.getLogger().info("Loading Configuration File...");
|
||||||
boolean exist = SETTINGS_FILE.exists();
|
boolean exist = SETTINGS_FILE.exists();
|
||||||
if (!exist) {
|
if (!exist) {
|
||||||
plugin.saveDefaultConfig();
|
plugin.saveDefaultConfig();
|
||||||
}
|
}
|
||||||
load(SETTINGS_FILE);
|
instance.load(SETTINGS_FILE);
|
||||||
if (exist) {
|
if (exist) {
|
||||||
mergeConfig();
|
instance.mergeConfig();
|
||||||
}
|
}
|
||||||
loadVariables();
|
loadVariables();
|
||||||
if (exist) {
|
if (exist) {
|
||||||
saveDefaults();
|
instance.saveDefaults();
|
||||||
}
|
}
|
||||||
messageFile = new File(PLUGIN_FOLDER, "messages" + File.separator + "messages_" + messagesLanguage + ".yml");
|
messageFile = new File(PLUGIN_FOLDER, "messages" + File.separator + "messages_" + messagesLanguage + ".yml");
|
||||||
}
|
}
|
||||||
@ -481,9 +483,9 @@ public final class Settings extends YamlConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String key, Object value) {
|
public static void setValue(String key, Object value) {
|
||||||
this.set(key, value);
|
instance.set(key, value);
|
||||||
this.save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashAlgorithm getPasswordHash() {
|
private static HashAlgorithm getPasswordHash() {
|
||||||
@ -539,9 +541,9 @@ public final class Settings extends YamlConfiguration {
|
|||||||
*
|
*
|
||||||
* @return True if saved successfully
|
* @return True if saved successfully
|
||||||
*/
|
*/
|
||||||
public final boolean save() {
|
public static boolean save() {
|
||||||
try {
|
try {
|
||||||
save(SETTINGS_FILE);
|
instance.save(SETTINGS_FILE);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user