Skip to content

Instantly share code, notes, and snippets.

@killjoy1221
Created October 3, 2018 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killjoy1221/85d364625415d7cc715c1408271cc65e to your computer and use it in GitHub Desktop.
Save killjoy1221/85d364625415d7cc715c1408271cc65e to your computer and use it in GitHub Desktop.
public interface CommandArg<T> {
Text getName();
TypeToken<T> getType();
}
public interface CommandArgs {
<T> T getOne(CommandArg<T> arg) throws NoSuchElementException;
<T> Optional<T> getOne(Text arg);
}
CommandArg<Text> name = text(Text.of("name"));
CommandArg<Optional<Text>> desc = optional(text(Text.of("desc")));
public void onCmd(CommandSource src, CommandArgs args) {
Text name = args.getOne(this.name);
Optional<Text> desc = args.getOne(this.desc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment