From 4a0ea72c73006ba4b3cad31240f66c748f53d96b Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Wed, 14 Dec 2022 13:39:33 +0300 Subject: Fix duplicate entry and possible fix of "must provide non-null hash" --- src/main/java/net/elytrium/limboauth/LimboAuth.java | 14 +++++++++++++- .../java/net/elytrium/limboauth/listener/AuthListener.java | 10 ---------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index b2d2e43..f8e3755 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -494,8 +494,20 @@ public class LimboAuth { if (onlineMode || isFloodgate) { if (registeredPlayer == null || registeredPlayer.getHash().isEmpty()) { + RegisteredPlayer nicknameRegisteredPlayer = registeredPlayer; registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, player.getUniqueId()); - if (registeredPlayer == null && Settings.IMP.MAIN.SAVE_PREMIUM_ACCOUNTS) { + + if (nicknameRegisteredPlayer != null && registeredPlayer == null && nicknameRegisteredPlayer.getHash().isEmpty()) { + registeredPlayer = nicknameRegisteredPlayer; + registeredPlayer.setPremiumUuid(player.getUniqueId().toString()); + try { + this.playerDao.update(registeredPlayer); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + if (nicknameRegisteredPlayer == null && registeredPlayer == null && Settings.IMP.MAIN.SAVE_PREMIUM_ACCOUNTS) { registeredPlayer = new RegisteredPlayer( nickname, nickname.toLowerCase(Locale.ROOT), diff --git a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java index 2c4b668..2529e80 100644 --- a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java +++ b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java @@ -94,16 +94,6 @@ public class AuthListener { if (registeredPlayer != null) { String currentUuid = registeredPlayer.getUuid(); - if (event.isOnlineMode() && registeredPlayer.getHash().isEmpty() && registeredPlayer.getPremiumUuid().isEmpty()) { - try { - registeredPlayer.setPremiumUuid(event.getOriginalProfile().getId().toString()); - this.playerDao.update(registeredPlayer); - } catch (SQLException e) { - e.printStackTrace(); - return; - } - } - if (currentUuid.isEmpty()) { try { registeredPlayer.setUuid(event.getGameProfile().getId().toString()); -- cgit