brigadier icon indicating copy to clipboard operation
brigadier copied to clipboard

term type argument as a subclass from string type argument

Open gnembon opened this issue 7 years ago • 1 comments

Another option for term-like string argument, as a subclass of StringArgumentType. Reasoning - code is much cleaner, yet still one would retrieve its value via getString as it is technically nothing but a string from a predefined collection, and I don't think making it a totally separate class from StringArgumentType makes sense as the returned value is a string and that object type you would expect. The fact that it is a subclass makes it clear in my opinion of a getter method as getString.

Please send feedback regarding this implementation.

In case the choice of the word 'term' to describe it is not clear, I shall direct to the following definition https://en.wikipedia.org/wiki/Terminology

SYNOPSIS (and why this type is very useful):

        dispatcher.register(literal("test").
                then(argument("first", term("foo","bar")).
                        executes( (c)-> test(c, getString(c, "first")+" 1"))).
                then(argument("second", term("baz","quux")).
                        executes( (c)-> test(c, getString(c, "second")+" 2"))));

gnembon avatar Oct 10 '18 04:10 gnembon

Closing and reopening to rerun checks.

peterix avatar Oct 26 '22 15:10 peterix