mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user