mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Add ignore handler
This commit is contained in:
1 parent
bf9e4e8148
commit
96c42d4706
2 files changed
+45
-2
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.common.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class IgnoreHandler {
|
||||
|
||||
@Inject
|
||||
public IgnoreHandler(
|
||||
final CarbonChat carbonChat
|
||||
) {
|
||||
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 0, false, event -> {
|
||||
event.recipients().removeIf(entry -> entry instanceof CarbonPlayer carbonPlayer &&
|
||||
carbonPlayer.ignoring(event.sender()));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ package net.draycia.carbon.common.util;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.List;
|
||||
import net.draycia.carbon.common.listeners.DeafenHandler;
|
||||
import net.draycia.carbon.common.listeners.IgnoreHandler;
|
||||
import net.draycia.carbon.common.listeners.ItemLinkHandler;
|
||||
import net.draycia.carbon.common.listeners.MuteHandler;
|
||||
|
||||
@@ -31,8 +32,8 @@ public final class ListenerUtils {
|
||||
|
||||
}
|
||||
|
||||
public static final List<Class<?>> LISTENER_CLASSES = List.of(DeafenHandler.class, ItemLinkHandler.class,
|
||||
MuteHandler.class);
|
||||
public static final List<Class<?>> LISTENER_CLASSES = List.of(DeafenHandler.class, IgnoreHandler.class,
|
||||
ItemLinkHandler.class, MuteHandler.class);
|
||||
|
||||
public static void registerCommonListeners(final Injector injector) {
|
||||
for (final var listenerClass : LISTENER_CLASSES) {
|
||||
|
||||
Reference in new issue
Block a user