mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Redo mutehandler logic
This commit is contained in:
1 parent
e0f03795e3
commit
0505308371
2 files changed
+17
-2
No files matched your search
@@ -10,4 +10,8 @@ import java.util.UUID;
|
|||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public record MuteEntry(long muteEpoch, @Nullable UUID muteCause, long expirationEpoch, @Nullable Key channel) {
|
public record MuteEntry(long muteEpoch, @Nullable UUID muteCause, long expirationEpoch, @Nullable Key channel) {
|
||||||
|
|
||||||
|
public boolean valid() {
|
||||||
|
return System.currentTimeMillis() < expirationEpoch;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,8 +32,19 @@ public class MuteHandler {
|
|||||||
|
|
||||||
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 100, false, event -> {
|
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 100, false, event -> {
|
||||||
for (final var muteEntry : event.sender().muteEntries()) {
|
for (final var muteEntry : event.sender().muteEntries()) {
|
||||||
if (muteEntry.channel() != null && event.chatChannel().key().equals(muteEntry.channel())) {
|
// Entry expired
|
||||||
return;
|
if (!muteEntry.valid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Muted in all channels
|
||||||
|
if (muteEntry.channel() == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Muted in the channel the message was sent in
|
||||||
|
if (event.chatChannel().key().equals(muteEntry.channel())) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user