forked from MeteorDevelopment/meteor-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandExample.java
More file actions
32 lines (28 loc) · 1.09 KB
/
CommandExample.java
File metadata and controls
32 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.example.addon.commands;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
import net.minecraft.client.multiplayer.ClientSuggestionProvider;
/**
* The Meteor Client command API uses the <a href="https://github.com/Mojang/brigadier">same command system as Minecraft does</a>.
*/
public class CommandExample extends Command {
/**
* The {@code name} parameter should be in kebab-case.
*/
public CommandExample() {
super("example", "Sends a message.");
}
@Override
public void build(LiteralArgumentBuilder<ClientSuggestionProvider> builder) {
builder.executes(_ -> {
info("hi");
return SINGLE_SUCCESS;
});
builder.then(literal("name").then(argument("nameArgument", StringArgumentType.word()).executes(context -> {
String argument = StringArgumentType.getString(context, "nameArgument");
info("hi, " + argument);
return SINGLE_SUCCESS;
})));
}
}