From aab8f86aa8c631170bad5f93556e931acdd3b96b Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 12 Jul 2021 09:13:12 -0400 Subject: [PATCH] Fix cherry-picking issues --- .../brigadier/StringArrayArgumentType.java | 4 +- .../brigadier/VelocityArgumentBuilder.java | 2 +- .../VelocityArgumentCommandNode.java | 3 +- .../registrar/BrigadierCommandRegistrar.java | 2 +- .../registrar/InvocableCommandRegistrar.java | 2 +- .../proxy/command/BrigadierCommandTests.java | 4 +- .../command/CommandGraphInjectorTests.java | 8 ++-- .../proxy/command/CommandManagerTests.java | 4 +- .../proxy/command/CommandTestSuite.java | 9 +++- .../proxy/command/RawCommandTests.java | 42 +++++++++---------- .../proxy/command/SimpleCommandTests.java | 42 +++++++++---------- .../command/SuggestionsProviderTests.java | 4 +- .../VelocityArgumentCommandNodeTests.java | 2 + 13 files changed, 72 insertions(+), 56 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/StringArrayArgumentType.java b/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/StringArrayArgumentType.java index eefeec46e..46739f835 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/StringArrayArgumentType.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/StringArrayArgumentType.java @@ -39,7 +39,9 @@ public final class StringArrayArgumentType implements ArgumentType { Splitter.on(CommandDispatcher.ARGUMENT_SEPARATOR_CHAR); private static final List EXAMPLES = Arrays.asList("word", "some words"); - private StringArrayArgumentType() {} + private StringArrayArgumentType() { + + } @Override public String[] parse(final StringReader reader) throws CommandSyntaxException { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentBuilder.java b/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentBuilder.java index 62e8c8b93..b475b7ec5 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentBuilder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentBuilder.java @@ -52,7 +52,7 @@ public final class VelocityArgumentBuilder private final String name; private final ArgumentType type; - private SuggestionProvider suggestionsProvider = null; + private @Nullable SuggestionProvider suggestionsProvider = null; private VelocityArgumentBuilder(final String name, final ArgumentType type) { this.name = name; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNode.java b/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNode.java index d0bb4f6ec..0a263efb8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNode.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNode.java @@ -38,6 +38,7 @@ import java.util.Collection; import java.util.concurrent.CompletableFuture; import java.util.function.BiPredicate; import java.util.function.Predicate; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An argument node that uses the given (possibly custom) {@link ArgumentType} @@ -56,7 +57,7 @@ public class VelocityArgumentCommandNode extends ArgumentCommandNode requirement, final BiPredicate, ImmutableStringReader> contextRequirement, final CommandNode redirect, final RedirectModifier modifier, final boolean forks, - final SuggestionProvider customSuggestions) { + final @Nullable SuggestionProvider customSuggestions) { super(name, StringArgumentType.greedyString(), command, requirement, contextRequirement, redirect, modifier, forks, customSuggestions); this.type = Preconditions.checkNotNull(type, "type"); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/registrar/BrigadierCommandRegistrar.java b/proxy/src/main/java/com/velocitypowered/proxy/command/registrar/BrigadierCommandRegistrar.java index 432065f3f..bb18ce4d1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/registrar/BrigadierCommandRegistrar.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/registrar/BrigadierCommandRegistrar.java @@ -46,7 +46,7 @@ public final class BrigadierCommandRegistrar extends AbstractCommandRegistrar
, @Override public void register(final CommandMeta meta, final T command) { - final Iterator aliases = meta.getAliases().iterator(); + final Iterator aliases = meta.aliases().iterator(); final String primaryAlias = aliases.next(); final LiteralCommandNode literal = diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/BrigadierCommandTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/BrigadierCommandTests.java index 1e6cb706a..88fc0bb33 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/BrigadierCommandTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/BrigadierCommandTests.java @@ -205,7 +205,7 @@ public class BrigadierCommandTests extends CommandTestSuite { manager.register(new BrigadierCommand(node)); final Exception wrapper = assertThrows(CompletionException.class, () -> - manager.executeAsync(source, "hello").join()); + manager.execute(source, "hello").join()); assertSame(expected, wrapper.getCause().getCause()); } @@ -223,7 +223,7 @@ public class BrigadierCommandTests extends CommandTestSuite { manager.register(new BrigadierCommand(node)); final Exception wrapper = assertThrows(CompletionException.class, () -> - manager.executeAsync(source, "hello").join()); + manager.execute(source, "hello").join()); assertSame(expected, wrapper.getCause().getCause()); } diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandGraphInjectorTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandGraphInjectorTests.java index 3f86b8c4a..33c32af31 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandGraphInjectorTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandGraphInjectorTests.java @@ -48,7 +48,7 @@ public class CommandGraphInjectorTests extends CommandTestSuite { @Test void testInjectInvocableCommand() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (SimpleCommand) invocation -> fail()); manager.getInjector().inject(dest, source); @@ -61,7 +61,7 @@ public class CommandGraphInjectorTests extends CommandTestSuite { void testFiltersImpermissibleAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -88,7 +88,7 @@ public class CommandGraphInjectorTests extends CommandTestSuite { final var hint = LiteralArgumentBuilder .literal("hint") .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, (SimpleCommand) invocation -> fail()); @@ -106,7 +106,7 @@ public class CommandGraphInjectorTests extends CommandTestSuite { final var hint = LiteralArgumentBuilder .literal("hint") .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new RawCommand() { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java index 50c6cd856..d4b7577b2 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandManagerTests.java @@ -166,7 +166,9 @@ public class CommandManagerTests extends CommandTestSuite { static final DummyCommand INSTANCE = new DummyCommand(); - private DummyCommand() {} + private DummyCommand() { + + } @Override public void execute(final Invocation invocation) { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java index c69443c96..28cbc0449 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/CommandTestSuite.java @@ -25,13 +25,14 @@ import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.proxy.event.MockEventManager; import com.velocitypowered.proxy.event.VelocityEventManager; import java.util.Arrays; +import org.checkerframework.checker.nullness.qual.Nullable; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; abstract class CommandTestSuite { - private static VelocityEventManager eventManager; + private static @Nullable VelocityEventManager eventManager; protected VelocityCommandManager manager; protected final CommandSource source = MockCommandSource.INSTANCE; @@ -44,6 +45,9 @@ abstract class CommandTestSuite { @AfterAll static void afterAll() { try { + if (eventManager == null) { + throw new AssertionError("Event manager must exist"); + } eventManager.shutdown(); eventManager = null; } catch (final InterruptedException e) { @@ -53,6 +57,9 @@ abstract class CommandTestSuite { @BeforeEach void setUp() { + if (eventManager == null) { + throw new AssertionError("Event manager must exist"); + } this.manager = new VelocityCommandManager(eventManager); } diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/RawCommandTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/RawCommandTests.java index 1c92c7787..cf41496a9 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/RawCommandTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/RawCommandTests.java @@ -42,7 +42,7 @@ public class RawCommandTests extends CommandTestSuite { void testExecuteAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (RawCommand) invocation -> { assertEquals(source, invocation.source()); assertEquals("hello", invocation.alias()); @@ -58,7 +58,7 @@ public class RawCommandTests extends CommandTestSuite { void testExecuteIgnoresAliasCase() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (RawCommand) invocation -> { assertEquals("hello", invocation.alias()); callCount.incrementAndGet(); @@ -72,7 +72,7 @@ public class RawCommandTests extends CommandTestSuite { void testExecuteInputIsTrimmed() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (RawCommand) invocation -> { assertEquals("hello", invocation.alias()); assertEquals("", invocation.arguments()); @@ -88,7 +88,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testExecuteAfterUnregisterForwards() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (RawCommand) invocation -> fail()); manager.unregister("hello"); @@ -99,7 +99,7 @@ public class RawCommandTests extends CommandTestSuite { void testForwardsAndDoesNotExecuteImpermissibleAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -124,7 +124,7 @@ public class RawCommandTests extends CommandTestSuite { void testExecutesWithArguments() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (RawCommand) invocation -> { assertEquals("hello", invocation.alias()); assertEquals("dear world", invocation.arguments()); @@ -139,7 +139,7 @@ public class RawCommandTests extends CommandTestSuite { void testHandlesAndDoesNotExecuteWithImpermissibleArgs() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("color").build(); + final var meta = manager.createMetaBuilder("color").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -163,7 +163,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestAliasIfImpermissible() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -186,7 +186,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestAliasAfterUnregister() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -205,7 +205,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testSuggestsArgumentsAfterAlias() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -225,7 +225,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testSuggestsArgumentsAfterAliasIgnoresAliasCase() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -244,7 +244,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testSuggestsArgumentsAfterPartialArguments() { - final var meta = manager.metaBuilder("numbers").build(); + final var meta = manager.createMetaBuilder("numbers").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -265,7 +265,7 @@ public class RawCommandTests extends CommandTestSuite { void testDoesNotSuggestFirstArgumentIfImpermissibleAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -294,7 +294,7 @@ public class RawCommandTests extends CommandTestSuite { void testDoesNotSuggestArgumentsAfterPartialImpermissibleArguments() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("foo").build(); + final var meta = manager.createMetaBuilder("foo").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -321,7 +321,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestIfFutureCompletesExceptionally() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -339,7 +339,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestIfSuggestAsyncThrows() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -358,7 +358,7 @@ public class RawCommandTests extends CommandTestSuite { @Test void testSuggestCompletesExceptionallyIfHasPermissionThrows() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new RawCommand() { @Override public void execute(final Invocation invocation) { @@ -389,7 +389,7 @@ public class RawCommandTests extends CommandTestSuite { final var hint = LiteralArgumentBuilder .literal("hint") .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new RawCommand() { @@ -412,7 +412,7 @@ public class RawCommandTests extends CommandTestSuite { final var hint = LiteralArgumentBuilder .literal("hint") .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new RawCommand() { @@ -436,7 +436,7 @@ public class RawCommandTests extends CommandTestSuite { .argument("hint", word()) .suggests((context, builder) -> CompletableFuture.failedFuture(new RuntimeException())) .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new RawCommand() { @@ -462,7 +462,7 @@ public class RawCommandTests extends CommandTestSuite { throw new RuntimeException(); }) .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new RawCommand() { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/SimpleCommandTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/SimpleCommandTests.java index a6471bf45..a222a4d24 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/SimpleCommandTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/SimpleCommandTests.java @@ -43,7 +43,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testExecutesAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (SimpleCommand) invocation -> { assertEquals(source, invocation.source()); assertEquals("hello", invocation.alias()); @@ -59,7 +59,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testExecuteIgnoresAliasCase() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (SimpleCommand) invocation -> { assertEquals("hello", invocation.alias()); callCount.incrementAndGet(); @@ -73,7 +73,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testExecuteInputIsTrimmed() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (SimpleCommand) invocation -> { assertEquals("hello", invocation.alias()); assertArrayEquals(new String[0], invocation.arguments()); @@ -89,7 +89,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testExecuteAfterUnregisterForwards() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (SimpleCommand) invocation -> fail()); manager.unregister("hello"); @@ -100,7 +100,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testForwardsAndDoesNotExecuteImpermissibleAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -125,7 +125,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testExecutesWithArguments() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, (SimpleCommand) invocation -> { assertEquals("hello", invocation.alias()); assertArrayEquals(new String[] { "dear", "world" }, invocation.arguments()); @@ -140,7 +140,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testHandlesAndDoesNotExecuteWithImpermissibleArgs() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("color").build(); + final var meta = manager.createMetaBuilder("color").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -164,7 +164,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestAliasIfImpermissible() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -187,7 +187,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestAliasAfterUnregister() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -206,7 +206,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testSuggestsArgumentsAfterAlias() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -226,7 +226,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testSuggestsArgumentsAfterAliasIgnoresAliasCase() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -245,7 +245,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testSuggestsArgumentsAfterPartialArguments() { - final var meta = manager.metaBuilder("numbers").build(); + final var meta = manager.createMetaBuilder("numbers").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -266,7 +266,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testDoesNotSuggestFirstArgumentIfImpermissibleAlias() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -295,7 +295,7 @@ public class SimpleCommandTests extends CommandTestSuite { void testDoesNotSuggestArgumentsAfterPartialImpermissibleArguments() { final var callCount = new AtomicInteger(); - final var meta = manager.metaBuilder("foo").build(); + final var meta = manager.createMetaBuilder("foo").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -322,7 +322,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestIfFutureCompletesExceptionally() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -340,7 +340,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testDoesNotSuggestIfSuggestAsyncThrows() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -359,7 +359,7 @@ public class SimpleCommandTests extends CommandTestSuite { @Test void testSuggestCompletesExceptionallyIfHasPermissionThrows() { - final var meta = manager.metaBuilder("hello").build(); + final var meta = manager.createMetaBuilder("hello").build(); manager.register(meta, new SimpleCommand() { @Override public void execute(final Invocation invocation) { @@ -390,7 +390,7 @@ public class SimpleCommandTests extends CommandTestSuite { final var hint = LiteralArgumentBuilder .literal("hint") .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new SimpleCommand() { @@ -413,7 +413,7 @@ public class SimpleCommandTests extends CommandTestSuite { final var hint = LiteralArgumentBuilder .literal("hint") .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new SimpleCommand() { @@ -437,7 +437,7 @@ public class SimpleCommandTests extends CommandTestSuite { .argument("hint", word()) .suggests((context, builder) -> CompletableFuture.failedFuture(new RuntimeException())) .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new SimpleCommand() { @@ -463,7 +463,7 @@ public class SimpleCommandTests extends CommandTestSuite { throw new RuntimeException(); }) .build(); - final var meta = manager.metaBuilder("hello") + final var meta = manager.createMetaBuilder("hello") .hint(hint) .build(); manager.register(meta, new SimpleCommand() { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/SuggestionsProviderTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/SuggestionsProviderTests.java index 12889a4cf..e9a90654b 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/SuggestionsProviderTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/SuggestionsProviderTests.java @@ -244,7 +244,9 @@ public class SuggestionsProviderTests extends CommandTestSuite { static final NoSuggestionsCommand INSTANCE = new NoSuggestionsCommand(); - private NoSuggestionsCommand() {} + private NoSuggestionsCommand() { + + } @Override public void execute(final Invocation invocation) { diff --git a/proxy/src/test/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNodeTests.java b/proxy/src/test/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNodeTests.java index 1c1d6084b..8d65e3424 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNodeTests.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/command/brigadier/VelocityArgumentCommandNodeTests.java @@ -21,6 +21,7 @@ import static com.velocitypowered.proxy.command.brigadier.VelocityArgumentBuilde import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -67,6 +68,7 @@ public class VelocityArgumentCommandNodeTests { assertTrue(this.contextBuilder.getArguments().containsKey("foo")); final ParsedArgument parsed = (ParsedArgument) this.contextBuilder.getArguments().get("foo"); + assertNotNull(parsed, "Argument foo is null!"); assertArrayEquals(new String[] { "hello", "world" }, parsed.getResult()); assertEquals(expectedRange, parsed.getRange()); }