Add errorprone and fix warnings/errors

The compiler will also treat all warnings as errors from now on.
This commit is contained in:
Alexander Söderberg 2020-10-23 10:20:45 +02:00 committed by Alexander Söderberg
parent 6ffee9d04f
commit cfac2639ad
101 changed files with 309 additions and 146 deletions

View file

@ -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> {
/**

View file

@ -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());

View file

@ -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;

View file

@ -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
*

View file

@ -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
*