From d6f3f9a633d325d4a669766eb51f455a6ef1d08f Mon Sep 17 00:00:00 2001 From: Draycia Date: Tue, 14 Jan 2025 14:38:31 -0800 Subject: [PATCH] Allow console to use mute/unmute/debug --- .../common/command/commands/DebugCommand.java | 8 +++++--- .../common/command/commands/MuteCommand.java | 15 ++++++++------- .../common/command/commands/UnmuteCommand.java | 12 ++++-------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/DebugCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/DebugCommand.java index 911b4caf..cf7ccd51 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/DebugCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/DebugCommand.java @@ -72,16 +72,18 @@ public final class DebugCommand extends CarbonCommand { .optional("player", this.parserFactory.carbonPlayer(), richDescription(this.carbonMessages.commandDebugArgumentPlayer())) .permission("carbon.debug") - .senderType(PlayerCommander.class) + .senderType(Commander.class) .commandDescription(richDescription(this.carbonMessages.commandDebugDescription())) .handler(handler -> { - final CarbonPlayer sender = handler.sender().carbonPlayer(); + final Commander sender = handler.sender(); final CarbonPlayer target; if (handler.contains("player")) { target = handler.get("player"); + } else if (sender instanceof PlayerCommander playerCommander) { + target = playerCommander.carbonPlayer(); } else { - target = sender; + return; } sender.sendMessage( diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/MuteCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/MuteCommand.java index 94d04dd0..53210c30 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/MuteCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/MuteCommand.java @@ -82,10 +82,10 @@ public final class MuteCommand extends CarbonCommand { .withComponent(uuidParser()) ) .permission("carbon.mute") - .senderType(PlayerCommander.class) + .senderType(Commander.class) .commandDescription(richDescription(this.carbonMessages.commandMuteDescription())) .handler(handler -> { - final CarbonPlayer sender = handler.sender().carbonPlayer(); + final Commander sender = handler.sender(); final CarbonPlayer target; if (handler.contains("player")) { @@ -103,14 +103,15 @@ public final class MuteCommand extends CarbonCommand { return; } - this.carbonMessages.muteAlertRecipient(target); - - if (!sender.equals(target)) { - this.carbonMessages.muteAlertPlayers(sender, target.displayName()); + if (sender instanceof PlayerCommander playerCommander && playerCommander.carbonPlayer().equals(target)) { + this.carbonMessages.muteExempt(playerCommander); } + this.carbonMessages.muteAlertRecipient(target); + this.carbonMessages.muteAlertRecipient(this.server.console()); + for (final var player : this.server.players()) { - if (player.equals(target) || player.equals(sender)) { + if (player.equals(target)) { continue; } diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/UnmuteCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/UnmuteCommand.java index 990a037a..e7a9f171 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/UnmuteCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/UnmuteCommand.java @@ -27,7 +27,6 @@ import net.draycia.carbon.common.command.CarbonCommand; import net.draycia.carbon.common.command.CommandSettings; import net.draycia.carbon.common.command.Commander; import net.draycia.carbon.common.command.ParserFactory; -import net.draycia.carbon.common.command.PlayerCommander; import net.draycia.carbon.common.messages.CarbonMessages; import net.kyori.adventure.key.Key; import org.checkerframework.checker.nullness.qual.NonNull; @@ -82,10 +81,10 @@ public final class UnmuteCommand extends CarbonCommand { .withComponent(uuidParser()) ) .permission("carbon.mute.unmute") - .senderType(PlayerCommander.class) + .senderType(Commander.class) .commandDescription(richDescription(this.carbonMessages.commandUnmuteDescription())) .handler(handler -> { - final CarbonPlayer sender = handler.sender().carbonPlayer(); + final Commander sender = handler.sender(); final CarbonPlayer target; if (handler.contains("player")) { @@ -99,13 +98,10 @@ public final class UnmuteCommand extends CarbonCommand { } this.carbonMessages.unmuteAlertRecipient(target); - - if (!sender.equals(target)) { - this.carbonMessages.unmuteAlertPlayers(sender, target.displayName()); - } + this.carbonMessages.unmuteAlertPlayers(this.server.console(), target.displayName()); for (final var player : this.server.players()) { - if (player.equals(target) || player.equals(sender)) { + if (player.equals(target)) { continue; }