mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 18:55:11 +01:00
reordering local variable scope in captcha command
This commit is contained in:
parent
d7f9b602c7
commit
b4b92e5a93
@ -25,18 +25,6 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
// Messages instance
|
||||
final Messages m = Messages.getInstance();
|
||||
|
||||
// Random string instance, for captcha generation (I think) -- timvisee
|
||||
RandomString randStr = new RandomString(Settings.captchaLength);
|
||||
|
||||
// Get the parameter values
|
||||
String captcha = commandArguments.get(0);
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
@ -46,6 +34,12 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
final Player player = (Player) sender;
|
||||
final String playerNameLowerCase = player.getName().toLowerCase();
|
||||
|
||||
// Get the parameter values
|
||||
String captcha = commandArguments.get(0);
|
||||
|
||||
// Messages instance
|
||||
final Messages m = Messages.getInstance();
|
||||
|
||||
// Command logic
|
||||
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||
m.send(player, "logged_in");
|
||||
@ -57,6 +51,9 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
||||
m.send(player, "usage_log");
|
||||
return true;
|
||||
@ -64,18 +61,16 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
|
||||
if (Settings.useCaptcha && !captcha.equals(plugin.cap.get(playerNameLowerCase))) {
|
||||
plugin.cap.remove(playerNameLowerCase);
|
||||
plugin.cap.put(playerNameLowerCase, randStr.nextString());
|
||||
String randStr = new RandomString(Settings.captchaLength).nextString();
|
||||
plugin.cap.put(playerNameLowerCase, randStr);
|
||||
for (String s : m.send("wrong_captcha")) {
|
||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(playerNameLowerCase)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.captcha.remove(playerNameLowerCase);
|
||||
plugin.cap.remove(playerNameLowerCase);
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
plugin.captcha.remove(playerNameLowerCase);
|
||||
plugin.cap.remove(playerNameLowerCase);
|
||||
|
||||
// Show a status message
|
||||
m.send(player, "valid_captcha");
|
||||
|
@ -19,7 +19,6 @@ import org.bukkit.scheduler.BukkitScheduler;
|
||||
*/
|
||||
public class Management {
|
||||
|
||||
public static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
private final AuthMe plugin;
|
||||
private final BukkitScheduler sched;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user