mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
don't throw exceptions in commands
This commit is contained in:
4 files changed
+16
-2
No files matched your search
@@ -22,6 +22,7 @@ package net.draycia.carbon.common.command.commands;
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.exceptions.CommandExecutionException;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
@@ -67,7 +68,9 @@ public class MuteCommand {
|
||||
final var result = carbonChat.server().player(handler.<UUID>get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
} else {
|
||||
throw new IllegalStateException("No target found to unmute.");
|
||||
messageService.muteNoTarget(sender);
|
||||
// TODO: send command syntax
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.hasPermission("carbon.mute.exempt")) {
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.draycia.carbon.common.command.commands;
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.exceptions.CommandExecutionException;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
@@ -68,7 +69,9 @@ public class UnmuteCommand {
|
||||
final var result = carbonChat.server().player(handler.<UUID>get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
} else {
|
||||
throw new IllegalStateException("No target found to unmute.");
|
||||
messageService.unmuteNoTarget(sender);
|
||||
// TODO: send command syntax
|
||||
return;
|
||||
}
|
||||
|
||||
messageService.unmuteAlertRecipient(target);
|
||||
|
||||
@@ -74,6 +74,9 @@ public interface CarbonMessageService {
|
||||
@Message("mute.unmute.alert.players")
|
||||
void unmuteAlertPlayers(final Audience audience, final Component target);
|
||||
|
||||
@Message("mute.unmute.no_target")
|
||||
void unmuteNoTarget(final Audience audience);
|
||||
|
||||
@Message("mute.exempt")
|
||||
void muteExempt(final Audience audience);
|
||||
|
||||
@@ -86,6 +89,9 @@ public interface CarbonMessageService {
|
||||
@Message("mute.cannot_speak")
|
||||
void muteCannotSpeak(final Audience audience);
|
||||
|
||||
@Message("mute.no_target")
|
||||
void muteNoTarget(final Audience audience);
|
||||
|
||||
@Message("mute.spy.prefix")
|
||||
RenderedMessage muteSpyPrefix(final Audience audience);
|
||||
|
||||
|
||||
@@ -32,9 +32,11 @@ mute.info.muted=<red><target> <red>is muted
|
||||
mute.info.not_muted=<red><target> <gold>is not muted
|
||||
mute.info.self.muted=<red>You are muted
|
||||
mute.info.self.not_muted=<green>You are not muted
|
||||
mute.no_target=<red>No specified player to mute.
|
||||
mute.spy.prefix=<red><hover:show_text:<red>Muted</red>M</hover></red>
|
||||
mute.unmute.alert.players=<green><target> <green>has been unmuted
|
||||
mute.unmute.alert.target=<green>You have been unmuted
|
||||
mute.unmute.no_target=<red>No specified player to unmute.
|
||||
nickname.reset.others=<green><username></green><gold>'s nickname was reset
|
||||
nickname.reset=<gold>Your nickname was reset
|
||||
nickname.set.others=<green>You set </green><target><green>'s nickname to </green><nickname>
|
||||
|
||||
Reference in new issue
Block a user