bukkit/paper/velocity: Add convenience methods for constructing command managers using native platform sender types
This commit is contained in:
parent
5d460e9f3a
commit
0722bf6ead
3 changed files with 71 additions and 3 deletions
|
|
@ -33,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* Injection module that allows for {@link VelocityCommandManager} to be injectable
|
||||
|
|
@ -67,6 +68,25 @@ public final class CloudInjectionModule<C> extends AbstractModule {
|
|||
this.backwardsCommandSenderMapper = backwardsCommandSenderMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new child injection module using Velocity's {@link CommandSource} as the sender type.
|
||||
*
|
||||
* @param commandExecutionCoordinator Command execution coordinator
|
||||
* @return new injection module
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static @NonNull CloudInjectionModule<@NonNull CommandSource> createNative(
|
||||
final @NonNull Function<@NonNull CommandTree<@NonNull CommandSource>,
|
||||
@NonNull CommandExecutionCoordinator<@NonNull CommandSource>> commandExecutionCoordinator
|
||||
) {
|
||||
return new CloudInjectionModule<>(
|
||||
CommandSource.class,
|
||||
commandExecutionCoordinator,
|
||||
UnaryOperator.identity(),
|
||||
UnaryOperator.identity()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected void configure() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue