refactor: check player left and ip query without queue for faster trusted broadcast and filtering

This commit is contained in:
ChomeNS
2025-05-17 17:26:16 +07:00
parent a60baad6f3
commit 5b56f411a1
3 changed files with 11 additions and 13 deletions

View File

@@ -221,10 +221,8 @@ public class CorePlugin implements Listener {
}
}
// thanks chipmunk for this new tellraw method
public CompletableFuture<Component> runTracked (final String command) { return runTracked(false, command); }
public CompletableFuture<Component> runTracked (final boolean useCargo, final String command) {
// thanks chipmunk for this "new" tellraw method which is pretty much used by everyone now
public CompletableFuture<Component> runTracked (final String command) {
if (!ready || command.length() > 32767) return null;
if (!bot.options.useCore) return null;
@@ -240,7 +238,7 @@ public class CorePlugin implements Listener {
final CompletableFuture<Component> trackedFuture = new CompletableFuture<>();
final CompletableFuture<String> future = bot.query.block(useCargo, coreBlock, "LastOutput", true);
final CompletableFuture<String> future = bot.query.block(false, coreBlock, "LastOutput", true);
future.thenApply(output -> {
if (output == null) return null;

View File

@@ -111,7 +111,7 @@ public class PlayersPlugin implements Listener {
return;
}
final CompletableFuture<Component> trackedCoreFuture = bot.core.runTracked(true, "essentials:seen " + target.profile.getIdAsString());
final CompletableFuture<Component> trackedCoreFuture = bot.core.runTracked("essentials:seen " + target.profile.getIdAsString());
if (trackedCoreFuture == null) {
outputFuture.complete(null);
@@ -291,11 +291,11 @@ public class PlayersPlugin implements Listener {
bot.listener.dispatch(listener -> listener.onPlayerDisplayNameUpdated(target, displayName));
}
private CompletableFuture<String> getLastKnownName (final String uuid) {
return bot.query.entity(true, uuid, "bukkit.lastKnownName");
private CompletableFuture<String> getLastKnownName (final boolean useCargo, final String uuid) {
return bot.query.entity(useCargo, uuid, "bukkit.lastKnownName");
}
private void check (final PlayerEntry target) {
private void check (final boolean useCargo, final PlayerEntry target) {
final PlayerEntry pending = pendingLeftPlayers.stream()
.filter(player -> player.equals(target))
.findAny()
@@ -303,7 +303,7 @@ public class PlayersPlugin implements Listener {
if (pending != null) pendingLeftPlayers.remove(pending);
final CompletableFuture<String> future = getLastKnownName(target.profile.getIdAsString());
final CompletableFuture<String> future = getLastKnownName(useCargo, target.profile.getIdAsString());
future.thenApply(lastKnownName -> {
// checking for empty string means
@@ -364,7 +364,7 @@ public class PlayersPlugin implements Listener {
return;
for (final PlayerEntry target : new ArrayList<>(list)) {
check(target);
check(true, target);
}
}
@@ -381,7 +381,7 @@ public class PlayersPlugin implements Listener {
}
} else {
pendingLeftPlayers.add(target);
check(target);
check(false, target);
}
}