đī¸ Source parser
Table of content:
Source parser are simple way to create parser
What is source parser
Source parser are above function that return Map of String as key and Object as value obj could be anything You can just return instead of Object an enum value Map<String, GameMode>
Source parser are just an simple way to create key value peer parser
Also source parser have 4 arguments 2 of them are most have
* is for must have argument
keyword* The Keyword that triggers the parserpriority(default 0) Parser priorityclazz* The return type of the parserresultMaxAgeInMills(default 0) The max age of the result in millisecondsignoreCase(default false) If it will check if it equalIgnore case instead just equallax(default false) Whether or not it lazy mapping(Lazy mapping will try to auto complete your label)
More about priority
If we have multiple parser not with the same keyword but for our example IntParser & StringParser We will want IntParser to try to parse first so his priority will be higher then StringParser
More about resultMaxAgeInMills
When the result is older it will be discarded the next time someone use the parser And if you set it to 0 it will always be discarded But if you want the result to never be discarded for example enum class You just set it to -1
More about lax
Lax is Lazy mapping but what is Lazy mapping?
Lazy mapping will try to autofill your command for example if you type
And lax is on it will complete it to
If there is a collision like
It could be both survival & specator So in that case it would ignore it and throw an exception it could be handle with @ExceptionHandle
Usage
Where should you use Source parser
Source parser should be used when you key value peer as
list of player
list of materials
etc