fix: players removing fix again

This commit is contained in:
ChomeNS
2025-03-30 18:12:40 +07:00
parent 363d7a9270
commit 821bfe2626
3 changed files with 9 additions and 4 deletions

View File

@@ -257,7 +257,10 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener {
final CompletableFuture<String> 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);

View File

@@ -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();