aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/elytrium/limboauth/LimboAuth.java10
-rw-r--r--src/main/java/net/elytrium/limboauth/floodgate/FloodgateApiHolder.java4
-rw-r--r--src/main/java/net/elytrium/limboauth/listener/AuthListener.java11
3 files changed, 19 insertions, 6 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()) {
diff --git a/src/main/java/net/elytrium/limboauth/floodgate/FloodgateApiHolder.java b/src/main/java/net/elytrium/limboauth/floodgate/FloodgateApiHolder.java
index 8832d4b..9e0b96d 100644
--- a/src/main/java/net/elytrium/limboauth/floodgate/FloodgateApiHolder.java
+++ b/src/main/java/net/elytrium/limboauth/floodgate/FloodgateApiHolder.java
@@ -34,4 +34,8 @@ public class FloodgateApiHolder {
public boolean isFloodgatePlayer(UUID uuid) {
return this.floodgateApi.isFloodgatePlayer(uuid);
}
+
+ public int getPrefixLength() {
+ return this.floodgateApi.getPlayerPrefix().length();
+ }
}
diff --git a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java
index 1bed937..9ff6b6f 100644
--- a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java
+++ b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java
@@ -22,15 +22,16 @@ import com.j256.ormlite.stmt.UpdateBuilder;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.event.connection.PreLoginEvent;
+import com.velocitypowered.api.event.player.GameProfileRequestEvent;
import com.velocitypowered.api.util.UuidUtils;
import java.sql.SQLException;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import net.elytrium.limboapi.api.event.LoginLimboRegisterEvent;
-import net.elytrium.limboapi.api.event.SafeGameProfileRequestEvent;
import net.elytrium.limboauth.LimboAuth;
import net.elytrium.limboauth.Settings;
+import net.elytrium.limboauth.floodgate.FloodgateApiHolder;
import net.elytrium.limboauth.handler.AuthSessionHandler;
import net.elytrium.limboauth.model.RegisteredPlayer;
@@ -39,10 +40,12 @@ public class AuthListener {
private final LimboAuth plugin;
private final Dao<RegisteredPlayer, String> playerDao;
+ private final FloodgateApiHolder floodgateApi;
- public AuthListener(LimboAuth plugin, Dao<RegisteredPlayer, String> playerDao) {
+ public AuthListener(LimboAuth plugin, Dao<RegisteredPlayer, String> playerDao, FloodgateApiHolder floodgateApi) {
this.plugin = plugin;
this.playerDao = playerDao;
+ this.floodgateApi = floodgateApi;
}
@Subscribe
@@ -77,8 +80,8 @@ public class AuthListener {
}
@Subscribe
- public void onGameProfileRequest(SafeGameProfileRequestEvent event) {
- if (Settings.IMP.MAIN.SAVE_UUID) {
+ public void onGameProfileRequest(GameProfileRequestEvent event) {
+ if (Settings.IMP.MAIN.SAVE_UUID && (this.floodgateApi == null || !this.floodgateApi.isFloodgatePlayer(event.getOriginalProfile().getId()))) {
RegisteredPlayer registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, event.getOriginalProfile().getId());
if (registeredPlayer != null) {