From 4fa8e66a9ccf8acacbc36edc470439845f483bc3 Mon Sep 17 00:00:00 2001 From: Draycia Date: Tue, 7 Dec 2021 12:34:03 -0800 Subject: [PATCH] Add whisper message logs --- .../common/command/commands/ContinueCommand.java | 9 +++++---- .../common/command/commands/ReplyCommand.java | 9 +++++---- .../common/command/commands/WhisperCommand.java | 14 +++++++++----- .../common/messages/CarbonMessageService.java | 8 ++++++++ .../resources/locale/messages-en_US.properties | 1 + 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java index d4191a42..cfc842d0 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java @@ -97,11 +97,12 @@ public class ContinueCommand { return; } - messageService.whisperSender(new SourcedAudience(sender, sender), - CarbonPlayer.renderName(sender), CarbonPlayer.renderName(recipient), message); + final Component senderName = CarbonPlayer.renderName(sender); + final Component recipientName = CarbonPlayer.renderName(recipient); - messageService.whisperRecipient(new SourcedAudience(sender, recipient), - CarbonPlayer.renderName(sender), CarbonPlayer.renderName(recipient), message); + messageService.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message); + messageService.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message); + messageService.whisperConsoleLog(carbonChat.server().console(), senderName, recipientName, message); sender.lastWhisperTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid()); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java index c3109b98..64d7dfc5 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java @@ -99,11 +99,12 @@ public class ReplyCommand { return; } - messageService.whisperSender(new SourcedAudience(sender, sender), - CarbonPlayer.renderName(sender), CarbonPlayer.renderName(recipient), message); + final Component senderName = CarbonPlayer.renderName(sender); + final Component recipientName = CarbonPlayer.renderName(recipient); - messageService.whisperRecipient(new SourcedAudience(sender, recipient), - CarbonPlayer.renderName(sender), CarbonPlayer.renderName(recipient), message); + messageService.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message); + messageService.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message); + messageService.whisperConsoleLog(carbonChat.server().console(), senderName, recipientName, message); sender.lastWhisperTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid()); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java index 0c467688..0a3c898c 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java @@ -22,6 +22,7 @@ package net.draycia.carbon.common.command.commands; import cloud.commandframework.CommandManager; import cloud.commandframework.arguments.standard.StringArgument; import com.google.inject.Inject; +import net.draycia.carbon.api.CarbonServer; import net.draycia.carbon.api.users.CarbonPlayer; import net.draycia.carbon.api.util.SourcedAudience; import net.draycia.carbon.common.command.Commander; @@ -29,6 +30,7 @@ import net.draycia.carbon.common.command.PlayerCommander; import net.draycia.carbon.common.command.argument.CarbonPlayerArgument; import net.draycia.carbon.common.messages.CarbonMessageService; import net.draycia.carbon.common.util.CloudUtils; +import net.kyori.adventure.text.Component; public class WhisperCommand { @@ -36,7 +38,8 @@ public class WhisperCommand { public WhisperCommand( final CommandManager commandManager, final CarbonMessageService messageService, - final CarbonPlayerArgument carbonPlayerArgument + final CarbonPlayerArgument carbonPlayerArgument, + final CarbonServer carbonServer ) { final var command = commandManager.commandBuilder("whisper", "w", "message", "msg") .argument(carbonPlayerArgument.newInstance(true, "recipient", CarbonPlayerArgument.NO_SENDER)) @@ -80,11 +83,12 @@ public class WhisperCommand { return; } - messageService.whisperSender(new SourcedAudience(sender, sender), - CarbonPlayer.renderName(sender), CarbonPlayer.renderName(recipient), message); + final Component senderName = CarbonPlayer.renderName(sender); + final Component recipientName = CarbonPlayer.renderName(recipient); - messageService.whisperRecipient(new SourcedAudience(sender, recipient), - CarbonPlayer.renderName(sender), CarbonPlayer.renderName(recipient), message); + messageService.whisperSender(new SourcedAudience(sender, sender), senderName, recipientName, message); + messageService.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message); + messageService.whisperConsoleLog(carbonServer.console(), senderName, recipientName, message); sender.lastWhisperTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid()); diff --git a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java index aaf773d4..6fb5af9c 100644 --- a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java +++ b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java @@ -119,6 +119,14 @@ public interface CarbonMessageService { final String message ); + @Message("whisper.console") + void whisperConsoleLog( + final Audience audience, + @Placeholder("sender_display_name") final Component senderDisplayName, + @Placeholder("recipient_display_name") final Component recipientDisplayName, + final String message + ); + @Message("reply.target.missing") void replyTargetNotSet(final Audience audience, @Placeholder("sender_display_name") final Component senderDisplayName); diff --git a/common/src/main/resources/locale/messages-en_US.properties b/common/src/main/resources/locale/messages-en_US.properties index 0b6d067e..b5b01785 100644 --- a/common/src/main/resources/locale/messages-en_US.properties +++ b/common/src/main/resources/locale/messages-en_US.properties @@ -48,6 +48,7 @@ nickname.show.unset=You do not have a nickname set nickname.show=Your nickname is reply.target.missing=You have no-one to reply to reply.target.self=You cannot whisper to yourself +whisper.console=[] -> [] whisper.continue.target_missing=You have no one to whisper whisper.from=[] -> [You] whisper.ignored_by_target= is ignoring you