diff --git a/api/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java b/api/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java index 1a09936d..a91e96e8 100644 --- a/api/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java +++ b/api/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java @@ -131,6 +131,14 @@ public interface ChatChannel extends Keyed, ChatComponentRenderer { */ double radius(); + /** + * If the empty receipt message should be sent to the sender. + * + * @return Returns true if the channel should display a message when a player is out of range. + * @since 2.1.0 + */ + boolean emptyRadiusRecipientsMessage(); + /** * Represents the result of a channel permission check. * diff --git a/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java index aa14f085..1c726add 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java @@ -103,6 +103,11 @@ public final class BasicChatChannel implements ChatChannel { return -1; } + @Override + public boolean emptyRadiusRecipientsMessage() { + return true; + } + @Override public ChannelPermissionResult speechPermitted(final CarbonPlayer carbonPlayer) { return ChannelPermissionResult.allowed(); diff --git a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java index 0bb429dc..8c402e8e 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java @@ -110,6 +110,12 @@ public final class ConfigChatChannel implements ChatChannel { """) private int radius = -1; + @Comment(""" + If true, players will be able to see if they're not sending messages to anyone + because they're out of range from the radius. + """) + private boolean emptyRadiusRecipientsMessage = true; + private transient @Nullable ConfigChannelMessages messageService = null; @Override @@ -290,6 +296,11 @@ public final class ConfigChatChannel implements ChatChannel { return this.radius; } + @Override + public boolean emptyRadiusRecipientsMessage() { + return this.emptyRadiusRecipientsMessage; + } + @Override public boolean equals(final Object other) { if (!(other instanceof BasicChatChannel otherChannel)) return false; diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java b/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java index e4b6541f..ff3537d1 100644 --- a/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java +++ b/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java @@ -36,7 +36,7 @@ public class RadiusListener { final CarbonMessages carbonMessages ) { carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 0, false, event -> { - if (event.chatChannel() == null) { + if (event.chatChannel() == null || event.previewing()) { return; } @@ -76,9 +76,9 @@ public class RadiusListener { return false; }); } - if (event.recipients().size() > 1) return; - - carbonMessages.emptyRecipients(event.sender()); + if (event.recipients().size() <= 2 && event.chatChannel().emptyRadiusRecipientsMessage()) { // the player and cosole + carbonMessages.emptyRecipients(event.sender()); + } }); } diff --git a/common/src/main/resources/locale/messages-en_US.properties b/common/src/main/resources/locale/messages-en_US.properties index af808b98..a6646a5e 100644 --- a/common/src/main/resources/locale/messages-en_US.properties +++ b/common/src/main/resources/locale/messages-en_US.properties @@ -94,4 +94,4 @@ whisper.from=[] -> [You whisper.ignored_by_target= is ignoring you whisper.ignoring_target=You are ignoring whisper.to=[You] -> [] -channel.radius.empty_recipients=No players found within blocks of +channel.radius.empty_recipients=You're not close enough to anyone to send a message