Move autoLoginFloodgate check to a common function

Reduces duplicate code.
Added missing check for "no-conflict".
This commit is contained in:
Smart123s
2022-02-25 18:00:21 +01:00
parent 033fdd55ae
commit 817eedd4ac
3 changed files with 13 additions and 7 deletions

View File

@ -49,8 +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(autoLoginFloodgate.equals("true")
|| (autoLoginFloodgate.equals("linked") && isLinked));
session.setVerified(isAutoLoginAllowed());
// run login task
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, session);

View File

@ -55,13 +55,9 @@ public class FloodgateAuthTask
BungeeLoginSession session = new BungeeLoginSession(player.getName(), isRegistered, profile);
core.getPlugin().getSession().put(player.getPendingConnection(), session);
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
boolean forcedOnlineMode = autoLoginFloodgate.equals("true")
|| (autoLoginFloodgate.equals("linked") && isLinked);
// run login task
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, server, session,
forcedOnlineMode);
isAutoLoginAllowed());
core.getPlugin().getScheduler().runAsync(forceLoginTask);
}

View File

@ -145,6 +145,17 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
|| ("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);
}
/**
* Decides wether checks for conflicting Java names should be made
* @return ture if an API call to Mojang is needed