From 99032b42806f644e83f74c005b00dfd0d7f307b7 Mon Sep 17 00:00:00 2001 From: AlexDev_ <56083016+alexdev03@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:55:35 +0100 Subject: [PATCH] Increased delay --- .../placeholder/PlaceholderManager.java | 17 ++++++++++++++--- .../velocitab/tab/TabListListener.java | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/william278/velocitab/placeholder/PlaceholderManager.java b/src/main/java/net/william278/velocitab/placeholder/PlaceholderManager.java index 4087663..3f18764 100644 --- a/src/main/java/net/william278/velocitab/placeholder/PlaceholderManager.java +++ b/src/main/java/net/william278/velocitab/placeholder/PlaceholderManager.java @@ -22,6 +22,7 @@ package net.william278.velocitab.placeholder; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.velocitypowered.api.proxy.Player; +import lombok.Setter; import net.william278.velocitab.Velocitab; import net.william278.velocitab.config.Formatter; import net.william278.velocitab.config.Group; @@ -40,6 +41,9 @@ import java.util.regex.Pattern; public class PlaceholderManager { + @Setter + private boolean debug = false; + private static final String ELSE_PLACEHOLDER = "ELSE"; private static final Pattern VELOCITAB_PATTERN = Pattern.compile(""); private static final Pattern TEST = Pattern.compile("<.*?>"); @@ -87,13 +91,20 @@ public class PlaceholderManager { .map(s -> s.replace("%target_", "%")) .toList(); + final long start = System.currentTimeMillis(); + placeholders.forEach(placeholder -> replaceSingle(placeholder, plugin, tabPlayer) .ifPresentOrElse(replacement -> parsed.put(placeholder, replacement), () -> plugin.getPAPIProxyBridgeHook().ifPresent(hook -> hook.formatPlaceholders(placeholder, player).thenAccept(replacement -> { - if(replacement == null || replacement.equals(placeholder)) { + if (replacement == null || replacement.equals(placeholder)) { return; } + + if (debug) { + plugin.getLogger().info("Placeholder {} replaced with {} in {}ms", placeholder, replacement, System.currentTimeMillis() - start); + } + parsed.put(placeholder, replacement); })))); } @@ -133,7 +144,7 @@ public class PlaceholderManager { @NotNull private String applyPlaceholderReplacements(@NotNull String text, @NotNull TabPlayer player, - @NotNull Map parsed) { + @NotNull Map parsed) { for (final Map.Entry> entry : player.getGroup().placeholderReplacements().entrySet()) { if (!parsed.containsKey(entry.getKey())) { continue; @@ -191,7 +202,7 @@ public class PlaceholderManager { return Optional.empty(); } - if(optionalPlaceholder.get().isParameterised()) { + if (optionalPlaceholder.get().isParameterised()) { throw new IllegalArgumentException("Placeholder " + placeholder + " is parameterised"); } diff --git a/src/main/java/net/william278/velocitab/tab/TabListListener.java b/src/main/java/net/william278/velocitab/tab/TabListListener.java index 4218d3a..8889ec3 100644 --- a/src/main/java/net/william278/velocitab/tab/TabListListener.java +++ b/src/main/java/net/william278/velocitab/tab/TabListListener.java @@ -155,7 +155,8 @@ public class TabListListener { .repeat(50, TimeUnit.MILLISECONDS) .schedule(); - final int delay = justQuit.contains(joined.getUniqueId()) ? 400 : 200; + //After updating papiproxybridge we can check if redis is used + final int delay = justQuit.contains(joined.getUniqueId()) ? 400 : 300; plugin.getServer().getScheduler().buildTask(plugin, () -> { task.cancel();