mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Let sender know when recipient has DMs off
This commit is contained in:
1 parent
6a822da277
commit
9627d88f9c
6 files changed
+28
-35
No files matched your search
+7
-12
@@ -43,19 +43,19 @@ public final class ContinueCommand extends CarbonCommand {
|
|||||||
|
|
||||||
private final UserManager<?> users;
|
private final UserManager<?> users;
|
||||||
private final CommandManager<Commander> commandManager;
|
private final CommandManager<Commander> commandManager;
|
||||||
private final CarbonMessages carbonMessages;
|
private final CarbonMessages messages;
|
||||||
private final WhisperCommand.WhisperHandler whisper;
|
private final WhisperCommand.WhisperHandler whisper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ContinueCommand(
|
public ContinueCommand(
|
||||||
final UserManager<?> userManager,
|
final UserManager<?> userManager,
|
||||||
final CommandManager<Commander> commandManager,
|
final CommandManager<Commander> commandManager,
|
||||||
final CarbonMessages carbonMessages,
|
final CarbonMessages messages,
|
||||||
final WhisperCommand.WhisperHandler whisper
|
final WhisperCommand.WhisperHandler whisper
|
||||||
) {
|
) {
|
||||||
this.users = userManager;
|
this.users = userManager;
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.carbonMessages = carbonMessages;
|
this.messages = messages;
|
||||||
this.whisper = whisper;
|
this.whisper = whisper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,20 +73,15 @@ public final class ContinueCommand extends CarbonCommand {
|
|||||||
public void init() {
|
public void init() {
|
||||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||||
.argument(StringArgument.greedy("message"),
|
.argument(StringArgument.greedy("message"),
|
||||||
RichDescription.of(this.carbonMessages.commandContinueArgumentMessage()))
|
RichDescription.of(this.messages.commandContinueArgumentMessage()))
|
||||||
.permission("carbon.whisper.continue")
|
.permission("carbon.whisper.continue")
|
||||||
.senderType(PlayerCommander.class)
|
.senderType(PlayerCommander.class)
|
||||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandContinueDescription())
|
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.messages.commandContinueDescription())
|
||||||
.handler(ctx -> {
|
.handler(ctx -> {
|
||||||
final CarbonPlayer sender = ((PlayerCommander) ctx.getSender()).carbonPlayer();
|
final CarbonPlayer sender = ((PlayerCommander) ctx.getSender()).carbonPlayer();
|
||||||
|
|
||||||
if (sender.muted()) {
|
if (sender.muted()) {
|
||||||
this.carbonMessages.muteCannotSpeak(sender);
|
this.messages.muteCannotSpeak(sender);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender.ignoringDirectMessages()) {
|
|
||||||
this.carbonMessages.whisperIgnoringAll(sender);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +89,7 @@ public final class ContinueCommand extends CarbonCommand {
|
|||||||
final @Nullable UUID whisperTarget = sender.lastWhisperTarget();
|
final @Nullable UUID whisperTarget = sender.lastWhisperTarget();
|
||||||
|
|
||||||
if (whisperTarget == null) {
|
if (whisperTarget == null) {
|
||||||
this.carbonMessages.whisperTargetNotSet(sender, sender.displayName());
|
this.messages.whisperTargetNotSet(sender, sender.displayName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,19 +43,19 @@ public final class ReplyCommand extends CarbonCommand {
|
|||||||
|
|
||||||
private final UserManager<?> users;
|
private final UserManager<?> users;
|
||||||
private final CommandManager<Commander> commandManager;
|
private final CommandManager<Commander> commandManager;
|
||||||
private final CarbonMessages carbonMessages;
|
private final CarbonMessages messages;
|
||||||
private final WhisperCommand.WhisperHandler whisper;
|
private final WhisperCommand.WhisperHandler whisper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ReplyCommand(
|
public ReplyCommand(
|
||||||
final UserManager<?> userManager,
|
final UserManager<?> userManager,
|
||||||
final CommandManager<Commander> commandManager,
|
final CommandManager<Commander> commandManager,
|
||||||
final CarbonMessages carbonMessages,
|
final CarbonMessages messages,
|
||||||
final WhisperCommand.WhisperHandler whisper
|
final WhisperCommand.WhisperHandler whisper
|
||||||
) {
|
) {
|
||||||
this.users = userManager;
|
this.users = userManager;
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.carbonMessages = carbonMessages;
|
this.messages = messages;
|
||||||
this.whisper = whisper;
|
this.whisper = whisper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,20 +73,15 @@ public final class ReplyCommand extends CarbonCommand {
|
|||||||
public void init() {
|
public void init() {
|
||||||
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
final var command = this.commandManager.commandBuilder(this.commandSettings().name(), this.commandSettings().aliases())
|
||||||
.argument(StringArgument.greedy("message"),
|
.argument(StringArgument.greedy("message"),
|
||||||
RichDescription.of(this.carbonMessages.commandReplyArgumentMessage()))
|
RichDescription.of(this.messages.commandReplyArgumentMessage()))
|
||||||
.permission("carbon.whisper.reply")
|
.permission("carbon.whisper.reply")
|
||||||
.senderType(PlayerCommander.class)
|
.senderType(PlayerCommander.class)
|
||||||
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandReplyDescription())
|
.meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.messages.commandReplyDescription())
|
||||||
.handler(ctx -> {
|
.handler(ctx -> {
|
||||||
final CarbonPlayer sender = ((PlayerCommander) ctx.getSender()).carbonPlayer();
|
final CarbonPlayer sender = ((PlayerCommander) ctx.getSender()).carbonPlayer();
|
||||||
|
|
||||||
if (sender.muted()) {
|
if (sender.muted()) {
|
||||||
this.carbonMessages.muteCannotSpeak(sender);
|
this.messages.muteCannotSpeak(sender);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender.ignoringDirectMessages()) {
|
|
||||||
this.carbonMessages.whisperIgnoringAll(sender);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +89,7 @@ public final class ReplyCommand extends CarbonCommand {
|
|||||||
final @Nullable UUID replyTarget = sender.whisperReplyTarget();
|
final @Nullable UUID replyTarget = sender.whisperReplyTarget();
|
||||||
|
|
||||||
if (replyTarget == null) {
|
if (replyTarget == null) {
|
||||||
this.carbonMessages.replyTargetNotSet(sender, sender.displayName());
|
this.messages.replyTargetNotSet(sender, sender.displayName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -35,17 +35,14 @@ public class ToggleMessagesCommand extends CarbonCommand {
|
|||||||
|
|
||||||
private final CommandManager<Commander> commandManager;
|
private final CommandManager<Commander> commandManager;
|
||||||
private final CarbonMessages carbonMessages;
|
private final CarbonMessages carbonMessages;
|
||||||
private final ArgumentFactory argumentFactory;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ToggleMessagesCommand(
|
public ToggleMessagesCommand(
|
||||||
final CommandManager<Commander> commandManager,
|
final CommandManager<Commander> commandManager,
|
||||||
final CarbonMessages carbonMessages,
|
final CarbonMessages carbonMessages
|
||||||
final ArgumentFactory argumentFactory
|
|
||||||
) {
|
) {
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.carbonMessages = carbonMessages;
|
this.carbonMessages = carbonMessages;
|
||||||
this.argumentFactory = argumentFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -102,11 +102,6 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.ignoringDirectMessages()) {
|
|
||||||
this.carbonMessages.whisperIgnoringAll(sender);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String message = ctx.get("message");
|
final String message = ctx.get("message");
|
||||||
final CarbonPlayer recipient = ctx.get("player");
|
final CarbonPlayer recipient = ctx.get("player");
|
||||||
|
|
||||||
@@ -171,6 +166,11 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
return;
|
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")) {
|
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 ? recipient.username() : recipientInputString,
|
||||||
@@ -193,6 +193,7 @@ public final class WhisperCommand extends CarbonCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (recipient.ignoringDirectMessages() && !sender.hasPermission("carbon.togglemsg.exempt")) {
|
if (recipient.ignoringDirectMessages() && !sender.hasPermission("carbon.togglemsg.exempt")) {
|
||||||
|
this.messages.whisperTargetIgnoringDMs(sender, recipient.displayName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.draycia.carbon.common.messages;
|
package net.draycia.carbon.common.messages;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.moonshine.annotation.Message;
|
import net.kyori.moonshine.annotation.Message;
|
||||||
@@ -159,6 +160,9 @@ public interface CarbonMessages {
|
|||||||
@Message("whisper.ignored_by_target")
|
@Message("whisper.ignored_by_target")
|
||||||
void whisperTargetIgnoring(final Audience audience, final Component 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")
|
@Message("whisper.toggled.on")
|
||||||
void whispersToggledOn(final Audience audience);
|
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.NicknameCommand;
|
||||||
import net.draycia.carbon.common.command.commands.ReloadCommand;
|
import net.draycia.carbon.common.command.commands.ReloadCommand;
|
||||||
import net.draycia.carbon.common.command.commands.ReplyCommand;
|
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.UnignoreCommand;
|
||||||
import net.draycia.carbon.common.command.commands.UnmuteCommand;
|
import net.draycia.carbon.common.command.commands.UnmuteCommand;
|
||||||
import net.draycia.carbon.common.command.commands.UpdateUsernameCommand;
|
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,
|
public static final List<Class<? extends CarbonCommand>> COMMAND_CLASSES = List.of(ClearChatCommand.class,
|
||||||
ContinueCommand.class, DebugCommand.class, HelpCommand.class, IgnoreCommand.class, MuteCommand.class,
|
ContinueCommand.class, DebugCommand.class, HelpCommand.class, IgnoreCommand.class, MuteCommand.class,
|
||||||
MuteInfoCommand.class, NicknameCommand.class, ReloadCommand.class, ReplyCommand.class, UnignoreCommand.class,
|
MuteInfoCommand.class, NicknameCommand.class, ReloadCommand.class, ReplyCommand.class, ToggleMessagesCommand.class,
|
||||||
UnmuteCommand.class, UpdateUsernameCommand.class, WhisperCommand.class, JoinCommand.class, LeaveCommand.class);
|
UnignoreCommand.class, UnmuteCommand.class, UpdateUsernameCommand.class, WhisperCommand.class, JoinCommand.class, LeaveCommand.class);
|
||||||
|
|
||||||
private static final List<CarbonCommand> CONSTRUCTED_COMMANDS = new ArrayList<>();
|
private static final List<CarbonCommand> CONSTRUCTED_COMMANDS = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user