Merge pull request #223 from Olzie-12/emptyRecipients

This commit is contained in:
Josua Parks authored and GitHub committed 2022-12-16 14:25:27 -08:00
commit 107ee990c8
6 files changed
+35 -2

No files matched your search

@@ -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();
@@ -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)) {
@@ -23,6 +23,7 @@ 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 net.draycia.carbon.common.messages.CarbonMessages;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@@ -31,10 +32,11 @@ public class RadiusListener {
@Inject
public RadiusListener(
final CarbonChat carbonChat
final CarbonChat carbonChat,
final CarbonMessages carbonMessages
) {
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 0, false, event -> {
if (event.chatChannel() == null) {
if (event.chatChannel() == null || event.previewing()) {
return;
}
@@ -74,6 +76,9 @@ public class RadiusListener {
return false;
});
}
if (event.recipients().size() <= 2 && event.chatChannel().emptyRadiusRecipientsMessage()) { // the player and cosole
carbonMessages.emptyRecipients(event.sender());
}
});
}
@@ -50,6 +50,9 @@ public interface CarbonMessages {
@Message("channel.change")
void changedChannels(final Audience audience, final String channel);
@Message("channel.radius.empty_recipients")
void emptyRecipients(final Audience audience);
/*
* =============================================================
* =========================== Mutes ===========================