mirror of https://github.com/Minestom/Minestom.git
Little cleanup
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
0abcc9f010
commit
1626cd461d
|
@ -1,12 +1,12 @@
|
|||
package net.minestom.server.command;
|
||||
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class CommandManagerTest {
|
||||
|
||||
|
@ -44,16 +44,4 @@ public class CommandManagerTest {
|
|||
manager.executeServerCommand("invalid_command");
|
||||
assertTrue(check.get());
|
||||
}
|
||||
|
||||
private static void assertNodeEquals(DeclareCommandsPacket.Node node, byte flags, int[] children, int redirectedNode,
|
||||
String name, String parser, byte[] properties, String suggestionsType) {
|
||||
assertEquals(flags, node.flags);
|
||||
assertArrayEquals(children, node.children);
|
||||
assertEquals(redirectedNode, node.redirectedNode);
|
||||
assertEquals(name, node.name);
|
||||
assertEquals(parser, node.parser);
|
||||
assertArrayEquals(properties, node.properties);
|
||||
assertEquals(suggestionsType, node.suggestionsType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CommandTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConflictingSyntaxAndSubcommand() {
|
||||
public void conflictSubcommandString() {
|
||||
final CommandManager manager = new CommandManager();
|
||||
|
||||
final AtomicBoolean subcommandRun = new AtomicBoolean();
|
||||
|
@ -76,4 +76,31 @@ public class CommandTest {
|
|||
assertTrue(subcommandRun.get());
|
||||
assertFalse(syntaxRun.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conflictLiteralString() {
|
||||
final CommandManager manager = new CommandManager();
|
||||
|
||||
final AtomicBoolean literalBool = new AtomicBoolean();
|
||||
final AtomicBoolean stringBool = new AtomicBoolean();
|
||||
|
||||
final Command command = new Command("command");
|
||||
var literal = ArgumentType.Literal("literal");
|
||||
var string = ArgumentType.String("id");
|
||||
command.addSyntax((sender, ctx) -> stringBool.set(true), string);
|
||||
command.addSyntax((sender, ctx) -> literalBool.set(true), literal);
|
||||
|
||||
manager.register(command);
|
||||
|
||||
manager.executeServerCommand("command literal");
|
||||
assertTrue(literalBool.get());
|
||||
assertFalse(stringBool.get());
|
||||
|
||||
literalBool.set(false);
|
||||
stringBool.set(false);
|
||||
|
||||
manager.executeServerCommand("command string");
|
||||
assertFalse(literalBool.get());
|
||||
assertTrue(stringBool.get());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue