✨ Add errorprone and fix warnings/errors
The compiler will also treat all warnings as errors from now on.
This commit is contained in:
parent
6ffee9d04f
commit
cfac2639ad
101 changed files with 309 additions and 146 deletions
|
|
@ -46,19 +46,17 @@ public class JavacordCommand<C> implements MessageCreateListener {
|
|||
|
||||
private final JavacordCommandManager<C> manager;
|
||||
private final CommandArgument<C, ?> command;
|
||||
private final cloud.commandframework.Command<C> cloudCommand;
|
||||
|
||||
JavacordCommand(
|
||||
final cloud.commandframework.@NonNull Command<C> cloudCommand,
|
||||
final @NonNull CommandArgument<C, ?> command,
|
||||
final @NonNull JavacordCommandManager<C> manager
|
||||
) {
|
||||
this.command = command;
|
||||
this.manager = manager;
|
||||
this.cloudCommand = cloudCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void onMessageCreate(final @NonNull MessageCreateEvent event) {
|
||||
MessageAuthor messageAuthor = event.getMessageAuthor();
|
||||
|
||||
|
|
@ -85,7 +83,6 @@ public class JavacordCommand<C> implements MessageCreateListener {
|
|||
messageContent = messageContent.replaceFirst(commandPrefix, "");
|
||||
|
||||
final String finalContent = messageContent;
|
||||
//noinspection unchecked
|
||||
if (((StaticArgument<C>) command).getAliases()
|
||||
.stream()
|
||||
.map(String::toLowerCase)
|
||||
|
|
@ -94,7 +91,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
|
|||
}
|
||||
|
||||
manager.executeCommand(sender, finalContent)
|
||||
.whenComplete(((commandResult, throwable) -> {
|
||||
.whenComplete((commandResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -158,7 +155,7 @@ public class JavacordCommand<C> implements MessageCreateListener {
|
|||
|
||||
commandSender.sendErrorMessage(throwable.getMessage());
|
||||
throwable.printStackTrace();
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ public class JavacordCommandManager<C> extends CommandManager<C> {
|
|||
* @param backwardsCommandSenderMapper Function that maps the command sender type to {@link Object}
|
||||
* @param commandPrefixMapper Function that maps the command sender type to the command prefix
|
||||
* @param commandPermissionMapper Function used to check if a command sender has the permission to execute a command
|
||||
* @throws Exception If the construction of the manager fails
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public JavacordCommandManager(
|
||||
final @NonNull DiscordApi discordApi,
|
||||
final @NonNull Function<@NonNull CommandTree<C>,
|
||||
|
|
@ -69,8 +69,7 @@ public class JavacordCommandManager<C> extends CommandManager<C> {
|
|||
final @NonNull Function<@NonNull C, @NonNull String> commandPrefixMapper,
|
||||
final @Nullable BiFunction<@NonNull C,
|
||||
@NonNull String, @NonNull Boolean> commandPermissionMapper
|
||||
)
|
||||
throws Exception {
|
||||
) {
|
||||
super(commandExecutionCoordinator, new JavacordRegistrationHandler<>());
|
||||
((JavacordRegistrationHandler<C>) this.getCommandRegistrationHandler()).initialize(this);
|
||||
this.discordApi = discordApi;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ final class JavacordRegistrationHandler<C> implements CommandRegistrationHandler
|
|||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked") final JavacordCommand<C> javacordCommand = new JavacordCommand<>(
|
||||
(Command<C>) command,
|
||||
(CommandArgument<C, ?>) commandArgument,
|
||||
this.javacordCommandManager
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,20 +25,20 @@ package cloud.commandframework.jda;
|
|||
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Command manager for use with JDA 4
|
||||
*
|
||||
* @param <C> Command sender type
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class JDA4CommandManager<C> extends JDACommandManager<C> {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
*
|
||||
* @param <C> Command sender type
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class JDACommandListener<C> extends ListenerAdapter {
|
||||
|
||||
private static final String MESSAGE_INVALID_SYNTAX = "Invalid Command Syntax. Correct command syntax is: ";
|
||||
|
|
@ -59,7 +60,6 @@ public class JDACommandListener<C> extends ListenerAdapter {
|
|||
@Override
|
||||
public final void onMessageReceived(final @NonNull MessageReceivedEvent event) {
|
||||
final Message message = event.getMessage();
|
||||
final JDACommandSender jdaCommandSender = JDACommandSender.of(event);
|
||||
final C sender = this.commandManager.getCommandSenderMapper().apply(event);
|
||||
|
||||
if (this.commandManager.getBotId() == event.getAuthor().getIdLong()) {
|
||||
|
|
@ -84,13 +84,11 @@ public class JDACommandListener<C> extends ListenerAdapter {
|
|||
if (throwable instanceof InvalidSyntaxException) {
|
||||
this.commandManager.handleException(sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable, (c, e) -> {
|
||||
this.sendMessage(
|
||||
event,
|
||||
MESSAGE_INVALID_SYNTAX + prefix + ((InvalidSyntaxException) throwable)
|
||||
.getCorrectSyntax()
|
||||
);
|
||||
}
|
||||
(InvalidSyntaxException) throwable, (c, e) -> this.sendMessage(
|
||||
event,
|
||||
MESSAGE_INVALID_SYNTAX + prefix + ((InvalidSyntaxException) throwable)
|
||||
.getCorrectSyntax()
|
||||
)
|
||||
);
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
this.commandManager.handleException(sender,
|
||||
|
|
@ -112,13 +110,11 @@ public class JDACommandListener<C> extends ListenerAdapter {
|
|||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
this.commandManager.handleException(sender, ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable, (c, e) -> {
|
||||
this.sendMessage(
|
||||
event,
|
||||
"Invalid Command Argument: " + throwable.getCause()
|
||||
.getMessage()
|
||||
);
|
||||
}
|
||||
(ArgumentParseException) throwable, (c, e) -> this.sendMessage(
|
||||
event,
|
||||
"Invalid Command Argument: " + throwable.getCause()
|
||||
.getMessage()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
this.sendMessage(event, throwable.getMessage());
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
* Command preprocessor which decorates incoming {@link cloud.commandframework.context.CommandContext}
|
||||
* with Bukkit specific objects
|
||||
*
|
||||
* @param <C>
|
||||
* @param <C> Command sender type
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
final class JDACommandPreprocessor<C> implements CommandPreprocessor<C> {
|
||||
|
||||
private final JDACommandManager<C> mgr;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
|
||||
private List<ParserMode> modes = new ArrayList<>();
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(MessageChannel.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -228,6 +228,7 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
|
||||
public static class ChannelParseException extends IllegalArgumentException {
|
||||
|
||||
private static final long serialVersionUID = 2724288304060572202L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
@ -253,6 +254,8 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
|
||||
public static final class TooManyChannelsFoundParseException extends ChannelParseException {
|
||||
|
||||
private static final long serialVersionUID = -507783063742841507L;
|
||||
|
||||
/**
|
||||
* Construct a new channel parse exception
|
||||
*
|
||||
|
|
@ -272,6 +275,8 @@ public final class ChannelArgument<C> extends CommandArgument<C, MessageChannel>
|
|||
|
||||
public static final class ChannelNotFoundException extends ChannelParseException {
|
||||
|
||||
private static final long serialVersionUID = -8299458048947528494L;
|
||||
|
||||
/**
|
||||
* Construct a new channel parse exception
|
||||
*
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
private Set<ParserMode> modes = new HashSet<>();
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(User.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -244,6 +244,7 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
public static class UserParseException extends IllegalArgumentException {
|
||||
|
||||
private static final long serialVersionUID = -6728909884195850077L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
@ -269,6 +270,8 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
public static final class TooManyUsersFoundParseException extends UserParseException {
|
||||
|
||||
private static final long serialVersionUID = 7222089412615886672L;
|
||||
|
||||
/**
|
||||
* Construct a new user parse exception
|
||||
*
|
||||
|
|
@ -288,6 +291,8 @@ public final class UserArgument<C> extends CommandArgument<C, User> {
|
|||
|
||||
public static final class UserNotFoundParseException extends UserParseException {
|
||||
|
||||
private static final long serialVersionUID = 3689949065073643826L;
|
||||
|
||||
/**
|
||||
* Construct a new user parse exception
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue