From 7e9bd1639b95f7a2303dc4e63b02c0dcb70bc3ee Mon Sep 17 00:00:00 2001 From: Smart123s <28480228+Smart123s@users.noreply.github.com> Date: Fri, 25 Feb 2022 18:12:50 +0100 Subject: [PATCH] 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. --- .../bukkit/task/FloodgateAuthTask.java | 2 +- .../bungee/task/FloodgateAuthTask.java | 2 +- .../core/shared/FloodgateManagement.java | 29 +++++++------------ 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java index bc8f4993..6bf5b4bd 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java @@ -49,7 +49,7 @@ public class FloodgateAuthTask extends FloodgateManagement + * 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); } /**