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) {