diff options
author | Petr Ilin <hevav@hevav.dev> | 2022-03-20 18:52:02 +0300 |
---|---|---|
committer | Petr Ilin <hevav@hevav.dev> | 2022-03-20 18:52:02 +0300 |
commit | dac848544f9005b81b6446bfc095a3b27d62b5a8 (patch) | |
tree | 505b2009c75a526d5c2dc4fcb7a5abade2185583 /src/main/java/net/elytrium/limboauth/LimboAuth.java | |
parent | 79fae1617259f93def0b4104aaddd174d916c99b (diff) | |
download | LimboAuth-dac848544f9005b81b6446bfc095a3b27d62b5a8.tar.gz LimboAuth-dac848544f9005b81b6446bfc095a3b27d62b5a8.tar.bz2 LimboAuth-dac848544f9005b81b6446bfc095a3b27d62b5a8.zip |
Some floodgate fixes
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/LimboAuth.java')
-rw-r--r-- | src/main/java/net/elytrium/limboauth/LimboAuth.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index c574314..0a56e06 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -277,7 +277,7 @@ public class LimboAuth { .registerCommand(new AuthCommandMeta(this, ImmutableList.of("reg", "register")), new AuthCommand()); this.server.getEventManager().unregisterListeners(this); - this.server.getEventManager().register(this, new AuthListener(this, this.playerDao)); + this.server.getEventManager().register(this, new AuthListener(this, this.playerDao, this.floodgateApi)); Executors.newScheduledThreadPool(1, task -> new Thread(task, "purge-cache")).scheduleAtFixedRate(() -> this.checkCache(this.cachedAuthChecks, Settings.IMP.MAIN.PURGE_CACHE_MILLIS), @@ -357,6 +357,12 @@ public class LimboAuth { public void authPlayer(Player player) { String nickname = player.getUsername(); + boolean isFloodgate = !Settings.IMP.MAIN.FLOODGATE_NEED_AUTH && this.floodgateApi.isFloodgatePlayer(player.getUniqueId()); + + if (isFloodgate) { + nickname = nickname.substring(this.floodgateApi.getPrefixLength()); + } + if (!this.nicknameValidationPattern.matcher(nickname).matches()) { player.disconnect(LegacyComponentSerializer.legacyAmpersand().deserialize(Settings.IMP.MAIN.STRINGS.NICKNAME_INVALID_KICK)); return; @@ -364,7 +370,7 @@ public class LimboAuth { RegisteredPlayer registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, nickname); boolean onlineMode = player.isOnlineMode(); - if (onlineMode || (!Settings.IMP.MAIN.FLOODGATE_NEED_AUTH && this.floodgateApi.isFloodgatePlayer(player.getUniqueId()))) { + if (onlineMode || isFloodgate) { if (registeredPlayer == null || registeredPlayer.getHash().isEmpty()) { registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, player.getUniqueId()); if (registeredPlayer == null || registeredPlayer.getHash().isEmpty()) { |