Fix various code issues as detected by Sonar

Mostly minor changes:
- Add deprecated javadoc tag on deprecated members
- Reduce duplication (FlatFile, BackupService, ...)
- Make methods static
- Reduce size of anonymous classes
- Replace name with displayName in PermissionsSystemType (avoids confusing with Enum name())
- Tabs to spaces
- Merge if statements

Code from third-party sources (BCryptService, BinTools, PHPBB) not modified.
This commit is contained in:
ljacqu
2016-11-22 18:19:46 +01:00
parent 8685e50988
commit 7d65d2a7c4
32 changed files with 172 additions and 197 deletions
@@ -43,20 +43,7 @@ public class CrazyLoginConverter implements Converter {
try (BufferedReader users = new BufferedReader(new FileReader(source))) {
while ((line = users.readLine()) != null) {
if (line.contains("|")) {
String[] args = line.split("\\|");
if (args.length < 2 || "name".equalsIgnoreCase(args[0])) {
continue;
}
String playerName = args[0];
String password = args[1];
if (password != null) {
PlayerAuth auth = PlayerAuth.builder()
.name(playerName.toLowerCase())
.realName(playerName)
.password(password, null)
.build();
database.saveAuth(auth);
}
migrateAccount(line);
}
}
ConsoleLogger.info("CrazyLogin database has been imported correctly");
@@ -66,4 +53,26 @@ public class CrazyLoginConverter implements Converter {
}
}
/**
* Moves an account from CrazyLogin to the AuthMe database.
*
* @param line line read from the CrazyLogin file (one account)
*/
private void migrateAccount(String line) {
String[] args = line.split("\\|");
if (args.length < 2 || "name".equalsIgnoreCase(args[0])) {
return;
}
String playerName = args[0];
String password = args[1];
if (password != null) {
PlayerAuth auth = PlayerAuth.builder()
.name(playerName.toLowerCase())
.realName(playerName)
.password(password, null)
.build();
database.saveAuth(auth);
}
}
}