Merge pull request #737 from Smart123s/fix/736

Fix 'no-conflict' option of 'autoLoginFloodgate' in config
This commit is contained in:
games647
2022-02-26 17:37:37 +01:00
committed by GitHub
3 changed files with 13 additions and 14 deletions

View File

@ -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(isAutoAuthAllowed(autoLoginFloodgate));
|| (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);

View File

@ -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); isAutoAuthAllowed(autoLoginFloodgate));
core.getPlugin().getScheduler().runAsync(forceLoginTask); core.getPlugin().getScheduler().runAsync(forceLoginTask);
} }

View File

@ -120,7 +120,7 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
} }
} }
if (!isRegistered && !isAutoRegisterAllowed()) { if (!isRegistered && !isAutoAuthAllowed(autoRegisterFloodgate)) {
return; return;
} }
@ -135,14 +135,18 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
} }
/** /**
* Decude if the player can be auto registered. * Decide if the player can be automatically registered or logged in.<br>
* The config option 'non-conflicting' is ignored by this function. * 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 * @return true if the Player can be registered automatically
*/ */
private boolean isAutoRegisterAllowed() { protected boolean isAutoAuthAllowed(String configValue) {
return "true".equals(autoRegisterFloodgate) return "true".equals(configValue)
|| "no-conflict".equals(autoRegisterFloodgate) // this was checked before || "no-conflict".equals(configValue) // this was checked before
|| ("linked".equals(autoRegisterFloodgate) && isLinked); || ("linked".equals(configValue) && isLinked);
} }
/** /**