refactor: check player left and ip query without queue for faster trusted broadcast and filtering
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user