From 32f93f247e05afaf1d2acd000381f35e9c9f3fcc Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:51:48 +0700 Subject: [PATCH] fix: delay 5 seconds before thinking that the server is vanilla (this is confirmed to still work on actual vanilla servers and on kaboom too) 5 seconds because the server sends out the commands packet a bit later after login, but it seems like the player left packet (which is used to detect vanish) is sent before that --- build-number.txt | 2 +- src/main/java/me/chayapak1/chomens_bot/Bot.java | 2 +- .../java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build-number.txt b/build-number.txt index 693513ad..c994df5e 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3447 \ No newline at end of file +3450 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/Bot.java b/src/main/java/me/chayapak1/chomens_bot/Bot.java index d73cb949..cf9f5504 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Bot.java +++ b/src/main/java/me/chayapak1/chomens_bot/Bot.java @@ -75,7 +75,7 @@ public class Bot extends SessionAdapter { public int connectAttempts = 0; public boolean loggedIn = false; - public long loginTime; + public long loginTime = System.currentTimeMillis(); public final ExecutorService executorService = Main.EXECUTOR_SERVICE; public final ScheduledExecutorService executor = Main.EXECUTOR; diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java index 26cab5aa..750d30e6 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java @@ -368,7 +368,10 @@ public class PlayersPlugin implements Listener { if (target == null) return; - if (!bot.serverFeatures.hasNamespaces || target.profile.getName().isEmpty() /* LoL empty string username lazy fix */) { + if ( + (System.currentTimeMillis() - bot.loginTime > 5 * 1000 && !bot.serverFeatures.hasNamespaces) + || target.profile.getName().isEmpty() // LoL empty string username lazy fix + ) { final boolean removed = list.remove(target); if (removed) {