Various minor cleanup

This commit is contained in:
Jason Penilla 2021-06-28 02:13:48 -07:00 committed by Jason
parent 0c5fec4187
commit f7b7b93251
12 changed files with 29 additions and 21 deletions

View file

@ -167,15 +167,15 @@ public class VelocityCommandManager<C> extends CommandManager<C> implements Brig
return ((VelocityPluginRegistrationHandler<C>) this.getCommandRegistrationHandler()).brigadierManager();
}
final @NonNull ProxyServer getProxyServer() {
final @NonNull ProxyServer proxyServer() {
return this.proxyServer;
}
final @NonNull Function<@NonNull CommandSource, @NonNull C> getCommandSenderMapper() {
final @NonNull Function<@NonNull CommandSource, @NonNull C> commandSenderMapper() {
return this.commandSenderMapper;
}
final @NonNull Function<@NonNull C, @NonNull CommandSource> getBackwardsCommandSenderMapper() {
final @NonNull Function<@NonNull C, @NonNull CommandSource> backwardsCommandSenderMapper() {
return this.backwardsCommandSenderMapper;
}

View file

@ -51,7 +51,7 @@ final class VelocityCommandPreprocessor<C> implements CommandPreprocessor<C> {
public void accept(final @NonNull CommandPreprocessingContext<C> context) {
context.getCommandContext().store(
VelocityContextKeys.PROXY_SERVER_KEY,
this.mgr.getProxyServer()
this.mgr.proxyServer()
);
}

View file

@ -59,7 +59,7 @@ final class VelocityExecutor<C> implements Command<CommandSource> {
public int run(final @NonNull CommandContext<CommandSource> commandContext) {
final CommandSource source = commandContext.getSource();
final String input = commandContext.getInput();
final C sender = this.manager.getCommandSenderMapper().apply(
final C sender = this.manager.commandSenderMapper().apply(
source);
this.manager.executeCommand(sender, input).whenComplete(this.getResultConsumer(source, sender));
return com.mojang.brigadier.Command.SINGLE_SUCCESS;

View file

@ -46,16 +46,16 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
this.brigadierManager = new CloudBrigadierManager<>(
velocityCommandManager,
() -> new CommandContext<>(
velocityCommandManager.getCommandSenderMapper()
.apply(velocityCommandManager.getProxyServer()
velocityCommandManager.commandSenderMapper()
.apply(velocityCommandManager.proxyServer()
.getConsoleCommandSource()),
velocityCommandManager
)
);
this.brigadierManager.brigadierSenderMapper(
sender -> this.manager.getCommandSenderMapper().apply(sender)
sender -> this.manager.commandSenderMapper().apply(sender)
);
this.brigadierManager.backwardsBrigadierSenderMapper(this.manager.getBackwardsCommandSenderMapper());
this.brigadierManager.backwardsBrigadierSenderMapper(this.manager.backwardsCommandSenderMapper());
}
@Override
@ -68,18 +68,18 @@ final class VelocityPluginRegistrationHandler<C> implements CommandRegistrationH
command.getArguments().get(0).getName(),
(Command<C>) command,
(c, p) -> this.manager.hasPermission(
this.manager.getCommandSenderMapper().apply(c),
this.manager.commandSenderMapper().apply(c),
p
),
true,
new VelocityExecutor<>(this.manager)
)
);
final CommandMeta commandMeta = this.manager.getProxyServer().getCommandManager()
final CommandMeta commandMeta = this.manager.proxyServer().getCommandManager()
.metaBuilder(brigadierCommand)
.aliases(aliases.toArray(new String[0])).build();
aliases.forEach(this.manager.getProxyServer().getCommandManager()::unregister);
this.manager.getProxyServer().getCommandManager().register(commandMeta, brigadierCommand);
aliases.forEach(this.manager.proxyServer().getCommandManager()::unregister);
this.manager.proxyServer().getCommandManager().register(commandMeta, brigadierCommand);
return true;
}