From 817eedd4ac036a92743f7c785b552da6a8e2d414 Mon Sep 17 00:00:00 2001 From: Smart123s <28480228+Smart123s@users.noreply.github.com> Date: Fri, 25 Feb 2022 18:00:21 +0100 Subject: [PATCH 1/2] Move autoLoginFloodgate check to a common function Reduces duplicate code. Added missing check for "no-conflict". --- .../fastlogin/bukkit/task/FloodgateAuthTask.java | 3 +-- .../fastlogin/bungee/task/FloodgateAuthTask.java | 6 +----- .../fastlogin/core/shared/FloodgateManagement.java | 11 +++++++++++ 3 files changed, 13 insertions(+), 7 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 2df2305b..bc8f4993 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,8 +49,7 @@ public class FloodgateAuthTask extends FloodgateManagement Date: Fri, 25 Feb 2022 18:12:50 +0100 Subject: [PATCH 2/2] 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); } /**