mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Move autoLoginFloodgate check to a common function
Reduces duplicate code. Added missing check for "no-conflict".
This commit is contained in:
@ -49,8 +49,7 @@ public class FloodgateAuthTask extends FloodgateManagement<Player, CommandSender
|
|||||||
BukkitLoginSession session = new BukkitLoginSession(player.getName(), isRegistered, profile);
|
BukkitLoginSession session = new BukkitLoginSession(player.getName(), isRegistered, profile);
|
||||||
|
|
||||||
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
|
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
|
||||||
session.setVerified(autoLoginFloodgate.equals("true")
|
session.setVerified(isAutoLoginAllowed());
|
||||||
|| (autoLoginFloodgate.equals("linked") && isLinked));
|
|
||||||
|
|
||||||
// run login task
|
// run login task
|
||||||
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, session);
|
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, session);
|
||||||
|
@ -55,13 +55,9 @@ public class FloodgateAuthTask
|
|||||||
BungeeLoginSession session = new BungeeLoginSession(player.getName(), isRegistered, profile);
|
BungeeLoginSession session = new BungeeLoginSession(player.getName(), isRegistered, profile);
|
||||||
core.getPlugin().getSession().put(player.getPendingConnection(), session);
|
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
|
// run login task
|
||||||
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, server, session,
|
Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, server, session,
|
||||||
forcedOnlineMode);
|
isAutoLoginAllowed());
|
||||||
core.getPlugin().getScheduler().runAsync(forceLoginTask);
|
core.getPlugin().getScheduler().runAsync(forceLoginTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,17 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
|
|||||||
|| ("linked".equals(autoRegisterFloodgate) && isLinked);
|
|| ("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
|
* Decides wether checks for conflicting Java names should be made
|
||||||
* @return ture if an API call to Mojang is needed
|
* @return ture if an API call to Mojang is needed
|
||||||
|
Reference in New Issue
Block a user