001/*
002 * This file is part of Baritone.
003 *
004 * Baritone is free software: you can redistribute it and/or modify
005 * it under the terms of the GNU Lesser General Public License as published by
006 * the Free Software Foundation, either version 3 of the License, or
007 * (at your option) any later version.
008 *
009 * Baritone is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU Lesser General Public License for more details.
013 *
014 * You should have received a copy of the GNU Lesser General Public License
015 * along with Baritone.  If not, see <https://www.gnu.org/licenses/>.
016 */
017
018package baritone.api.command.argument;
019
020import baritone.api.command.ICommand;
021import baritone.api.command.argparser.IArgParser;
022import baritone.api.command.datatypes.IDatatype;
023import baritone.api.command.datatypes.IDatatypeFor;
024import baritone.api.command.datatypes.IDatatypePost;
025import baritone.api.command.exception.CommandException;
026import baritone.api.command.exception.CommandInvalidTypeException;
027import baritone.api.command.exception.CommandNotEnoughArgumentsException;
028import baritone.api.command.exception.CommandTooManyArgumentsException;
029import baritone.api.utils.Helper;
030import net.minecraft.util.EnumFacing;
031
032import java.util.Deque;
033import java.util.LinkedList;
034import java.util.stream.Stream;
035
036/**
037 * The {@link IArgConsumer} is how {@link ICommand}s read the arguments passed to them. This class has many benefits:
038 *
039 * <ul>
040 * <li>Mutability. The whole concept of the {@link IArgConsumer}} is to let you gradually consume arguments in any way
041 * you'd like. You can change your consumption based on earlier arguments, for subcommands for example.</li>
042 * <li>You don't need to keep track of your consumption. The {@link IArgConsumer}} keeps track of the arguments you
043 * consume so that it can throw detailed exceptions whenever something is out of the ordinary. Additionally, if you
044 * need to retrieve an argument after you've already consumed it - look no further than {@link #consumed()}!</li>
045 * <li>Easy retrieval of many different types. If you need to retrieve an instance of an int or float for example,
046 * look no further than {@link #getAs(Class)}. If you need a more powerful way of retrieving data, try out the many
047 * {@code getDatatype...} methods.</li>
048 * <li>It's very easy to throw detailed exceptions. The {@link IArgConsumer}} has many different methods that can
049 * enforce the number of arguments, the type of arguments, and more, throwing different types of
050 * {@link CommandException}s if something seems off. You're recommended to do all validation and store all needed
051 * data in variables BEFORE logging any data to chat via {@link Helper#logDirect(String)}, so that the error
052 * handlers can do their job and log the error to chat.</li>
053 * </ul>
054 */
055public interface IArgConsumer {
056
057    LinkedList<ICommandArgument> getArgs();
058
059    Deque<ICommandArgument> getConsumed();
060
061    /**
062     * @param num The number of arguments to check for
063     * @return {@code true} if there are <i>at least</i> {@code num} arguments left in this {@link IArgConsumer}}
064     * @see #hasAny()
065     * @see #hasAtMost(int)
066     * @see #hasExactly(int)
067     */
068    boolean has(int num);
069
070    /**
071     * @return {@code true} if there is <i>at least</i> 1 argument left in this {@link IArgConsumer}}
072     * @see #has(int)
073     * @see #hasAtMostOne()
074     * @see #hasExactlyOne()
075     */
076    boolean hasAny();
077
078    /**
079     * @param num The number of arguments to check for
080     * @return {@code true} if there are <i>at most</i> {@code num} arguments left in this {@link IArgConsumer}}
081     * @see #has(int)
082     * @see #hasAtMost(int)
083     * @see #hasExactly(int)
084     */
085    boolean hasAtMost(int num);
086
087    /**
088     * @return {@code true} if there is <i>at most</i> 1 argument left in this {@link IArgConsumer}}
089     * @see #hasAny()
090     * @see #hasAtMostOne()
091     * @see #hasExactlyOne()
092     */
093    boolean hasAtMostOne();
094
095    /**
096     * @param num The number of arguments to check for
097     * @return {@code true} if there are <i>exactly</i> {@code num} arguments left in this {@link IArgConsumer}}
098     * @see #has(int)
099     * @see #hasAtMost(int)
100     */
101    boolean hasExactly(int num);
102
103    /**
104     * @return {@code true} if there is <i>exactly</i> 1 argument left in this {@link IArgConsumer}}
105     * @see #hasAny()
106     * @see #hasAtMostOne()
107     */
108    boolean hasExactlyOne();
109
110    /**
111     * @param index The index to peek
112     * @return The argument at index {@code index} in this {@link IArgConsumer}}, with 0 being the next one. This does not
113     * mutate the {@link IArgConsumer}}
114     * @throws CommandNotEnoughArgumentsException If there is less than {@code index + 1} arguments left
115     * @see #peek()
116     * @see #peekString(int)
117     * @see #peekAs(Class, int)
118     * @see #get()
119     */
120    ICommandArgument peek(int index) throws CommandNotEnoughArgumentsException;
121
122    /**
123     * @return The next argument in this {@link IArgConsumer}}. This does not mutate the {@link IArgConsumer}}
124     * @throws CommandNotEnoughArgumentsException If there is less than one argument left
125     * @see #peek(int)
126     * @see #peekString()
127     * @see #peekAs(Class)
128     * @see #get()
129     */
130    ICommandArgument peek() throws CommandNotEnoughArgumentsException;
131
132    /**
133     * @param index The index to peek
134     * @param type  The type to check for
135     * @return If an ArgParser.Stateless for the specified {@code type} would succeed in parsing the next
136     * argument
137     * @throws CommandNotEnoughArgumentsException If there is less than {@code index + 1} arguments left
138     * @see #peek()
139     * @see #getAs(Class)
140     */
141    boolean is(Class<?> type, int index) throws CommandNotEnoughArgumentsException;
142
143    /**
144     * @param type The type to check for
145     * @return If an ArgParser.Stateless for the specified {@code type} would succeed in parsing the next
146     * argument
147     * @throws CommandNotEnoughArgumentsException If there is less than one argument left
148     * @see #peek()
149     * @see #getAs(Class)
150     */
151    boolean is(Class<?> type) throws CommandNotEnoughArgumentsException;
152
153    /**
154     * @param index The index to peek
155     * @return The value of the argument at index {@code index} in this {@link IArgConsumer}}, with 0 being the next one
156     * This does not mutate the {@link IArgConsumer}}
157     * @throws CommandNotEnoughArgumentsException If there is less than {@code index + 1} arguments left
158     * @see #peek()
159     * @see #peekString()
160     */
161    String peekString(int index) throws CommandNotEnoughArgumentsException;
162
163    /**
164     * @return The value of the next argument in this {@link IArgConsumer}}. This does not mutate the {@link IArgConsumer}}
165     * @throws CommandNotEnoughArgumentsException If there is less than one argument left
166     * @see #peekString(int)
167     * @see #getString()
168     */
169    String peekString() throws CommandNotEnoughArgumentsException;
170
171    /**
172     * @param index     The index to peek
173     * @param enumClass The class to search
174     * @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
175     * next argument's value
176     * @throws java.util.NoSuchElementException If the constant couldn't be found
177     * @see #peekEnumOrNull(Class)
178     * @see #getEnum(Class)
179     * @see ICommandArgument#getEnum(Class)
180     */
181    <E extends Enum<?>> E peekEnum(Class<E> enumClass, int index) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
182
183    /**
184     * @param enumClass The class to search
185     * @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
186     * next argument's value
187     * @throws CommandInvalidTypeException If the constant couldn't be found
188     * @see #peekEnumOrNull(Class)
189     * @see #getEnum(Class)
190     * @see ICommandArgument#getEnum(Class)
191     */
192    <E extends Enum<?>> E peekEnum(Class<E> enumClass) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
193
194    /**
195     * @param index     The index to peek
196     * @param enumClass The class to search
197     * @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
198     * next argument's value. If no constant could be found, null
199     * @see #peekEnum(Class)
200     * @see #getEnumOrNull(Class)
201     * @see ICommandArgument#getEnum(Class)
202     */
203    <E extends Enum<?>> E peekEnumOrNull(Class<E> enumClass, int index) throws CommandNotEnoughArgumentsException;
204
205    /**
206     * @param enumClass The class to search
207     * @return From the specified enum class, an enum constant of that class. The enum constant's name will match the
208     * next argument's value. If no constant could be found, null
209     * @see #peekEnum(Class)
210     * @see #getEnumOrNull(Class)
211     * @see ICommandArgument#getEnum(Class)
212     */
213    <E extends Enum<?>> E peekEnumOrNull(Class<E> enumClass) throws CommandNotEnoughArgumentsException;
214
215    /**
216     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the argument at the specified index into the specified
217     * class
218     * <p>
219     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
220     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
221     * {@link IArgConsumer}}.
222     *
223     * @param type  The type to peek as
224     * @param index The index to peek
225     * @return An instance of the specified type
226     * @throws CommandInvalidTypeException If the parsing failed
227     * @see IArgParser
228     * @see #peekAs(Class)
229     * @see #peekAsOrDefault(Class, Object, int)
230     * @see #peekAsOrNull(Class, int)
231     */
232    <T> T peekAs(Class<T> type, int index) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
233
234    /**
235     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
236     * <p>
237     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
238     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
239     * {@link IArgConsumer}}.
240     *
241     * @param type The type to peek as
242     * @return An instance of the specified type
243     * @throws CommandInvalidTypeException If the parsing failed
244     * @see IArgParser
245     * @see #peekAs(Class, int)
246     * @see #peekAsOrDefault(Class, Object)
247     * @see #peekAsOrNull(Class)
248     */
249    <T> T peekAs(Class<T> type) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
250
251    /**
252     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the argument at the specified index into the specified
253     * class
254     * <p>
255     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
256     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
257     * {@link IArgConsumer}}.
258     *
259     * @param type  The type to peek as
260     * @param def   The value to return if the argument can't be parsed
261     * @param index The index to peek
262     * @return An instance of the specified type, or {@code def} if it couldn't be parsed
263     * @see IArgParser
264     * @see #peekAsOrDefault(Class, Object)
265     * @see #peekAs(Class, int)
266     * @see #peekAsOrNull(Class, int)
267     */
268    <T> T peekAsOrDefault(Class<T> type, T def, int index) throws CommandNotEnoughArgumentsException;
269
270    /**
271     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
272     * <p>
273     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
274     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
275     * {@link IArgConsumer}}.
276     *
277     * @param type The type to peek as
278     * @param def  The value to return if the argument can't be parsed
279     * @return An instance of the specified type, or {@code def} if it couldn't be parsed
280     * @see IArgParser
281     * @see #peekAsOrDefault(Class, Object, int)
282     * @see #peekAs(Class)
283     * @see #peekAsOrNull(Class)
284     */
285    <T> T peekAsOrDefault(Class<T> type, T def) throws CommandNotEnoughArgumentsException;
286
287    /**
288     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the argument at the specified index into the specified
289     * class
290     * <p>
291     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
292     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
293     * {@link IArgConsumer}}.
294     *
295     * @param type  The type to peek as
296     * @param index The index to peek
297     * @return An instance of the specified type, or {@code null} if it couldn't be parsed
298     * @see IArgParser
299     * @see #peekAsOrNull(Class)
300     * @see #peekAs(Class, int)
301     * @see #peekAsOrDefault(Class, Object, int)
302     */
303    <T> T peekAsOrNull(Class<T> type, int index) throws CommandNotEnoughArgumentsException;
304
305    /**
306     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
307     * <p>
308     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
309     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
310     * {@link IArgConsumer}}.
311     *
312     * @param type The type to peek as
313     * @return An instance of the specified type, or {@code null} if it couldn't be parsed
314     * @see IArgParser
315     * @see #peekAsOrNull(Class, int)
316     * @see #peekAs(Class)
317     * @see #peekAsOrDefault(Class, Object)
318     */
319    <T> T peekAsOrNull(Class<T> type) throws CommandNotEnoughArgumentsException;
320
321    <T> T peekDatatype(IDatatypeFor<T> datatype) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
322
323    <T, O> T peekDatatype(IDatatypePost<T, O> datatype) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
324
325    <T, O> T peekDatatype(IDatatypePost<T, O> datatype, O original) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
326
327    <T> T peekDatatypeOrNull(IDatatypeFor<T> datatype);
328
329    <T, O> T peekDatatypeOrNull(IDatatypePost<T, O> datatype);
330
331    <T, O, D extends IDatatypePost<T, O>> T peekDatatypePost(D datatype, O original) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
332
333    <T, O, D extends IDatatypePost<T, O>> T peekDatatypePostOrDefault(D datatype, O original, T def);
334
335    <T, O, D extends IDatatypePost<T, O>> T peekDatatypePostOrNull(D datatype, O original);
336
337    /**
338     * Attempts to get the specified {@link IDatatypeFor} from this ArgConsumer
339     * <p>
340     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
341     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
342     * {@link IArgConsumer}}.
343     * <p>
344     * Since this is a peek operation, this ArgConsumer will not be mutated by any call to this method.
345     *
346     * @param datatype The datatype to get
347     * @return The datatype instance
348     * @see IDatatype
349     * @see IDatatypeFor
350     */
351    <T, D extends IDatatypeFor<T>> T peekDatatypeFor(Class<D> datatype);
352
353    /**
354     * Attempts to get the specified {@link IDatatypeFor} from this ArgConsumer
355     * <p>
356     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
357     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
358     * {@link IArgConsumer}}.
359     * <p>
360     * Since this is a peek operation, this ArgConsumer will not be mutated by any call to this method.
361     *
362     * @param datatype The datatype to get
363     * @param def      The default value
364     * @return The datatype instance, or {@code def} if it throws an exception
365     * @see IDatatype
366     * @see IDatatypeFor
367     */
368    <T, D extends IDatatypeFor<T>> T peekDatatypeForOrDefault(Class<D> datatype, T def);
369
370    /**
371     * Attempts to get the specified {@link IDatatypeFor} from this ArgConsumer
372     * <p>
373     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
374     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
375     * {@link IArgConsumer}}.
376     * <p>
377     * Since this is a peek operation, this ArgConsumer will not be mutated by any call to this method.
378     *
379     * @param datatype The datatype to get
380     * @return The datatype instance, or {@code null} if it throws an exception
381     * @see IDatatype
382     * @see IDatatypeFor
383     */
384    <T, D extends IDatatypeFor<T>> T peekDatatypeForOrNull(Class<D> datatype);
385
386    /**
387     * Gets the next argument and returns it. This consumes the first argument so that subsequent calls will return
388     * later arguments
389     *
390     * @return The next argument
391     * @throws CommandNotEnoughArgumentsException If there's less than one argument left
392     */
393    ICommandArgument get() throws CommandNotEnoughArgumentsException;
394
395    /**
396     * Gets the value of the next argument and returns it. This consumes the first argument so that subsequent calls
397     * will return later arguments
398     *
399     * @return The value of the next argument
400     * @throws CommandNotEnoughArgumentsException If there's less than one argument left
401     */
402    String getString() throws CommandNotEnoughArgumentsException;
403
404    /**
405     * Gets an enum value from the enum class with the same name as the next argument's value
406     * <p>
407     * For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
408     * {@link EnumFacing#UP}
409     *
410     * @param enumClass The enum class to search
411     * @return An enum constant of that class with the same name as the next argument's value
412     * @throws CommandInvalidTypeException If the constant couldn't be found
413     * @see #peekEnum(Class)
414     * @see #getEnumOrNull(Class)
415     * @see ICommandArgument#getEnum(Class)
416     */
417    <E extends Enum<?>> E getEnum(Class<E> enumClass) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
418
419    /**
420     * Gets an enum value from the enum class with the same name as the next argument's value
421     * <p>
422     * For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
423     * {@link EnumFacing#UP}
424     *
425     * @param enumClass The enum class to search
426     * @param def       The default value
427     * @return An enum constant of that class with the same name as the next argument's value, or {@code def} if it
428     * couldn't be found
429     * @see #getEnum(Class)
430     * @see #getEnumOrNull(Class)
431     * @see #peekEnumOrNull(Class)
432     * @see ICommandArgument#getEnum(Class)
433     */
434    <E extends Enum<?>> E getEnumOrDefault(Class<E> enumClass, E def) throws CommandNotEnoughArgumentsException;
435
436    /**
437     * Gets an enum value from the enum class with the same name as the next argument's value
438     * <p>
439     * For example if you getEnum as an {@link EnumFacing}, and the next argument's value is "up", this will return
440     * {@link EnumFacing#UP}
441     *
442     * @param enumClass The enum class to search
443     * @return An enum constant of that class with the same name as the next argument's value, or {@code null} if it
444     * couldn't be found
445     * @see #getEnum(Class)
446     * @see #getEnumOrDefault(Class, Enum)
447     * @see #peekEnumOrNull(Class)
448     * @see ICommandArgument#getEnum(Class)
449     */
450    <E extends Enum<?>> E getEnumOrNull(Class<E> enumClass) throws CommandNotEnoughArgumentsException;
451
452    /**
453     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
454     * <p>
455     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
456     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
457     * {@link IArgConsumer}}.
458     *
459     * @param type The type to peek as
460     * @return An instance of the specified type
461     * @throws CommandInvalidTypeException If the parsing failed
462     * @see IArgParser
463     * @see #get()
464     * @see #getAsOrDefault(Class, Object)
465     * @see #getAsOrNull(Class)
466     * @see #peekAs(Class)
467     * @see #peekAsOrDefault(Class, Object, int)
468     * @see #peekAsOrNull(Class, int)
469     */
470    <T> T getAs(Class<T> type) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
471
472    /**
473     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
474     * <p>
475     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
476     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
477     * {@link IArgConsumer}}.
478     *
479     * @param type The type to peek as
480     * @param def  The default value
481     * @return An instance of the specified type, or {@code def} if it couldn't be parsed
482     * @see IArgParser
483     * @see #get()
484     * @see #getAs(Class)
485     * @see #getAsOrNull(Class)
486     * @see #peekAs(Class)
487     * @see #peekAsOrDefault(Class, Object, int)
488     * @see #peekAsOrNull(Class, int)
489     */
490    <T> T getAsOrDefault(Class<T> type, T def) throws CommandNotEnoughArgumentsException;
491
492    /**
493     * Tries to use a <b>stateless</b> {@link IArgParser} to parse the next argument into the specified class
494     * <p>
495     * A critical difference between {@link IDatatype}s and {@link IArgParser}s is how many arguments they can take.
496     * While {@link IArgParser}s always operate on a single argument's value, {@link IDatatype}s get access to the entire
497     * {@link IArgConsumer}}.
498     *
499     * @param type The type to peek as
500     * @return An instance of the specified type, or {@code null} if it couldn't be parsed
501     * @see IArgParser
502     * @see #get()
503     * @see #getAs(Class)
504     * @see #getAsOrDefault(Class, Object)
505     * @see #peekAs(Class)
506     * @see #peekAsOrDefault(Class, Object, int)
507     * @see #peekAsOrNull(Class, int)
508     */
509    <T> T getAsOrNull(Class<T> type) throws CommandNotEnoughArgumentsException;
510
511    <T, O, D extends IDatatypePost<T, O>> T getDatatypePost(D datatype, O original) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
512
513    <T, O, D extends IDatatypePost<T, O>> T getDatatypePostOrDefault(D datatype, O original, T _default);
514
515    <T, O, D extends IDatatypePost<T, O>> T getDatatypePostOrNull(D datatype, O original);
516
517    <T, D extends IDatatypeFor<T>> T getDatatypeFor(D datatype) throws CommandInvalidTypeException, CommandNotEnoughArgumentsException;
518
519    <T, D extends IDatatypeFor<T>> T getDatatypeForOrDefault(D datatype, T def);
520
521    <T, D extends IDatatypeFor<T>> T getDatatypeForOrNull(D datatype);
522
523    <T extends IDatatype> Stream<String> tabCompleteDatatype(T datatype);
524
525    /**
526     * Returns the "raw rest" of the string. For example, from a string <code>arg1 arg2&nbsp;&nbsp;arg3</code>, split
527     * into three {@link ICommandArgument}s {@code "arg1"}, {@code "arg2"}, and {@code "arg3"}:
528     *
529     * <ul>
530     * <li>{@code rawRest()} would return <code>arg1 arg2&nbsp;&nbsp;arg3</code></li>
531     * <li>After calling {@link #get()}, {@code rawRest()} would return <code>arg2&nbsp;&nbsp;arg3</code> (note the
532     * double space - it is preserved!)</li>
533     * <li>After calling {@link #get()} again, {@code rawRest()} would return {@code "arg3"}</li>
534     * <li>After calling {@link #get()} one last time, {@code rawRest()} would return {@code ""}</li>
535     * </ul>
536     *
537     * @return The "raw rest" of the string.
538     */
539    String rawRest();
540
541    /**
542     * @param min The minimum amount of arguments to require.
543     * @throws CommandNotEnoughArgumentsException If there are less than {@code min} arguments left.
544     * @see #requireMax(int)
545     * @see #requireExactly(int)
546     */
547    void requireMin(int min) throws CommandNotEnoughArgumentsException;
548
549    /**
550     * @param max The maximum amount of arguments allowed.
551     * @throws CommandTooManyArgumentsException If there are more than {@code max} arguments left.
552     * @see #requireMin(int)
553     * @see #requireExactly(int)
554     */
555    void requireMax(int max) throws CommandTooManyArgumentsException;
556
557    /**
558     * @param args The exact amount of arguments to require.
559     * @throws CommandNotEnoughArgumentsException If there are less than {@code args} arguments left.
560     * @throws CommandTooManyArgumentsException   If there are more than {@code args} arguments left.
561     * @see #requireMin(int)
562     * @see #requireMax(int)
563     */
564    void requireExactly(int args) throws CommandException;
565
566    /**
567     * @return If this {@link IArgConsumer}} has consumed at least one argument.
568     * @see #consumed()
569     * @see #consumedString()
570     */
571    boolean hasConsumed();
572
573    /**
574     * @return The last argument this {@link IArgConsumer}} has consumed, or an "unknown" argument, indicated by a
575     * comamnd argument index that has a value of {@code -1}, if no arguments have been consumed yet.
576     * @see #consumedString()
577     * @see #hasConsumed()
578     */
579    ICommandArgument consumed();
580
581    /**
582     * @return The value of thelast argument this {@link IArgConsumer}} has consumed, or an empty string if no arguments
583     * have been consumed yet
584     * @see #consumed()
585     * @see #hasConsumed()
586     */
587    String consumedString();
588
589    /**
590     * @return A copy of this {@link IArgConsumer}}. It has the same arguments (both consumed and not), but does not
591     * affect or mutate this instance. Useful for the various {@code peek} functions
592     */
593    IArgConsumer copy();
594}