mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Allow disabling cross-server broadcasting per-channel (#589)
* Add channel config option to individually disable cross-server * Block incoming messages when channel cross-server is false
This commit is contained in:
1 parent
1ed9f4441e
commit
9380c13817
7 files changed
+39
No files matched your search
@@ -117,6 +117,9 @@ public class ConfigChatChannel implements ChatChannel {
|
||||
|
||||
private long cooldown = -1;
|
||||
|
||||
@Comment("Whether this channel's messages should be sent cross-server.")
|
||||
private boolean crossServer = true;
|
||||
|
||||
@Override
|
||||
public @Nullable String quickPrefix() {
|
||||
if (this.quickPrefix == null || this.quickPrefix.isBlank()) {
|
||||
@@ -263,6 +266,11 @@ public class ConfigChatChannel implements ChatChannel {
|
||||
return this.emptyRadiusRecipientsMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCrossServer() {
|
||||
return this.crossServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
if (!(other instanceof ConfigChatChannel otherChannel)) {
|
||||
|
||||
@@ -51,6 +51,10 @@ public class MessagePacketHandler implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.chatChannel().shouldCrossServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
messaging.get().queuePacket(() -> {
|
||||
final CarbonPlayer sender = event.sender();
|
||||
final Component networkMessage = e.renderFor(sender);
|
||||
|
||||
@@ -122,6 +122,10 @@ public final class CarbonChatPacketHandler extends AbstractMessagingHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!channel.shouldCrossServer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<KeyedRenderer> renderers = new ArrayList<>();
|
||||
|
||||
final List<Audience> recipients = channel.recipients(sender);
|
||||
|
||||
Reference in new issue
Block a user