Skip to content

Commit

Permalink
Add channel setting to disable cross server
Browse files Browse the repository at this point in the history
Also defaults integration channels to not broadcast
  • Loading branch information
Draycia committed Sep 17, 2024
1 parent c216b0c commit 36009b6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public class ConfigChatChannel implements ChatChannel {

private long cooldown = -1;

private Key broadcastCrossServer = true;

@Override
public @Nullable String quickPrefix() {
if (this.quickPrefix == null || this.quickPrefix.isBlank()) {
Expand Down Expand Up @@ -263,6 +265,10 @@ public boolean emptyRadiusRecipientsMessage() {
return this.emptyRadiusRecipientsMessage;
}

public boolean broadcastCrossServer() {
return this.broadcastCrossServer;
}

@Override
public boolean equals(final Object other) {
if (!(other instanceof ConfigChatChannel otherChannel)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public MessagePacketHandler(
if (event.sender() instanceof ConsoleCarbonPlayer) {
return;
}
if (event.channel() instanceof ConfigChatChannel configChannel) {
if (!configChannel.broadcastCrossServer()) {
return;
}
}

messaging.get().queuePacket(() -> {
final CarbonPlayer sender = event.sender();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ protected final boolean hasRelations(final CarbonPlayer player, final Relation r
return faction != null && faction.getRelationCount(relation) > 0;
}

@Override
public boolean broadcastCrossServer() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,9 @@ public List<Audience> recipients(final CarbonPlayer sender) {
return PartyManager.getParty(Bukkit.getPlayer(player.uuid()));
}

@Override
public boolean broadcastCrossServer() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@ protected List<Player> onlinePlayers(final T residentList) {

protected abstract Component cannotUseChannel(CarbonPlayer player);

@Override
public boolean broadcastCrossServer() {
return false;
}

}

0 comments on commit 36009b6

Please sign in to comment.