Skip to content

cloud-velocity#

cloud-velocity allows you to write commands for Velocity.

Installation#

Cloud for Velocity is available through Maven Central.

<dependencies>
    <dependency>
        <groupId>org.incendo</groupId>
        <artifactId>cloud-velocity</artifactId>
        <version>2.0.0-beta.2</version>
    </dependency>
</dependencies>
implementation("org.incendo:cloud-velocity:2.0.0-beta.2")
implementation 'org.incendo:cloud-velocity:2.0.0-beta.2'

Usage#

cloud-velocity has a command manager implementation called VelocityCommandManager that can be created in two ways.

By using a Guice injector:

// @Inject private Injector injector;
Injector childInjector = injector.createChildInjector(
  new CloudInjectionModule<>(
    YourSenderType.class,
    executionCoordinator, /* 1 */
    senderMapper /* 2 */
  )
);

VelocityCommandManager<YourSenderType> commandManager = childInjector.getInstance(
  Key.get(new TypeLiteral<VelocityCommandManager<YourSenderType>>() {})
);

Or, manually creating an instance:

VelocityCommandManager<YourSenderType> commandManager = new VelocityCommandManager<>(
  pluginContainer,
  proxyServer,
  executionCoordinator, /* 1 */
  senderMapper /* 2 */
);
  1. Information about execution coordinators in general can be found here.
  2. The sender mapper is a two-way mapping between Velocity’s CommandSource and your custom sender type. You may use SenderMapper.identity() if using CommandSource as the sender type.

Brigadier#

Velocity commands are powered by Brigadier, which means that you may use the features from cloud-brigadier.

Parsers#

Parser Type
PlayerParser Player
ServerParser RegisteredServer

Localization#

cloud-velocity provides additional caption keys for the localization system. These can be found in VelocityCaptionKeys. The default caption values can be found in VelocityCommandManager.