Added static methods to create ArgumentBuilders directly in the BrigadierCommand class (#1161)
This commit is contained in:
@@ -20,11 +20,13 @@ package com.velocitypowered.proxy.command;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.word;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.velocitypowered.api.command.BrigadierCommand;
|
||||
@@ -349,4 +351,14 @@ public class BrigadierCommandTests extends CommandTestSuite {
|
||||
assertThrows(CompletionException.class, () ->
|
||||
manager.offerSuggestions(source, "parent ").join());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArgumentBuilderCreationUsingStaticFactory() {
|
||||
assertDoesNotThrow(() -> BrigadierCommand.literalArgumentBuilder("someCommand"));
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> BrigadierCommand.literalArgumentBuilder("some random command"));
|
||||
assertDoesNotThrow(
|
||||
() -> BrigadierCommand.requiredArgumentBuilder(
|
||||
"someRequiredArgument", StringArgumentType.word()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user