Let sender know when recipient has DMs off

This commit is contained in:
Draycia committed 2023-08-25 19:50:30 -07:00
1 parent 6a822da277
commit 9627d88f9c
6 files changed
+28 -35

No files matched your search

@@ -43,19 +43,19 @@ public final class ContinueCommand extends CarbonCommand {
private final UserManager<?> users;
private final CommandManager<Commander> commandManager;
private final CarbonMessages carbonMessages;
private final CarbonMessages messages;
private final WhisperCommand.WhisperHandler whisper;
@Inject
public ContinueCommand(
final UserManager<?> userManager,
final CommandManager<Commander> commandManager,
final CarbonMessages carbonMessages,
final CarbonMessages messages,
final WhisperCommand.WhisperHandler whisper
) {
this.users = userManager;
this.commandManager = commandManager;
this.carbonMessages = carbonMessages;
this.messages = messages;
this.whisper = whisper;
}
@@ -73,20 +73,15 @@ public final class ContinueCommand extends CarbonCommand {
public void init() {
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
.argument(StringArgument.greedy("message"),
RichDescription.of(this.carbonMessages.commandContinueArgumentMessage()))
RichDescription.of(this.messages.commandContinueArgumentMessage()))
.permission("carbon.whisper.continue")
.senderType(PlayerCommander.class)
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandContinueDescription())
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.messages.commandContinueDescription())
.handler(ctx -> {
final CarbonPlayer sender = ((PlayerCommander) ctx.getSender()).carbonPlayer();
if (sender.muted()) {
this.carbonMessages.muteCannotSpeak(sender);
return;
}
if (sender.ignoringDirectMessages()) {
this.carbonMessages.whisperIgnoringAll(sender);
this.messages.muteCannotSpeak(sender);
return;
}
@@ -94,7 +89,7 @@ public final class ContinueCommand extends CarbonCommand {
final @Nullable UUID whisperTarget = sender.lastWhisperTarget();
if (whisperTarget == null) {
this.carbonMessages.whisperTargetNotSet(sender, sender.displayName());
this.messages.whisperTargetNotSet(sender, sender.displayName());
return;
}
@@ -43,19 +43,19 @@ public final class ReplyCommand extends CarbonCommand {
private final UserManager<?> users;
private final CommandManager<Commander> commandManager;
private final CarbonMessages carbonMessages;
private final CarbonMessages messages;
private final WhisperCommand.WhisperHandler whisper;
@Inject
public ReplyCommand(
final UserManager<?> userManager,
final CommandManager<Commander> commandManager,
final CarbonMessages carbonMessages,
final CarbonMessages messages,
final WhisperCommand.WhisperHandler whisper
) {
this.users = userManager;
this.commandManager = commandManager;
this.carbonMessages = carbonMessages;
this.messages = messages;
this.whisper = whisper;
}
@@ -73,20 +73,15 @@ public final class ReplyCommand extends CarbonCommand {
public void init() {
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
.argument(StringArgument.greedy("message"),
RichDescription.of(this.carbonMessages.commandReplyArgumentMessage()))
RichDescription.of(this.messages.commandReplyArgumentMessage()))
.permission("carbon.whisper.reply")
.senderType(PlayerCommander.class)
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReplyDescription())
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.messages.commandReplyDescription())
.handler(ctx -> {
final CarbonPlayer sender = ((PlayerCommander) ctx.getSender()).carbonPlayer();
if (sender.muted()) {
this.carbonMessages.muteCannotSpeak(sender);
return;
}
if (sender.ignoringDirectMessages()) {
this.carbonMessages.whisperIgnoringAll(sender);
this.messages.muteCannotSpeak(sender);
return;
}
@@ -94,7 +89,7 @@ public final class ReplyCommand extends CarbonCommand {
final @Nullable UUID replyTarget = sender.whisperReplyTarget();
if (replyTarget == null) {
this.carbonMessages.replyTargetNotSet(sender, sender.displayName());
this.messages.replyTargetNotSet(sender, sender.displayName());
return;
}
@@ -35,17 +35,14 @@ public class ToggleMessagesCommand extends CarbonCommand {
private final CommandManager<Commander> commandManager;
private final CarbonMessages carbonMessages;
private final ArgumentFactory argumentFactory;
@Inject
public ToggleMessagesCommand(
final CommandManager<Commander> commandManager,
final CarbonMessages carbonMessages,
final ArgumentFactory argumentFactory
final CarbonMessages carbonMessages
) {
this.commandManager = commandManager;
this.carbonMessages = carbonMessages;
this.argumentFactory = argumentFactory;
}
@Override
@@ -102,11 +102,6 @@ public final class WhisperCommand extends CarbonCommand {
return;
}
if (sender.ignoringDirectMessages()) {
this.carbonMessages.whisperIgnoringAll(sender);
return;
}
final String message = ctx.get("message");
final CarbonPlayer recipient = ctx.get("player");
@@ -171,6 +166,11 @@ public final class WhisperCommand extends CarbonCommand {
return;
}
if (sender.ignoringDirectMessages() && !sender.hasPermission("carbon.togglemsg.exempt")) {
this.messages.whisperIgnoringAll(sender);
return;
}
if (!this.network.online(recipient) || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
final var exception = new CarbonPlayerArgument.ParseException(
recipientInputString == null ? recipient.username() : recipientInputString,
@@ -193,6 +193,7 @@ public final class WhisperCommand extends CarbonCommand {
}
if (recipient.ignoringDirectMessages() && !sender.hasPermission("carbon.togglemsg.exempt")) {
this.messages.whisperTargetIgnoringDMs(sender, recipient.displayName());
return;
}
@@ -19,6 +19,7 @@
*/
package net.draycia.carbon.common.messages;
import javax.sound.sampled.AudioInputStream;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.moonshine.annotation.Message;
@@ -159,6 +160,9 @@ public interface CarbonMessages {
@Message("whisper.ignored_by_target")
void whisperTargetIgnoring(final Audience audience, final Component target);
@Message("whisper.ignored_dms")
void whisperTargetIgnoringDMs(final Audience audience, final Component target);
@Message("whisper.toggled.on")
void whispersToggledOn(final Audience audience);
@@ -52,6 +52,7 @@ import net.draycia.carbon.common.command.commands.MuteInfoCommand;
import net.draycia.carbon.common.command.commands.NicknameCommand;
import net.draycia.carbon.common.command.commands.ReloadCommand;
import net.draycia.carbon.common.command.commands.ReplyCommand;
import net.draycia.carbon.common.command.commands.ToggleMessagesCommand;
import net.draycia.carbon.common.command.commands.UnignoreCommand;
import net.draycia.carbon.common.command.commands.UnmuteCommand;
import net.draycia.carbon.common.command.commands.UpdateUsernameCommand;
@@ -74,8 +75,8 @@ public final class CloudUtils {
public static final List<Class<? extends CarbonCommand>> COMMAND_CLASSES = List.of(ClearChatCommand.class,
ContinueCommand.class, DebugCommand.class, HelpCommand.class, IgnoreCommand.class, MuteCommand.class,
MuteInfoCommand.class, NicknameCommand.class, ReloadCommand.class, ReplyCommand.class, UnignoreCommand.class,
UnmuteCommand.class, UpdateUsernameCommand.class, WhisperCommand.class, JoinCommand.class, LeaveCommand.class);
MuteInfoCommand.class, NicknameCommand.class, ReloadCommand.class, ReplyCommand.class, ToggleMessagesCommand.class,
UnignoreCommand.class, UnmuteCommand.class, UpdateUsernameCommand.class, WhisperCommand.class, JoinCommand.class, LeaveCommand.class);
private static final List<CarbonCommand> CONSTRUCTED_COMMANDS = new ArrayList<>();