From 008dac8850ac4cb93c1fc25bf92c1dd7049e6394 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Fri, 9 Dec 2022 01:11:09 +0300 Subject: Option to switch the saving of premium accounts --- src/main/java/net/elytrium/limboauth/LimboAuth.java | 19 +++++++++++++++++++ src/main/java/net/elytrium/limboauth/Settings.java | 5 +++++ 2 files changed, 24 insertions(+) (limited to 'src/main/java/net/elytrium') diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index ed04f3a..b2d2e43 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -495,6 +495,25 @@ public class LimboAuth { if (onlineMode || isFloodgate) { if (registeredPlayer == null || registeredPlayer.getHash().isEmpty()) { registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, player.getUniqueId()); + if (registeredPlayer == null && Settings.IMP.MAIN.SAVE_PREMIUM_ACCOUNTS) { + registeredPlayer = new RegisteredPlayer( + nickname, + nickname.toLowerCase(Locale.ROOT), + "", + player.getRemoteAddress().getAddress().getHostAddress(), + "", + System.currentTimeMillis(), + player.getUniqueId().toString(), + player.getUniqueId().toString() + ); + + try { + this.playerDao.create(registeredPlayer); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (registeredPlayer == null || registeredPlayer.getHash().isEmpty()) { // Due to the current connection state, which is set to LOGIN there, we cannot send the packets. // We need to wait for the PLAY connection state to set. diff --git a/src/main/java/net/elytrium/limboauth/Settings.java b/src/main/java/net/elytrium/limboauth/Settings.java index 99bb2f0..68102eb 100644 --- a/src/main/java/net/elytrium/limboauth/Settings.java +++ b/src/main/java/net/elytrium/limboauth/Settings.java @@ -73,6 +73,11 @@ public class Settings extends YamlConfig { "If the player had the cracked account, and switched to the premium account, the cracked UUID will be used." }) public boolean SAVE_UUID = true; + @Comment({ + "Saves in the database the accounts of premium users whose login is via online-mode-need-auth: false", + "Can be disabled to reduce the size of stored data in the database" + }) + public boolean SAVE_PREMIUM_ACCOUNTS = true; public boolean ENABLE_TOTP = true; public boolean TOTP_NEED_PASSWORD = true; public boolean REGISTER_NEED_REPEAT_PASSWORD = true; -- cgit