join/left消息堆叠时检测是否已经跨分钟
This commit is contained in:
parent
c178415969
commit
49a5dd76e7
1 changed files with 8 additions and 1 deletions
|
@ -40,6 +40,7 @@ import java.util.function.BiConsumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TGBridge {
|
public class TGBridge {
|
||||||
|
private static final long MINUTE = 60_000;
|
||||||
private final VTools plugin;
|
private final VTools plugin;
|
||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
@SuppressWarnings("java:S3008")
|
@SuppressWarnings("java:S3008")
|
||||||
|
@ -505,13 +506,16 @@ public class TGBridge {
|
||||||
private class JoinLeftAnnounceMessage {
|
private class JoinLeftAnnounceMessage {
|
||||||
private int messageId;
|
private int messageId;
|
||||||
private long time;
|
private long time;
|
||||||
|
private long timeMinute;
|
||||||
|
|
||||||
private StringBuilder text;
|
private StringBuilder text;
|
||||||
private boolean abort = false;
|
private boolean abort = false;
|
||||||
|
|
||||||
boolean isValid() {
|
boolean isValid() {
|
||||||
if (abort || messageId < 1) return false;
|
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;
|
return dt <= 30_000 && dt >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,6 +526,7 @@ public class TGBridge {
|
||||||
protected JoinLeftAnnounceMessage(String firstMessage) {
|
protected JoinLeftAnnounceMessage(String firstMessage) {
|
||||||
text = new StringBuilder(firstMessage);
|
text = new StringBuilder(firstMessage);
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
|
timeMinute = time/MINUTE;
|
||||||
sendAnnounceMessage();
|
sendAnnounceMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +553,9 @@ public class TGBridge {
|
||||||
protected JoinLeftAnnounceMessage() {
|
protected JoinLeftAnnounceMessage() {
|
||||||
messageId = 0;
|
messageId = 0;
|
||||||
time = 0;
|
time = 0;
|
||||||
|
timeMinute = 0;
|
||||||
text = new StringBuilder();
|
text = new StringBuilder();
|
||||||
|
abort = false;
|
||||||
} //dummy
|
} //dummy
|
||||||
|
|
||||||
private void addLines(List<String> messages) {
|
private void addLines(List<String> messages) {
|
||||||
|
|
Loading…
Reference in a new issue