Package top.focess.qq.api.util
Class IOHandler
- java.lang.Object
-
- top.focess.command.IOHandler
-
- top.focess.qq.api.util.IOHandler
-
public abstract class IOHandler extends top.focess.command.IOHandlerThis class is used to handle input and output when executing Command.
-
-
Field Summary
Fields Modifier and Type Field Description protected static top.focess.scheduler.SchedulerSCHEDULER
-
Constructor Summary
Constructors Constructor Description IOHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidasync(java.util.function.Consumer<IOHandler> consumer)static IOHandlergetConsoleIoHandler()abstract booleanhasInput(boolean flag, int seconds)Indicate there needs an input String and wait for the seconds<T> Tinput(top.focess.command.DataConverter<T> dataConverter)Used to convert the input String into the target typevoidoutputLang(String key, Object... objects)Used to output formatted language keystatic voidsetConsoleIoHandler(IOHandler consoleIoHandler)
-
-
-
Method Detail
-
input
@Nullable public <T> T input(top.focess.command.DataConverter<T> dataConverter) throws top.focess.command.InputTimeoutExceptionUsed to convert the input String into the target type- Type Parameters:
T- the target type- Parameters:
dataConverter- the data converter- Returns:
- the value in the target type or null if the input is not accepted by the dataConverter
- Throws:
top.focess.command.InputTimeoutException- if the input timeout
-
getConsoleIoHandler
public static IOHandler getConsoleIoHandler()
-
setConsoleIoHandler
public static void setConsoleIoHandler(IOHandler consoleIoHandler)
-
async
public void async(java.util.function.Consumer<IOHandler> consumer)
-
outputLang
public void outputLang(String key, Object... objects)
Used to output formatted language key- Parameters:
key- the language keyobjects- the objects need to replace
-
hasInput
public abstract boolean hasInput(boolean flag, int seconds)Indicate there needs an input String and wait for the seconds- Parameters:
seconds- the timeout secondsflag- true if you need the MiraiCode of this input when it is a Mirai Message, false if you need the string value of this input- Returns:
- true if there is an input String, false otherwise
- See Also:
IOHandler.hasInput(boolean)
-
-