示例#1
0
  @Test
  public void testFilter() {
    CommandManager cm = new CommandManager();
    CommandSource source = new TestCommandSource(cm);
    cm.getCommand("test3")
        .addFilter(new PlayerFilter())
        .setExecutor(
            new Executor() {
              @Override
              public void execute(CommandSource source, Command command, CommandArguments args)
                  throws CommandException {}
            });

    thrown.expectCause(isA(CommandException.class));
    thrown.expectMessage("You must be a Player to execute this command");
    source.processCommand("test3");
  }
示例#2
0
  @Test
  public void testChildren() {
    CommandManager cm = new CommandManager();
    CommandSource testSource = new TestCommandSource(cm);
    cm.getCommand("test2")
        .getChild("foo")
        .getChild("bar")
        .getChild("baz")
        .setExecutor(
            new Executor() {
              @Override
              public void execute(CommandSource source, Command command, CommandArguments args)
                  throws CommandException {
                assertEquals("baz", command.getName());
                assertEquals("hello", args.popString("testStr"));
              }
            });

    testSource.processCommand("test2", "foo", "bar", "baz", "hello");
  }