forked from TuxCoding/FastLogin
Move similar config checks to a common function
'autoRegisterFloodgate' and 'autoLoginFloodgate' have the same possible options, and they are checked against the player in the exact same way. For example, if either one of them is set to isLinked, linked status is checked in the same way, regardless of wether it's checked for login or for registering.
This commit is contained in:
@ -49,7 +49,7 @@ public class FloodgateAuthTask extends FloodgateManagement<Player, CommandSender
|
||||
BukkitLoginSession session = new BukkitLoginSession(player.getName(), isRegistered, profile);
|
||||
|
||||
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
|
||||
session.setVerified(isAutoLoginAllowed());
|
||||
session.setVerified(isAutoAuthAllowed(autoLoginFloodgate));
|
||||
|
||||
// run login task
|
||||
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, session);
|
||||
|
@ -57,7 +57,7 @@ public class FloodgateAuthTask
|
||||
|
||||
// run login task
|
||||
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, server, session,
|
||||
isAutoLoginAllowed());
|
||||
isAutoAuthAllowed(autoLoginFloodgate));
|
||||
core.getPlugin().getScheduler().runAsync(forceLoginTask);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
|
||||
}
|
||||
}
|
||||
|
||||
if (!isRegistered && !isAutoRegisterAllowed()) {
|
||||
if (!isRegistered && !isAutoAuthAllowed(autoRegisterFloodgate)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -135,25 +135,18 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
|
||||
}
|
||||
|
||||
/**
|
||||
* Decude if the player can be auto registered.
|
||||
* The config option 'non-conflicting' is ignored by this function.
|
||||
* Decide if the player can be automatically registered or logged in.<br>
|
||||
* The config option 'non-conflicting' is ignored by this function, as name
|
||||
* conflicts are checked by a different part of the code.
|
||||
*
|
||||
* @param configValue the value of either 'autoLoginFloodgate' or
|
||||
* 'autoRegisterFloodgate' from config.yml
|
||||
* @return true if the Player can be registered automatically
|
||||
*/
|
||||
private boolean isAutoRegisterAllowed() {
|
||||
return "true".equals(autoRegisterFloodgate)
|
||||
|| "no-conflict".equals(autoRegisterFloodgate) // this was checked before
|
||||
|| ("linked".equals(autoRegisterFloodgate) && isLinked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide if the player can be auto logged in.
|
||||
* The config option 'non-conflicting' is ignored by this function.
|
||||
* @return true if the Player can be logged in automatically
|
||||
*/
|
||||
protected boolean isAutoLoginAllowed() {
|
||||
return "true".equals(autoLoginFloodgate)
|
||||
|| "no-conflict".equals(autoRegisterFloodgate) // this was checked before
|
||||
|| ("linked".equals(autoLoginFloodgate) && isLinked);
|
||||
protected boolean isAutoAuthAllowed(String configValue) {
|
||||
return "true".equals(configValue)
|
||||
|| "no-conflict".equals(configValue) // this was checked before
|
||||
|| ("linked".equals(configValue) && isLinked);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user