#430 Remove PlayerAuth constructors in favor of builder
- Remove various PlayerAuth constructors - Clean up FlatFile class - Add some javadoc to PlayerAuth
This commit is contained in:
@@ -31,27 +31,13 @@ public class CrazyLoginConverter implements Converter {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
*
|
||||
* @return CrazyLoginConverter
|
||||
*/
|
||||
public CrazyLoginConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
String fileName = Settings.crazyloginFileName;
|
||||
try {
|
||||
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!");
|
||||
sender.sendMessage("Error while trying to import data, please put " + fileName + " in AuthMe folder!");
|
||||
return;
|
||||
}
|
||||
String line;
|
||||
@@ -59,14 +45,17 @@ public class CrazyLoginConverter implements Converter {
|
||||
while ((line = users.readLine()) != null) {
|
||||
if (line.contains("|")) {
|
||||
String[] args = line.split("\\|");
|
||||
if (args.length < 2)
|
||||
if (args.length < 2 || "name".equalsIgnoreCase(args[0])) {
|
||||
continue;
|
||||
if (args[0].equalsIgnoreCase("name"))
|
||||
continue;
|
||||
String playerName = args[0].toLowerCase();
|
||||
}
|
||||
String playerName = args[0];
|
||||
String psw = args[1];
|
||||
if (psw != null) {
|
||||
PlayerAuth auth = new PlayerAuth(playerName, psw, "127.0.0.1", System.currentTimeMillis(), playerName);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(playerName.toLowerCase())
|
||||
.realName(playerName)
|
||||
.password(psw, null)
|
||||
.build();
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
|
||||
import static fr.xephi.authme.util.StringUtils.makePath;
|
||||
|
||||
class vAuthFileReader {
|
||||
|
||||
private final AuthMe plugin;
|
||||
@@ -28,7 +30,7 @@ class vAuthFileReader {
|
||||
}
|
||||
|
||||
public void convert() {
|
||||
final File file = new File(plugin.getDataFolder().getParent() + File.separator + "vAuth" + File.separator + "passwords.yml");
|
||||
final File file = new File(plugin.getDataFolder().getParent(), makePath("vAuth", "passwords.yml"));
|
||||
Scanner scanner;
|
||||
try {
|
||||
scanner = new Scanner(file);
|
||||
@@ -46,9 +48,15 @@ class vAuthFileReader {
|
||||
}
|
||||
if (pname == null)
|
||||
continue;
|
||||
auth = new PlayerAuth(pname.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", pname);
|
||||
auth = PlayerAuth.builder()
|
||||
.name(pname.toLowerCase())
|
||||
.realName(pname)
|
||||
.password(password, null).build();
|
||||
} else {
|
||||
auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", name);
|
||||
auth = PlayerAuth.builder()
|
||||
.name(name.toLowerCase())
|
||||
.realName(name)
|
||||
.password(password, null).build();
|
||||
}
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,10 @@ class xAuthToFlat {
|
||||
String pl = getIdPlayer(id);
|
||||
String psw = getPassword(id);
|
||||
if (psw != null && !psw.isEmpty() && pl != null) {
|
||||
PlayerAuth auth = new PlayerAuth(pl, psw, "192.168.0.1", 0, "your@email.com", pl);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(pl.toLowerCase())
|
||||
.realName(pl)
|
||||
.password(psw, null).build();
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
@@ -69,7 +72,8 @@ class xAuthToFlat {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(DatabaseTables.ACCOUNT));
|
||||
String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(DatabaseTables.ACCOUNT));
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, id);
|
||||
rs = ps.executeQuery();
|
||||
@@ -91,7 +95,8 @@ class xAuthToFlat {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin().getDatabaseController().getTable(DatabaseTables.ACCOUNT));
|
||||
String sql = String.format("SELECT * FROM `%s`",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(DatabaseTables.ACCOUNT));
|
||||
ps = conn.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
@@ -112,7 +117,8 @@ class xAuthToFlat {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(DatabaseTables.ACCOUNT));
|
||||
String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(DatabaseTables.ACCOUNT));
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, accountId);
|
||||
rs = ps.executeQuery();
|
||||
|
||||
Reference in New Issue
Block a user