Skip to content

Commit

Permalink
fix(core): allow command beans to use senderType
Browse files Browse the repository at this point in the history
Fixes #653
  • Loading branch information
Citymonstret committed Jan 22, 2024
1 parent 38270f8 commit 847cb91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected CommandBean() {
* @param builder the command builder
* @return the updated builder
*/
protected abstract Command.@NonNull Builder<C> configure(Command.@NonNull Builder<C> builder);
protected abstract Command.@NonNull Builder<? extends C> configure(Command.@NonNull Builder<C> builder);

/**
* Default command handler for this command bean. Does nothing unless override.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void testCommandBeanRegistration() {
assertThat(command.commandExecutionHandler()).isEqualTo(testCommandBean);
}

public static class TestCommandBean extends CommandBean<TestCommandSender> {

public static final class TestCommandBean extends CommandBean<TestCommandSender> {

@Override
protected @NonNull CommandProperties properties() {
Expand All @@ -80,8 +81,16 @@ public static class TestCommandBean extends CommandBean<TestCommandSender> {
}

@Override
protected Command.@NonNull Builder<TestCommandSender> configure(final Command.@NonNull Builder<TestCommandSender> builder) {
return builder.required("argument", IntegerParser.integerParser());
protected Command.@NonNull Builder<? extends TestCommandSender> configure(
final Command.@NonNull Builder<TestCommandSender> builder
) {
return builder.senderType(ChildTestCommandSender.class)
.required("argument", IntegerParser.integerParser());
}
}


public static final class ChildTestCommandSender extends TestCommandSender {

}
}

0 comments on commit 847cb91

Please sign in to comment.