package io.dico.dicore.command; import io.dico.dicore.command.parameter.ArgumentBuffer; import io.dico.dicore.command.registration.CommandMap; import org.bukkit.Location; import org.bukkit.command.CommandSender; import java.util.List; import java.util.Map; public interface ICommandDispatcher { /** * Get a potentially indirect child of the root of this dispatcher * * @param buffer the argument buffer with the subsequent keys to traverse. Any keys beyond the first that isn't found are ignored. * @return the child, or this same instance of no child is found. */ ICommandAddress getDeepChild(ArgumentBuffer buffer); /** * Similar to {@link #getDeepChild(ArgumentBuffer)}, * but this method incorporates checks on the command of traversed children: * {@link Command#isVisibleTo(CommandSender)} * and {@link Command#takePrecedenceOverSubcommand(String, ArgumentBuffer)} *
* The target of a command is never null, however, the same instance might be returned, and the returned address might not hold a command. * * @param sender the sender of the command * @param buffer the command itself as a buffer. * @return the address that is the target of the command. */ @Deprecated ICommandAddress getCommandTarget(CommandSender sender, ArgumentBuffer buffer); /** * Similar to {@link #getDeepChild(ArgumentBuffer)}, * but this method incorporates checks on the command of traversed children: * {@link Command#isVisibleTo(CommandSender)} * and {@link Command#takePrecedenceOverSubcommand(String, ArgumentBuffer)} *
* The target of a command is never null, however, the same instance might be returned, and the returned address might not hold a command.
*
* @param context the context of the command. The context must not have its address set.
* @param buffer the command itself as a buffer.
* @return the address that is the target of the command.
*/
ICommandAddress getCommandTarget(ExecutionContext context, ArgumentBuffer buffer) throws CommandException;
/**
* dispatch the command
*
* @param sender the sender
* @param command the command
* @return true if a command has executed
*/
boolean dispatchCommand(CommandSender sender, String[] command);
/**
* dispatch the command
*
* @param sender the sender
* @param usedLabel the label (word after the /)
* @param args the arguments
* @return true if a command has executed
*/
boolean dispatchCommand(CommandSender sender, String usedLabel, String[] args);
/**
* dispatch the command
*
* @param sender the sender
* @param buffer the command
* @return true if a command has executed
*/
boolean dispatchCommand(CommandSender sender, ArgumentBuffer buffer);
/**
* suggest tab completions
*
* @param sender the sender as passed to {@link org.bukkit.command.Command#tabComplete(CommandSender, String, String[], Location)}
* @param location the location as passed to {@link org.bukkit.command.Command#tabComplete(CommandSender, String, String[], Location)}
* @param args the arguments as passed to {@link org.bukkit.command.Command#tabComplete(CommandSender, String, String[], Location)}
* args must be sanitized such that it contains no empty elements, particularly at the last index.
* @return tab completions
*/
List