@ -56,52 +56,63 @@ Using Maven/something else? There's instructions on how to include Uniform on [t
## Basic use
## Basic use
Uniform lets you create commands either natively per-platform, or cross-platform (by compiling against `uniform-common` in a common module, then implementing `uniform-PLATFORM` in each platform, getting the platform specific Uniform manager instance and registering your commands).
Uniform lets you create commands either natively per-platform, or cross-platform (by compiling against `uniform-common` in a common module, then implementing `uniform-PLATFORM` in each platform, getting the platform specific Uniform manager instance and registering your commands).
Check `example-plugin` for a full example of a cross-platform command being registered on Paper.
### Platform-specific commands
### Platform-specific commands
Extend the platform-specific `PlatformCommand` class and add your Brigadier syntax.
Extend the platform-specific `PlatformCommand` class and add your Brigadier syntax.
```java
```java
public class ExampleCommand extends PaperCommand {
public class ExampleCommand extends PaperCommand {
Target `uniform-common` and implement the `Command` class.
Target `uniform-common` and extend the `Command` class. You'll want to use `BaseCommand#getUser` to get a platform-agnostic User from which you can acquire the adventure `Audience` to send messages to.
```java
```java
public class ExampleCrossPlatCommand implements Command {
import java.awt.*;
@Override
public class ExampleCrossPlatCommand extends Command {
@NotNull
public ExampleCrossPlatCommand() {
public String getNamespace() {
super("example", "cross-platform");
return "example";
}
@Override
@NotNull
public List<String> getAliases() {
return List.of("cross-plat");
}
}
@Override
@Override
public <S> void provide(@NotNull BaseCommand<S> command) {
public <S> void provide(@NotNull BaseCommand<S> command) {
command.setCondition(source -> true);
// What gets executed when no args are passed. For tidiness, feel free to delegate this stuff to methods!
command.setDefaultExecutor((ctx) -> {
command.setDefaultExecutor((context) -> {
// Use command.getUser(ctx.getSource()) to get the user
// Use command.getUser(context.getSource()) to get the user
final Audience user = command.getUser(ctx.getSource()).getAudience();
final Audience user = command.getUser(context.getSource()).getAudience();