From 821bfe26262d3d3ce610093745a32bb7e1f0355c Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 30 Mar 2025 18:12:40 +0700 Subject: [PATCH] fix: players removing fix again --- build-number.txt | 2 +- .../me/chayapak1/chomens_bot/plugins/PlayersPlugin.java | 7 +++++-- .../java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build-number.txt b/build-number.txt index 3e7488ed..581cdc89 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -2280 \ No newline at end of file +2284 \ No newline at end of file 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 4171a1d6..3bedd6c0 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/PlayersPlugin.java @@ -257,7 +257,10 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener { final CompletableFuture future = getLastKnownName(target.profile.getIdAsString()); future.thenApply(lastKnownName -> { - if (lastKnownName == null) { + // checking for empty string means + // we did get the output from the server, and + // the player doesn't exist or the NBT path doesn't exist + if (lastKnownName.isEmpty()) { final boolean removed = list.remove(target); // checking if removed prevents the event from being called twice @@ -297,7 +300,7 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener { } private void onLastKnownNameTick () { - if (!bot.loggedIn || !bot.serverFeatures.hasNamespaces) return; // hasNamespaces also means vanilla/non-bukkit + if (!bot.loggedIn || !bot.core.ready || !bot.serverFeatures.hasNamespaces) return; // hasNamespaces also means vanilla/non-bukkit for (PlayerEntry target : new ArrayList<>(list)) { check(target); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java index 4719a440..218143e1 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java @@ -52,7 +52,9 @@ public class QueryPlugin extends Bot.Listener implements ChatPlugin.Listener { transactions.remove(transactionId); - if (children.size() == 1 || !(children.get(1) instanceof TextComponent)) { + if (children.size() == 1) { + future.complete(""); + } else if (!(children.get(1) instanceof TextComponent)) { future.complete(null); } else { final String stringOutput = ((TextComponent) children.get(1)).content();