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.datatypes; 019 020import baritone.api.command.argparser.IArgParser; 021import baritone.api.command.argument.IArgConsumer; 022import baritone.api.command.exception.CommandException; 023 024import java.util.stream.Stream; 025 026/** 027 * An {@link IDatatype} is similar to an {@link IArgParser} in the sense that it is capable of consuming an argument 028 * to transform it into a usable form as the code desires. 029 * <p> 030 * A fundamental difference is that an {@link IDatatype} is capable of consuming multiple arguments. For example, 031 * {@link RelativeBlockPos} is an {@link IDatatypePost} which requires at least 3 {@link RelativeCoordinate} arguments 032 * to be specified. 033 * <p> 034 * Another difference is that an {@link IDatatype} can be tab-completed, providing comprehensive auto completion 035 * that can substitute based on existing input or provide possibilities for the next piece of input. 036 * 037 * @see IDatatypeContext 038 * @see IDatatypeFor 039 * @see IDatatypePost 040 */ 041public interface IDatatype { 042 043 /** 044 * Attempts to complete missing or partial input provided through the {@link IArgConsumer}} provided by 045 * {@link IDatatypeContext#getConsumer()} in order to aide the user in executing commands. 046 * <p> 047 * One benefit over datatypes over {@link IArgParser}s is that instead of each command trying to guess what values 048 * the datatype will accept, or simply not tab completing at all, datatypes that support tab completion can provide 049 * accurate information using the same methods used to parse arguments in the first place. 050 * 051 * @param ctx The argument consumer to tab complete 052 * @return A stream representing the strings that can be tab completed. DO NOT INCLUDE SPACES IN ANY STRINGS. 053 * @see IArgConsumer#tabCompleteDatatype(IDatatype) 054 */ 055 Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException; 056}