✨ 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
|
|
@ -4,4 +4,6 @@ dependencies {
|
|||
api project(':cloud-tasks')
|
||||
compileOnly "org.bukkit:bukkit:${vers['bukkit']}"
|
||||
compileOnly "me.lucko:commodore:${vers['commodore']}"
|
||||
compileOnly "org.jetbrains:annotations:${vers['jb-annotations']}"
|
||||
compileOnly "com.google.guava:guava:${vers['guava']}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import java.util.logging.Level;
|
|||
*
|
||||
* @param <C> Command sender type
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public final class BukkitBrigadierMapper<C> {
|
||||
|
||||
private static final int UUID_ARGUMENT_VERSION = 16;
|
||||
|
|
@ -115,6 +116,7 @@ public final class BukkitBrigadierMapper<C> {
|
|||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnnecessaryLambda")
|
||||
private Supplier<ArgumentType<?>> getArgumentVec3() {
|
||||
return () -> {
|
||||
try {
|
||||
|
|
@ -152,7 +154,7 @@ public final class BukkitBrigadierMapper<C> {
|
|||
try {
|
||||
this.brigadierManager.registerDefaultArgumentTypeSupplier(type, () -> {
|
||||
try {
|
||||
return (ArgumentType<?>) constructor.newInstance();
|
||||
return constructor.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
|
|||
sender,
|
||||
builder.toString()
|
||||
)
|
||||
.whenComplete(((commandResult, throwable) -> {
|
||||
.whenComplete((commandResult, throwable) -> {
|
||||
if (throwable != null) {
|
||||
if (throwable instanceof CompletionException) {
|
||||
throwable = throwable.getCause();
|
||||
|
|
@ -138,7 +138,7 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
|
|||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ public class BukkitCommandManager<C> extends CommandManager<C> {
|
|||
private final Function<CommandSender, C> commandSenderMapper;
|
||||
private final Function<C, CommandSender> backwardsCommandSenderMapper;
|
||||
|
||||
private final BukkitSynchronizer bukkitSynchronizer;
|
||||
private final TaskFactory taskFactory;
|
||||
|
||||
private boolean splitAliases = false;
|
||||
|
|
@ -109,6 +108,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> {
|
|||
* @param backwardsCommandSenderMapper Function that maps the command sender type to {@link CommandSender}
|
||||
* @throws Exception If the construction of the manager fails
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public BukkitCommandManager(
|
||||
final @NonNull Plugin owningPlugin,
|
||||
final @NonNull Function<@NonNull CommandTree<C>,
|
||||
|
|
@ -123,8 +123,8 @@ public class BukkitCommandManager<C> extends CommandManager<C> {
|
|||
this.commandSenderMapper = commandSenderMapper;
|
||||
this.backwardsCommandSenderMapper = backwardsCommandSenderMapper;
|
||||
|
||||
this.bukkitSynchronizer = new BukkitSynchronizer(owningPlugin);
|
||||
this.taskFactory = new TaskFactory(this.bukkitSynchronizer);
|
||||
final BukkitSynchronizer bukkitSynchronizer = new BukkitSynchronizer(owningPlugin);
|
||||
this.taskFactory = new TaskFactory(bukkitSynchronizer);
|
||||
|
||||
/* Try to determine the Minecraft version */
|
||||
int version = -1;
|
||||
|
|
@ -148,6 +148,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> {
|
|||
Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||
paper = true;
|
||||
} catch (final Exception ignored) {
|
||||
// This is fine
|
||||
}
|
||||
this.paper = paper;
|
||||
|
||||
|
|
@ -183,7 +184,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> {
|
|||
this.owningPlugin
|
||||
);
|
||||
|
||||
this.registerDefaultCaptions(new BukkitCaptionRegistryFactory<C>().create());
|
||||
this.setCaptionRegistry(new BukkitCaptionRegistryFactory<C>().create());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -363,6 +364,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> {
|
|||
|
||||
public static final class BrigadierFailureException extends IllegalStateException {
|
||||
|
||||
private static final long serialVersionUID = 7816660840063155703L;
|
||||
private final BrigadierFailureReason reason;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ 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
|
||||
*/
|
||||
final class BukkitCommandPreprocessor<C> implements CommandPreprocessor<C> {
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
|
||||
/**
|
||||
* Command sender that proxies {@link org.bukkit.command.CommandSender}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public abstract class BukkitCommandSender {
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ public abstract class BukkitCommandSender {
|
|||
*
|
||||
* @param internalSender Bukkit command sender
|
||||
*/
|
||||
public BukkitCommandSender(final org.bukkit.command.@NonNull CommandSender internalSender) {
|
||||
protected BukkitCommandSender(final org.bukkit.command.@NonNull CommandSender internalSender) {
|
||||
this.internalSender = internalSender;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
|
|||
this.commandMap = (CommandMap) getCommandMap.invoke(Bukkit.getServer());
|
||||
final Field knownCommands = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||
knownCommands.setAccessible(true);
|
||||
@SuppressWarnings("ALL") final Map<String, org.bukkit.command.Command> bukkitCommands =
|
||||
@SuppressWarnings("unchecked") final Map<String, org.bukkit.command.Command> bukkitCommands =
|
||||
(Map<String, org.bukkit.command.Command>) knownCommands.get(commandMap);
|
||||
this.bukkitCommands = bukkitCommands;
|
||||
this.bukkitCommandManager = bukkitCommandManager;
|
||||
|
|
@ -83,7 +83,7 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
|
|||
|
||||
@SuppressWarnings("unchecked") final BukkitCommand<C> bukkitCommand = new BukkitCommand<>(
|
||||
label,
|
||||
(this.bukkitCommandManager.getSplitAliases() ? Collections.<String>emptyList() : aliases),
|
||||
(this.bukkitCommandManager.getSplitAliases() ? Collections.emptyList() : aliases),
|
||||
(Command<C>) command,
|
||||
(CommandArgument<C, ?>) commandArgument,
|
||||
this.bukkitCommandManager
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
class CloudCommodoreManager<C> extends BukkitPluginRegistrationHandler<C> {
|
||||
|
||||
private final BukkitCommandManager<C> commandManager;
|
||||
|
|
@ -77,7 +77,7 @@ class CloudCommodoreManager<C> extends BukkitPluginRegistrationHandler<C> {
|
|||
) {
|
||||
final com.mojang.brigadier.Command<?> cmd = o -> 1;
|
||||
final LiteralCommandNode<?> literalCommandNode = this.brigadierManager
|
||||
.<Object>createLiteralCommandNode(label, command, (o, p) -> {
|
||||
.createLiteralCommandNode(label, command, (o, p) -> {
|
||||
final CommandSender sender = this.commodore.getBukkitSender(o);
|
||||
return this.commandManager.hasPermission(
|
||||
this.commandManager.getCommandSenderMapper().apply(sender),
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public abstract class EntitySelector {
|
|||
* @param selector The input string used to create this selector
|
||||
* @param entities The List of Bukkit {@link Entity entities} to construct the {@link EntitySelector} from
|
||||
*/
|
||||
public EntitySelector(
|
||||
protected EntitySelector(
|
||||
final @NonNull String selector,
|
||||
final @NonNull List<@NonNull Entity> entities
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, Enchantment> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(Enchantment.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -127,6 +127,7 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
|
|||
public static final class EnchantmentParser<C> implements ArgumentParser<C, Enchantment> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public @NonNull ArgumentParseResult<Enchantment> parse(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull Queue<@NonNull String> inputQueue
|
||||
|
|
@ -142,7 +143,6 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
|
|||
final NamespacedKey key;
|
||||
if (input.contains(":")) {
|
||||
final String[] splitInput = input.split(":");
|
||||
//noinspection deprecation
|
||||
key = new NamespacedKey(splitInput[0], splitInput[1]);
|
||||
} else {
|
||||
key = NamespacedKey.minecraft(input);
|
||||
|
|
@ -177,6 +177,7 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
|
|||
|
||||
public static final class EnchantmentParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = 1415174766296065151L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class MaterialArgument<C> extends CommandArgument<C, Material> {
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, Material> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(Material.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -164,6 +164,7 @@ public class MaterialArgument<C> extends CommandArgument<C, Material> {
|
|||
|
||||
public static final class MaterialParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = 1615554107385965610L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, OfflinePlayer> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(OfflinePlayer.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -136,6 +136,7 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
|
|||
public static final class OfflinePlayerParser<C> implements ArgumentParser<C, OfflinePlayer> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public @NonNull ArgumentParseResult<OfflinePlayer> parse(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull Queue<String> inputQueue
|
||||
|
|
@ -149,10 +150,9 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
|
|||
}
|
||||
inputQueue.remove();
|
||||
|
||||
//noinspection deprecation
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(input);
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(input);
|
||||
|
||||
if (player == null || (!player.hasPlayedBefore() && !player.isOnline())) {
|
||||
if (!player.hasPlayedBefore() && !player.isOnline()) {
|
||||
return ArgumentParseResult.failure(new OfflinePlayerParseException(input, commandContext));
|
||||
}
|
||||
|
||||
|
|
@ -181,6 +181,7 @@ public final class OfflinePlayerArgument<C> extends CommandArgument<C, OfflinePl
|
|||
*/
|
||||
public static final class OfflinePlayerParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = 7632293268451349508L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, Player> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(Player.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +130,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
|
|||
public static final class PlayerParser<C> implements ArgumentParser<C, Player> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public @NonNull ArgumentParseResult<Player> parse(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull Queue<@NonNull String> inputQueue
|
||||
|
|
@ -143,7 +144,6 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
|
|||
}
|
||||
inputQueue.remove();
|
||||
|
||||
//noinspection deprecation
|
||||
Player player = Bukkit.getPlayer(input);
|
||||
|
||||
if (player == null) {
|
||||
|
|
@ -175,6 +175,7 @@ public final class PlayerArgument<C> extends CommandArgument<C, Player> {
|
|||
*/
|
||||
public static final class PlayerParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = 927476591631527552L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class WorldArgument<C> extends CommandArgument<C, World> {
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, World> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(World.class, name);
|
||||
}
|
||||
|
||||
|
|
@ -154,6 +154,7 @@ public class WorldArgument<C> extends CommandArgument<C, World> {
|
|||
|
||||
public static final class WorldParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = 561648144491587450L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -289,6 +289,8 @@ public final class LocationArgument<C> extends CommandArgument<C, Location> {
|
|||
|
||||
private static class LocationParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = -3261835227265878218L;
|
||||
|
||||
protected LocationParseException(
|
||||
final @NonNull CommandContext<?> context,
|
||||
final @NonNull String input
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, MultipleEntitySelector> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(MultipleEntitySelector.class, name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, MultiplePlayerSelector> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(MultiplePlayerSelector.class, name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
*/
|
||||
public final class SelectorParseException extends ParserException {
|
||||
|
||||
private static final long serialVersionUID = 1900826717897819065L;
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, SingleEntitySelector> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(SingleEntitySelector.class, name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
|
|||
|
||||
public static final class Builder<C> extends CommandArgument.Builder<C, SinglePlayerSelector> {
|
||||
|
||||
protected Builder(final @NonNull String name) {
|
||||
private Builder(final @NonNull String name) {
|
||||
super(SinglePlayerSelector.class, name);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue