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(int seconds)Indicate there needs an input String and wait for the secondsvoidinput(@Nullable Message message)<T> Tinput(top.focess.command.DataConverter<T> dataConverter)Used to convert the input String into the target type@NonNull MessageinputMessage()voidoutputLang(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(int seconds)
Indicate there needs an input String and wait for the seconds- Parameters:
seconds- the timeout seconds- Returns:
- true if there is an input String, false otherwise
-
input
public void input(@Nullable @Nullable Message message)
-
inputMessage
public @NonNull Message inputMessage() throws top.focess.command.InputTimeoutException
- Throws:
top.focess.command.InputTimeoutException
-
-