From a13ddabfddd89eaadd94da0573846947593839ed Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Wed, 26 Jan 2022 23:19:05 -0600 Subject: [PATCH] Add exceptions --- src/main/java/dev/plex/command/PlexCommand.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/plex/command/PlexCommand.java b/src/main/java/dev/plex/command/PlexCommand.java index aed606d..e8293d3 100644 --- a/src/main/java/dev/plex/command/PlexCommand.java +++ b/src/main/java/dev/plex/command/PlexCommand.java @@ -8,6 +8,8 @@ import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.exception.CommandArgumentException; import dev.plex.command.exception.CommandFailException; +import dev.plex.command.exception.ConsoleMustDefinePlayerException; +import dev.plex.command.exception.ConsoleOnlyException; import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.source.CommandSource; import dev.plex.command.source.RequiredCommandSource; @@ -106,6 +108,14 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC { send(ex.getMessage()); } + catch (ConsoleMustDefinePlayerException ex) + { + send(tl("consoleMustDefinePlayer")); + } + catch (ConsoleOnlyException ex) + { + send(tl("consoleOnly")); + } return true; } @@ -116,9 +126,8 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC { return ImmutableList.of(); } - if (sender instanceof Player) + if (sender instanceof Player player) { - Player player = (Player)sender; this.sender = new CommandSource(player);