Use spaces, finish working on #423, import cleanup

This commit is contained in:
Gabriele C 2016-06-13 16:13:03 +02:00
parent 26531e93ef
commit e12ae2cf96
8 changed files with 67 additions and 49 deletions

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;

View File

@ -29,9 +29,12 @@ import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
/**
@ -150,11 +153,18 @@ public class AsynchronousLogin implements AsynchronousProcess {
public void login(final Player player, String password, boolean forceLogin) {
PlayerAuth pAuth = preAuth(player);
if (pAuth == null || needsCaptcha(player)) {
if (pAuth == null) {
return;
}
final String name = player.getName().toLowerCase();
// If Captcha is required send a message to the player and deny to login
if (needsCaptcha(player)) {
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(name));
return;
}
final String ip = Utils.getPlayerIp(player);
// Increase the counts here before knowing the result of the login.
@ -232,7 +242,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
} else {
service.send(player, MessageKey.WRONG_PASSWORD);
// Check again if a captcha is required to log in
// If the authentication fails check if Captcha is required and send a message to the player
if (needsCaptcha(player)) {
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(name));
}
@ -249,14 +259,27 @@ public class AsynchronousLogin implements AsynchronousProcess {
}
List<String> auths = database.getAllAuthsByIp(auth.getIp());
if (auths.size() < 2) {
if (auths.size() <= 1) {
return;
}
// TODO #423: color player names with green if the account is online
String message = StringUtils.join(", ", auths) + ".";
List<String> tmp = new ArrayList<String>();
for(String currentName : auths) {
Player currentPlayer = bukkitService.getPlayerExact(currentName);
if(currentPlayer != null && currentPlayer.isOnline()) {
tmp.add(ChatColor.GREEN + currentName);
} else {
tmp.add(currentName);
}
}
auths = tmp;
String message = StringUtils.join(ChatColor.GRAY + ", ", auths) + ".";
if(!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
ConsoleLogger.info("The user " + player.getName() + " has " + auths.size() + " accounts:");
ConsoleLogger.info(message);
}
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
if (onlinePlayer.getName().equalsIgnoreCase(player.getName())

View File

@ -8,7 +8,6 @@ import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.process.unregister;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
@ -15,7 +14,6 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;

View File

@ -8,7 +8,6 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;