Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove throws of InvalidSubCommandException #21

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,13 @@ public BukkitCommandManager(CommandManager delegate, String fallbackPrefix) {
return true;
});

this.getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, ex) -> {
BukkitCommandWrapper.sendMessageToSender(ex, namespace);

String label = namespace.getObject(String.class, "label");

throw new org.bukkit.command.CommandException("An internal parse exception occurred while executing the command " + label, ex);
});

ErrorHandler.ErrorConsumer<ArgumentException> commonArgumentExceptionConsumer = (namespace, ex) -> {
BukkitCommandWrapper.sendMessageToSender(ex, namespace);

return false;
};

this.getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonArgumentExceptionConsumer);
this.getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonArgumentExceptionConsumer);
this.getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonArgumentExceptionConsumer);
this.getErrorHandler().addExceptionHandler(NoPermissionsException.class, (namespace, throwable) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,14 @@ public BungeeCommandManager(CommandManager commandManager, Plugin plugin) {
return false;
});

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, e) -> {
String label = namespace.getObject(String.class, "label");
BungeeCommandWrapper.sendMessageToSender(e, namespace);

throw new CommandException("An internal parse exception occurred while executing the command " + label, e);
});

ErrorHandler.ErrorConsumer<CommandException> commonHandler = (namespace, e) -> {
BungeeCommandWrapper.sendMessageToSender(e, namespace);

return true;
};

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonHandler);
getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoPermissionsException.class, commonHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ public DiscordCommandManager(CommandManager commandManager, JDA client, String c
return true;
});

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, e) -> {
MessageListener.sendMessage(namespace, e);

throw new CommandException("An internal parse exception occurred while executing the command", e);
});

ErrorHandler.ErrorConsumer<CommandException> commonHandler = (namespace, e) -> {
MessageListener.sendMessage(namespace, e);

return true;
};

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonHandler);
getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoPermissionsException.class, commonHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,14 @@ public VelocityCommandManager(ProxyServer proxyServer, CommandManager commandMan
return true;
});

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, (namespace, e) -> {
VelocityCommandWrapper.sendMessageToSender(e, namespace);

throw new CommandException("An internal parse exception occurred while executing the command", e);
});

ErrorHandler.ErrorConsumer<CommandException> commonHandler = (namespace, e) -> {
VelocityCommandWrapper.sendMessageToSender(e, namespace);

return true;
};

getErrorHandler().addExceptionHandler(InvalidSubCommandException.class, commonHandler);
getErrorHandler().addExceptionHandler(ArgumentParseException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoMoreArgumentsException.class, commonHandler);
getErrorHandler().addExceptionHandler(NoPermissionsException.class, commonHandler);
Expand Down