Created
October 3, 2018 23:46
-
-
Save killjoy1221/85d364625415d7cc715c1408271cc65e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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