Write more unit tests for listeners, minor cleanup

This commit is contained in:
ljacqu
2016-08-06 13:21:39 +02:00
parent fcb50f2fd5
commit eef314b965
8 changed files with 467 additions and 19 deletions
@@ -82,15 +82,14 @@ public class RakamakConverter implements Converter {
.realName(playerName)
.ip(ip)
.password(psw)
.lastLogin(System.currentTimeMillis())
.lastLogin(0)
.build();
database.saveAuth(auth);
}
ConsoleLogger.info("Rakamak database has been imported correctly");
sender.sendMessage("Rakamak database has been imported correctly");
} catch (IOException ex) {
ConsoleLogger.warning(ex.getMessage());
sender.sendMessage("Can't open the rakamak database file! Does it exist?");
ConsoleLogger.logException("Can't open the rakamak database file! Does it exist?", ex);
}
}
}
@@ -877,8 +877,7 @@ public class MySQL implements DataSource {
* @param metaData lastlogin column meta data
* @throws SQLException
*/
@VisibleForTesting
protected void migrateLastLoginColumn(Connection con, DatabaseMetaData metaData) throws SQLException {
private void migrateLastLoginColumn(Connection con, DatabaseMetaData metaData) throws SQLException {
final int columnType;
try (ResultSet rs = metaData.getColumns(null, null, tableName, col.LAST_LOGIN)) {
if (!rs.next()) {
@@ -6,9 +6,9 @@ import fr.xephi.authme.util.StringUtils;
/**
* Exception thrown when a verification has failed.
*/
@SuppressWarnings("serial")
public class FailedVerificationException extends Exception {
private static final long serialVersionUID = 3903242223297960699L;
private final MessageKey reason;
private final String[] args;
@@ -225,7 +225,7 @@ public class PlayerListener implements Listener {
// Get the auth later as this may cause the single session check to fail
// Slow stuff
final PlayerAuth auth = dataSource.getAuth(player.getName());
final PlayerAuth auth = dataSource.getAuth(name);
final boolean isAuthAvailable = (auth != null);
final String lowerName = name.toLowerCase();
onJoinVerifier.checkAntibot(lowerName, isAuthAvailable);
@@ -49,9 +49,7 @@ public class ServerListener implements Listener {
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
spawnLoader.unloadEssentialsSpawn();
ConsoleLogger.info("EssentialsSpawn has been disabled: unhooking");
}
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
protocolLibService.disable();
ConsoleLogger.warning("ProtocolLib has been disabled, unhooking packet adapters!");
}
@@ -77,9 +75,7 @@ public class ServerListener implements Listener {
pluginHooks.tryHookToCombatPlus();
} else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) {
spawnLoader.loadEssentialsSpawn();
}
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
} else if ("ProtocolLib".equalsIgnoreCase(pluginName)) {
protocolLibService.setup();
}
}