Add many comments to the example to help explain things

This commit is contained in:
Aikar
2017-10-11 20:47:10 -04:00
parent c165ca2c36
commit 8c49ecabcf
3 changed files with 56 additions and 3 deletions
@@ -39,6 +39,9 @@ public abstract class SomeObject {
return this.thisValue;
}
// Dynamically returns up to 3 different objects based on the users input.
// A command signature using SomeObject doesn't care about all this logic, its defined once
// And it knows it will receive SomeObject
public static ContextResolver<SomeObject, BukkitCommandExecutionContext> getContextResolver() {
return (c) -> {
String first = c.popFirstArg();
@@ -50,6 +53,7 @@ public abstract class SomeObject {
try {
return new TestOther(Integer.parseInt(first));
} catch (NumberFormatException ignored) {
// User didn't type a number, show error!
throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER);
}
}