mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Fix cross-server message rendering
This commit is contained in:
1 parent
d4528048e2
commit
41e0f979e4
5 files changed
+19
-49
No files matched your search
@@ -330,6 +330,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
renderedMessage = renderer.render(sender, sender, renderedMessage, chatEvent.message());
|
||||
}
|
||||
|
||||
// TODO: Fix this, messages aren't rendered per person here :(
|
||||
for (final Audience recipient : chatEvent.recipients()) {
|
||||
recipient.sendMessage(renderedMessage);
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2023 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.events.CarbonEventHandler;
|
||||
import net.draycia.carbon.common.messaging.packets.ChatMessagePacket;
|
||||
import ninja.egg82.messenger.services.PacketService;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class MessagingHandler {
|
||||
|
||||
@Inject
|
||||
public MessagingHandler(final CarbonChat carbonChat, final CarbonEventHandler events) {
|
||||
events.subscribe(CarbonChatEvent.class, 1000, false, event -> {
|
||||
final @Nullable PacketService packetService = carbonChat.packetService();
|
||||
|
||||
if (packetService != null) {
|
||||
packetService.queuePacket(new ChatMessagePacket(carbonChat.serverId(), event.sender().uuid(),
|
||||
event.chatChannel().permission(), event.chatChannel().key(), event.sender().username(), event.message()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,6 +72,8 @@ public final class CarbonChatPacketHandler extends AbstractMessagingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
CarbonChatProvider.carbonChat().server().console().sendMessage(Component.text("[Cross-Server] ").append(messagePacket.message()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ 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.MessagingHandler;
|
||||
import net.draycia.carbon.common.listeners.MuteHandler;
|
||||
import net.draycia.carbon.common.listeners.PingHandler;
|
||||
|
||||
@@ -35,7 +34,7 @@ public final class ListenerUtils {
|
||||
}
|
||||
|
||||
public static final List<Class<?>> LISTENER_CLASSES = List.of(DeafenHandler.class, IgnoreHandler.class,
|
||||
ItemLinkHandler.class, MessagingHandler.class, MuteHandler.class, PingHandler.class);
|
||||
ItemLinkHandler.class, MuteHandler.class, PingHandler.class);
|
||||
|
||||
public static void registerCommonListeners(final Injector injector) {
|
||||
for (final var listenerClass : LISTENER_CLASSES) {
|
||||
|
||||
Reference in new issue
Block a user