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