mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Add sender_username and recipient_username placeholders to whisper formats (closes #312)
This commit is contained in:
2 files changed
+32
-22
No files matched your search
+14
-10
@@ -171,9 +171,10 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String recipientUsername = recipient.username();
|
||||||
if (!this.network.online(recipient) || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
|
if (!this.network.online(recipient) || !sender.awareOf(recipient) && !sender.hasPermission("carbon.whisper.vanished")) {
|
||||||
final var exception = new CarbonPlayerArgument.ParseException(
|
final var exception = new CarbonPlayerArgument.ParseException(
|
||||||
recipientInputString == null ? recipient.username() : recipientInputString,
|
recipientInputString == null ? recipientUsername : recipientInputString,
|
||||||
this.messages
|
this.messages
|
||||||
);
|
);
|
||||||
this.messages.errorCommandArgumentParsing(sender, CloudUtils.message(exception));
|
this.messages.errorCommandArgumentParsing(sender, CloudUtils.message(exception));
|
||||||
@@ -197,8 +198,8 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Component senderName = sender.displayName();
|
final Component senderDisplayName = sender.displayName();
|
||||||
final Component recipientName = recipient.displayName();
|
final Component recipientDisplayName = recipient.displayName();
|
||||||
|
|
||||||
final CarbonPrivateChatEvent privateChatEvent = new CarbonPrivateChatEventImpl(sender, recipient, Component.text(message));
|
final CarbonPrivateChatEvent privateChatEvent = new CarbonPrivateChatEventImpl(sender, recipient, Component.text(message));
|
||||||
this.events.emit(privateChatEvent);
|
this.events.emit(privateChatEvent);
|
||||||
@@ -208,11 +209,12 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.messages.whisperSender(SourcedAudience.of(sender, sender), senderName, recipientName, privateChatEvent.message());
|
final String senderUsername = sender.username();
|
||||||
|
this.messages.whisperSender(SourcedAudience.of(sender, sender), senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, privateChatEvent.message());
|
||||||
if (localRecipient) {
|
if (localRecipient) {
|
||||||
this.messages.whisperRecipient(SourcedAudience.of(sender, recipient), senderName, recipientName, privateChatEvent.message());
|
this.messages.whisperRecipient(SourcedAudience.of(sender, recipient), senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, privateChatEvent.message());
|
||||||
}
|
}
|
||||||
this.messages.whisperConsoleLog(this.server.console(), senderName, recipientName, privateChatEvent.message());
|
this.messages.whisperConsoleLog(this.server.console(), senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, privateChatEvent.message());
|
||||||
|
|
||||||
final @Nullable Sound messageSound = this.configManager.primaryConfig().messageSound();
|
final @Nullable Sound messageSound = this.configManager.primaryConfig().messageSound();
|
||||||
if (localRecipient && messageSound != null) {
|
if (localRecipient && messageSound != null) {
|
||||||
@@ -237,12 +239,14 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.userManager.user(packet.from()).thenAccept(sender -> {
|
this.userManager.user(packet.from()).thenAccept(sender -> {
|
||||||
final Component senderName = sender.displayName();
|
final String senderUsername = sender.username();
|
||||||
final Component recipientName = recipient.displayName();
|
final Component senderDisplayName = sender.displayName();
|
||||||
|
final String recipientUsername = recipient.username();
|
||||||
|
final Component recipientDisplayName = recipient.displayName();
|
||||||
|
|
||||||
recipient.whisperReplyTarget(sender.uuid());
|
recipient.whisperReplyTarget(sender.uuid());
|
||||||
this.messages.whisperRecipient(SourcedAudience.of(sender, recipient), senderName, recipientName, packet.message());
|
this.messages.whisperRecipient(SourcedAudience.of(sender, recipient), senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, packet.message());
|
||||||
this.messages.whisperConsoleLog(this.server.console(), senderName, recipientName, packet.message());
|
this.messages.whisperConsoleLog(this.server.console(), senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, packet.message());
|
||||||
final @Nullable Sound messageSound = this.configManager.primaryConfig().messageSound();
|
final @Nullable Sound messageSound = this.configManager.primaryConfig().messageSound();
|
||||||
if (messageSound != null) {
|
if (messageSound != null) {
|
||||||
recipient.playSound(messageSound);
|
recipient.playSound(messageSound);
|
||||||
|
|||||||
@@ -109,26 +109,32 @@ public interface CarbonMessages {
|
|||||||
|
|
||||||
@Message("whisper.to")
|
@Message("whisper.to")
|
||||||
void whisperSender(
|
void whisperSender(
|
||||||
final SourcedAudience audience,
|
SourcedAudience audience,
|
||||||
@Placeholder("sender_display_name") final Component senderDisplayName,
|
String senderUsername,
|
||||||
@Placeholder("recipient_display_name") final Component recipientDisplayName,
|
Component senderDisplayName,
|
||||||
final Component message
|
String recipientUsername,
|
||||||
|
Component recipientDisplayName,
|
||||||
|
Component message
|
||||||
);
|
);
|
||||||
|
|
||||||
@Message("whisper.from")
|
@Message("whisper.from")
|
||||||
void whisperRecipient(
|
void whisperRecipient(
|
||||||
final SourcedAudience audience,
|
SourcedAudience audience,
|
||||||
@Placeholder("sender_display_name") final Component senderDisplayName,
|
String senderUsername,
|
||||||
@Placeholder("recipient_display_name") final Component recipientDisplayName,
|
Component senderDisplayName,
|
||||||
final Component message
|
String recipientUsername,
|
||||||
|
Component recipientDisplayName,
|
||||||
|
Component message
|
||||||
);
|
);
|
||||||
|
|
||||||
@Message("whisper.console")
|
@Message("whisper.console")
|
||||||
void whisperConsoleLog(
|
void whisperConsoleLog(
|
||||||
final Audience audience,
|
Audience audience,
|
||||||
@Placeholder("sender_display_name") final Component senderDisplayName,
|
String senderUsername,
|
||||||
@Placeholder("recipient_display_name") final Component recipientDisplayName,
|
Component senderDisplayName,
|
||||||
final Component message
|
String recipientUsername,
|
||||||
|
Component recipientDisplayName,
|
||||||
|
Component message
|
||||||
);
|
);
|
||||||
|
|
||||||
@Message("whisper.error")
|
@Message("whisper.error")
|
||||||
|
|||||||
Reference in new issue
Block a user