From 49a5dd76e7465550a12a8c97d43b6bf6ebb02993 Mon Sep 17 00:00:00 2001 From: Sodium-Aluminate Date: Fri, 8 Dec 2023 18:02:31 +0800 Subject: [PATCH] =?UTF-8?q?join/left=E6=B6=88=E6=81=AF=E5=A0=86=E5=8F=A0?= =?UTF-8?q?=E6=97=B6=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E8=B7=A8=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/de/strifel/VTools/listeners/TGBridge.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/strifel/VTools/listeners/TGBridge.java b/src/main/java/de/strifel/VTools/listeners/TGBridge.java index 7c11bbd..575c605 100644 --- a/src/main/java/de/strifel/VTools/listeners/TGBridge.java +++ b/src/main/java/de/strifel/VTools/listeners/TGBridge.java @@ -40,6 +40,7 @@ import java.util.function.BiConsumer; import java.util.stream.Collectors; public class TGBridge { + private static final long MINUTE = 60_000; private final VTools plugin; private final ProxyServer server; @SuppressWarnings("java:S3008") @@ -505,13 +506,16 @@ public class TGBridge { private class JoinLeftAnnounceMessage { private int messageId; private long time; + private long timeMinute; private StringBuilder text; private boolean abort = false; boolean isValid() { if (abort || messageId < 1) return false; - long dt = System.currentTimeMillis() - time; + long current = System.currentTimeMillis(); + if (current / MINUTE != timeMinute) return false; + long dt = current - time; return dt <= 30_000 && dt >= 0; } @@ -522,6 +526,7 @@ public class TGBridge { protected JoinLeftAnnounceMessage(String firstMessage) { text = new StringBuilder(firstMessage); time = System.currentTimeMillis(); + timeMinute = time/MINUTE; sendAnnounceMessage(); } @@ -548,7 +553,9 @@ public class TGBridge { protected JoinLeftAnnounceMessage() { messageId = 0; time = 0; + timeMinute = 0; text = new StringBuilder(); + abort = false; } //dummy private void addLines(List messages) {